Example #1
0
/*
 * send the packet in buffer.
 */
static void putpacket(char *buffer)
{
    unsigned char checksum;
    int count;
    unsigned char ch;

    /*
     * $<packet info>#<checksum>.
     */

    do {
        putDebugChar('$');
        checksum = 0;
        count = 0;

        while ((ch = buffer[count]) != 0) {
            if (!(putDebugChar(ch)))
                return;
            checksum += ch;
            count += 1;
        }

        putDebugChar('#');
        putDebugChar(hexchars[checksum >> 4]);
        putDebugChar(hexchars[checksum & 0xf]);

    }
    while ((getDebugChar() & 0x7f) != '+');
}
Example #2
0
static unsigned char *stub_puts(unsigned char *buffer)
{
  unsigned char c, sum;
  int i;

  while (1) {
    putDebugChar('$');

    i = 0;
    sum = 0;
    while ((c = buffer[i++]) != '\0') {
      putDebugChar(c);
      sum += c;
    }

    putDebugChar('#');
    putDebugChar(h2a((sum >> 4) & 0xf));
    putDebugChar(h2a(sum & 0xf));

    if (getDebugChar() == '+')
      break;
  }

  return buffer;
}
Example #3
0
/*
 * Set up exception handlers for tracing and breakpoints
 */
void set_debug_traps(void)
{
	struct hard_trap_info *ht;
	unsigned long flags;
	unsigned char c;

	save_and_cli(flags);

	for (ht = hard_trap_info; ht->tt && ht->signo; ht++)
		saved_vectors[ht->tt] = set_except_vector(ht->tt, trap_low);
#if 1 
	putDebugChar('+'); /* 'hello world' */
	/*
	 * In case GDB is started before us, ack any packets
	 * (presumably "$?#xx") sitting there.
	 */
	while((c = getDebugChar()) != '$');
	while((c = getDebugChar()) != '#');
	c = getDebugChar(); /* eat first csum byte */
	c = getDebugChar(); /* eat second csum byte */
	putDebugChar('+'); /* ack it */
#endif
	initialized = 1;
	restore_flags(flags);
}
/* send the packet in buffer.  */
int putpacket(char *buffer)
{
	unsigned char checksum;
	int count;
	unsigned char ch;

	/*  $<packet info>#<checksum>. */
	do
	{
		if(putDebugChar('$'))
			return 1;
		checksum = 0;
		count = 0;

		while((ch = (buffer[count])))
		{
			if(putDebugChar(ch))
				return 1;
			checksum += ch;
			count += 1;
		}

		if(putDebugChar('#') || putDebugChar(hexchars[checksum >> 4])
		  || putDebugChar(hexchars[checksum & 0xf]))
			return 1;

		if(getDebugChar(&ch))
			return 1;

	}
	while(ch != '+');

	return 0;
}
Example #5
0
void putpacket (char *buffer) {
    unsigned char checksum;
    int count;
    char ch;

    /*  $<packet info>#<checksum>. */
    do
    {
        putDebugChar ('$');
        checksum = 0;
        count = 0;

        while (ch = buffer[count])
        {
            putDebugChar (ch);
            checksum += ch;
            count += 1;
        }

        putDebugChar ('#');
        putDebugChar (hexchars[checksum >> 4]);
        putDebugChar (hexchars[checksum % 16]);

    }
    while (getDebugChar () != '+');

}
Example #6
0
/* scan for the sequence $<data>#<checksum>     */
static void
getpacket(char *buffer)
{
	unsigned char checksum;
	unsigned char xmitcsum;
	int i;
	int count;
	unsigned char ch;

	do {
		/* wait around for the start character, ignore all other
		 * characters */
		while ((ch = (getDebugChar() & 0x7f)) != '$') {
#ifdef KGDB_DEBUG
			if (kdebug)
				putc(ch);
#endif
			;
		}

		checksum = 0;
		xmitcsum = -1;

		count = 0;

		/* now, read until a # or end of buffer is found */
		while (count < BUFMAX) {
			ch = getDebugChar() & 0x7f;
			if (ch == '#')
				break;
			checksum = checksum + ch;
			buffer[count] = ch;
			count = count + 1;
		}

		if (count >= BUFMAX)
			continue;

		buffer[count] = 0;

		if (ch == '#') {
			xmitcsum = hex(getDebugChar() & 0x7f) << 4;
			xmitcsum |= hex(getDebugChar() & 0x7f);
			if (checksum != xmitcsum)
				putDebugChar('-');	/* failed checksum */
			else {
				putDebugChar('+'); /* successful transfer */
				/* if a sequence char is present, reply the ID */
				if (buffer[2] == ':') {
					putDebugChar(buffer[0]);
					putDebugChar(buffer[1]);
					/* remove sequence chars from buffer */
					count = strlen(buffer);
					for (i=3; i <= count; i++)
						buffer[i-3] = buffer[i];
				}
			}
		}
	} while (checksum != xmitcsum);
}
Example #7
0
/* send the packet in buffer.  */
static void
putpacket(unsigned char *buffer)
{
	unsigned char checksum;
	int count;
	unsigned char ch, recv;

	/*  $<packet info>#<checksum>. */
	do {
		putDebugChar('$');
		checksum = 0;
		count = 0;

		while ((ch = buffer[count])) {
			putDebugChar(ch);
			checksum += ch;
			count += 1;
		}

		putDebugChar('#');
		putDebugChar(hexchars[checksum >> 4]);
		putDebugChar(hexchars[checksum & 0xf]);
		recv = getDebugChar();
	} while ((recv & 0x7f) != '+');
}
Example #8
0
File: serial.c Project: kisom/pmon
static int serialtest()
{
	int i,j;

	printf("serial test\n");
	initserial(0);
	initserial(1);
	
	for(i=0;i<16;i++)
	{
	if(testDebugChar(0))getDebugChar(0);
	else break;
	}

	for(i=0;i<16;j++)
	{
	if(testDebugChar(1))getDebugChar(1);
	else break;
	}

	printf("serial 0 send data to serial 1...");
	for(i=0;i<10;i++)
	{
	putDebugChar(0,'a'+i);
	for(j=0;j<TIMEOUT;j++)
	{
	if(testDebugChar(1))break;
	}
	if(j==TIMEOUT){printf("timeout");break;}
	printf("%c",getDebugChar(1));
	}
	printf("\n");

	for(i=0;i<16;i++)
	{
	if(testDebugChar(0))getDebugChar(0);
	else break;
	}

	for(i=0;i<16;j++)
	{
	if(testDebugChar(1))getDebugChar(1);
	else break;
	}
	printf("serial 1 send data to serial 0...");

	for(i=0;i<10;i++)
	{
	putDebugChar(1,'a'+i);
	for(j=0;j<TIMEOUT;j++)
	{
	if(testDebugChar(0))break;
	}
	if(j==TIMEOUT){printf("timeout");break;}
	printf("%c",getDebugChar(0));
	}
	printf("\n");
	return 0;
}
Example #9
0
File: io.c Project: KGG814/AOS
void
imx6_uart_putchar(char c)
{
    putDebugChar(c);
    if (c == '\n') {
        putDebugChar('\r');
    }
}
Example #10
0
File: io.c Project: KGG814/AOS
void
am335x_uart_putchar(char c)
{
    putDebugChar(c);
    if (c == '\n') {
        putDebugChar('\r');
    }
}
Example #11
0
void putDebugString(char* str)
{
	while (*str != '\0') {
		putDebugChar(*str);
		str++;
	}
	putDebugChar('\r');
	return;
}
Example #12
0
void
putDebugStr(const char *str)
{
    while (*str != '\0') {
	if (*str == '\n')
	    putDebugChar('\r');
	putDebugChar(*str++);
    }
}
Example #13
0
/* Await the sequence $<data>#<checksum> and store <data> in the array buffer
   returned. */
static void
getpacket (char *buffer)
{
	unsigned char checksum;
	unsigned char xmitcsum;
	int i;
	int count;
	char ch;
	do {
		while ((ch = getDebugChar ()) != '$')
			/* Wait for the start character $ and ignore all other characters */;
		checksum = 0;
		xmitcsum = -1;
		count = 0;
		/* Read until a # or the end of the buffer is reached */
		while (count < BUFMAX) {
			ch = getDebugChar ();
			if (ch == '#')
				break;
			checksum = checksum + ch;
			buffer[count] = ch;
			count = count + 1;
		}
		buffer[count] = '\0';
		
		if (ch == '#') {
			xmitcsum = hex (getDebugChar ()) << 4;
			xmitcsum += hex (getDebugChar ());
			if (checksum != xmitcsum) {
				/* Wrong checksum */
				putDebugChar ('-');
			}
			else {
				/* Correct checksum */
				putDebugChar ('+');
				/* If sequence characters are received, reply with them */
				if (buffer[2] == ':') {
					putDebugChar (buffer[0]);
					putDebugChar (buffer[1]);
					/* Remove the sequence characters from the buffer */
					count = gdb_cris_strlen (buffer);
					for (i = 3; i <= count; i++)
						buffer[i - 3] = buffer[i];
				}
			}
		}
	} while (checksum != xmitcsum);
}
void
putDebugChar(const char c)
{
	volatile scc_uart_t	*up;
	volatile cbd_t		*tbdf;
	volatile immap_t	*im;

	if (c == '\n')
		putDebugChar ('\r');

	im = (immap_t *)CONFIG_SYS_IMMR;
	up = (scc_uart_t *)&im->im_dprambase[KGDB_PROFF_SCC];
	tbdf = (cbd_t *)&im->im_dprambase[up->scc_genscc.scc_tbase];

	/* Wait for last character to go.
	 */
	while (tbdf->cbd_sc & BD_SC_READY)
		;

	/* Load the character into the transmit buffer.
	 */
	*(volatile char *)tbdf->cbd_bufaddr = c;
	tbdf->cbd_datlen = 1;
	tbdf->cbd_sc |= BD_SC_READY;
}
/* this function is used to set up exception handlers for tracing and
   breakpoints */
void
set_debug_traps (void)
{
  stackPtr = &remcomStack[STACKSIZE / sizeof (int) - 1];

  exceptionHandler (0, _catchException0);
  exceptionHandler (1, _catchException1);
  exceptionHandler (3, _catchException3);
  exceptionHandler (4, _catchException4);
  exceptionHandler (5, _catchException5);
  exceptionHandler (6, _catchException6);
  exceptionHandler (7, _catchException7);
  exceptionHandler (8, _catchException8);
  exceptionHandler (9, _catchException9);
  exceptionHandler (10, _catchException10);
  exceptionHandler (11, _catchException11);
  exceptionHandler (12, _catchException12);
  exceptionHandler (13, _catchException13);
  exceptionHandler (14, _catchException14);
  exceptionHandler (16, _catchException16);

  /* In case GDB is started before us, ack any packets (presumably
     "$?#xx") sitting there.  */
  putDebugChar ('+');

  initialized = true;

}
Example #16
0
void
putDebugStr (const char *s)
{
	while (*s) {
		putDebugChar (*s++);
	}
}
Example #17
0
static void
putpacket (char *buffer)
{
  unsigned char checksum;
  int count;
  unsigned char ch;

  if (strlen(buffer) >= BUFMAX)
    panic("kgdb: buffer overflow");

  /*  $<packet info>#<checksum>. */
  do
    {
/*
 * This is a non-standard hack to allow use of the serial console for
 * operation as well as debugging.  Simply turn on 'remotechat' in gdb.
 *
 * This extension is not part of the Cygnus protocol, is kinda gross,
 * but gets the job done.
 */
#ifdef GDB_REMOTE_CHAT
      putDebugChar ('|');
      putDebugChar ('|');
      putDebugChar ('|');
      putDebugChar ('|');
#endif
      putDebugChar ('$');
      checksum = 0;
      count = 0;

      while ((ch=buffer[count]) != 0)
	{
	  putDebugChar (ch);
	  checksum += ch;
	  count += 1;
	}

      putDebugChar ('#');
      putDebugChar (hexchars[checksum >> 4]);
      putDebugChar (hexchars[checksum & 0xf]);
    }
  while ((getDebugChar () & 0x7f) != '+');
}
Example #18
0
File: capdl.c Project: scan/seL4
static void putEncodedChar(unsigned char c)
{
    switch (c) {
    case ESCAPE:
        putDebugChar(ESCAPE);
        putDebugChar(ESCAPE_ESCAPE);
        break;
    case START:
        putDebugChar(ESCAPE);
        putDebugChar(START_ESCAPE);
        break;
    case END:
        putDebugChar(ESCAPE);
        putDebugChar(END_ESCAPE);
        break;
    default:
        if (c < 20) {
            putDebugChar(ESCAPE);
            putDebugChar(c + 20);
        } else {
            putDebugChar(c);
        }
    }
}
/*
 * Set up exception handlers for tracing and breakpoints
 */
void set_debug_traps(void)
{
//	unsigned long flags;
	unsigned char c;

//	save_and_cli(flags);
	/*
	 * In case GDB is started before us, ack any packets
	 * (presumably "$?#xx") sitting there.
	 */
	while((c = getDebugChar()) != '$');
	while((c = getDebugChar()) != '#');
	c = getDebugChar(); /* eat first csum byte */
	c = getDebugChar(); /* eat second csum byte */
	putDebugChar('+'); /* ack it */

	gdb_stub_initialised = TRUE;
//	restore_flags(flags);
}
Example #20
0
File: serial.c Project: kisom/pmon
static int cmd_serial(int argc,char **argv)
{
int line;
if(argc!=3)return -1;
line=argv[2][0]-'0';

switch(argv[1][0])
{
case 'i':
	initserial(line);
	break;
case 'r':
	printf("%c\n",getDebugChar(line));break;
case 'w':
	putDebugChar(line,'a');
	break;
case 't':
	printf("%d\n",testDebugChar(line));
	break;
}
return 0;	
	
}
Example #21
0
void
putDebugChar(const char c)
{
	volatile cbd_t		*tbdf;
	volatile char		*buf;
	volatile smc_uart_t	*up;
	volatile immap_t	*im = (immap_t *)CONFIG_SYS_IMMR;

	if (c == '\n')
		putDebugChar ('\r');

	up = (smc_uart_t *)&(im->im_dprambase[KGDB_PROFF_SMC]);

	tbdf = (cbd_t *)&im->im_dprambase[up->smc_tbase];

	/* Wait for last character to go. */
	buf = (char *)tbdf->cbd_bufaddr;
	while (tbdf->cbd_sc & BD_SC_READY)
		;

	*buf = c;
	tbdf->cbd_datlen = 1;
	tbdf->cbd_sc |= BD_SC_READY;
}
Example #22
0
static void
putpacket(char *buffer)
{
	int checksum;
	int runlen;
	int encode;
	
	do {
		char *src = buffer;
		putDebugChar ('$');
		checksum = 0;
		while (*src) {
			/* Do run length encoding */
			putDebugChar (*src);
			checksum += *src;
			runlen = 0;
			while (runlen < RUNLENMAX && *src == src[runlen]) {
				runlen++;
			}
			if (runlen > 3) {
				/* Got a useful amount */
				putDebugChar ('*');
				checksum += '*';
				encode = runlen + ' ' - 4;
				putDebugChar (encode);
				checksum += encode;
				src += runlen;
			}
			else {
				src++;
			}
		}
		putDebugChar('#');
		putDebugChar(hex_asc_hi(checksum));
		putDebugChar(hex_asc_lo(checksum));
	} while(kgdb_started && (getDebugChar() != '+'));
}
Example #23
0
File: prom.c Project: cilynx/dd-wrt
void prom_putchar(char c)
{
	putDebugChar(c);
}
Example #24
0
void kprintf( const char *str, ... )
{
  int percent = 0;
  va_list args;
  char digits[12];
  size_t i;

  va_start(args, str);

  for(i=0; str[i]; i++ )
  {
    if( percent )
    {
      switch( str[i] )
      {
        case '%':
          putDebugChar('%');
          break;
        case 'c':
          putDebugChar((char)va_arg(args,char));
          break;
        case 'p':
        case 'x':
        case 'X':
          kprintf(kitoa(va_arg(args, int), digits, 16));
          break;
        case 's':
          kprintf(va_arg(args, char *));
          break;
        case 'u':
        case 'd':
        case 'i':
           kprintf(kitoa(va_arg(args, int), digits, 10));
          break;
        default:
          break;
      }
      percent = 0;
    }
    else
    {
      switch( str[i] )
      {
        case '%':
          percent = 1;
          break;

        case '\n':
          //doNewLine( x, y );
          putDebugChar('\r');
         // putDebugChar('\n');
          break;
/*
        case '\r':
          *x = 0;
          break;
*/
        default:
          putDebugChar( str[i] );

        //  if( ++(*x) == SCREEN_WIDTH )
        //    doNewLine( x, y );
          break;
      }
    }
  }
Example #25
0
static unsigned char *stub_gets(unsigned char *buffer)
{
  int i = 0;
  unsigned char c = 0, sum = 0, datasum = 0;
  enum {
    GETS_STATUS_WAIT_DOLLAR,
    GETS_STATUS_READY_READ,
    GETS_STATUS_READ_DATA,
    GETS_STATUS_READ_SUM_UPPER,
    GETS_STATUS_READ_SUM_LOWER,
    GETS_STATUS_END,
  } status;

  status = GETS_STATUS_WAIT_DOLLAR;

  while (status != GETS_STATUS_END) {
    if (status != GETS_STATUS_READY_READ)
      c = getDebugChar();
    switch (status) {
    case GETS_STATUS_WAIT_DOLLAR:
      if (c == '$') status = GETS_STATUS_READY_READ;
      break;
    case GETS_STATUS_READY_READ:
      i = 0;
      sum = datasum = 0;
      status = GETS_STATUS_READ_DATA;
      break;
    case GETS_STATUS_READ_DATA:
      if (c == '$') {
	status = GETS_STATUS_READY_READ;
	break;
      }
      if (c == '#') {
	buffer[i] = '\0';
	status = GETS_STATUS_READ_SUM_UPPER;
	break;
      }
      sum += c;
      buffer[i++] = c;
      break;
    case GETS_STATUS_READ_SUM_UPPER:
      datasum = a2h(c) << 4;
      status = GETS_STATUS_READ_SUM_LOWER;
      break;
    case GETS_STATUS_READ_SUM_LOWER:
      datasum |= a2h(c);
      if (sum != datasum) {
	putDebugChar('-');
	status = GETS_STATUS_WAIT_DOLLAR;
      } else {
	status = GETS_STATUS_END;
      }
      break;
    default:
      break;
    }
  }

  putDebugChar('+');
  if ((i > 2) && (buffer[2] == ':')) {
    putDebugChar(buffer[0]);
    putDebugChar(buffer[1]);
    return &buffer[3];
  }
  return buffer;
}
Example #26
0
File: gdb.c Project: JanmanX/KUDOS
/* scan for the sequence $<data>#<checksum>     */
static unsigned char *getpacket(void)
{
  char *buffer = &remcomInBuffer[0];
  unsigned char checksum;
  unsigned char xmitcsum;
  int count;
  char ch;

  while (1)
    {
      /* wait around for the start character, ignore all other characters */
      while ((ch = getDebugChar ()) != '$' && ch != EOF)
	;

      if (ch == EOF)
          return NULL;
retry:
      checksum = 0;
      xmitcsum = -1;
      count = 0;

      /* now, read until a # or end of buffer is found */
      while (count < BUFMAX)
	{
	  ch = getDebugChar ();
          if (ch == '$')
            goto retry;
	  if (ch == '#')
	    break;
	  checksum = checksum + ch;
	  buffer[count] = ch;
	  count = count + 1;
	}
      buffer[count] = 0;

      if (ch == '#')
	{
	  ch = getDebugChar ();
	  xmitcsum = hex (ch) << 4;
	  ch = getDebugChar ();
	  xmitcsum += hex (ch);

	  if (checksum != xmitcsum)
	    {
	      putDebugChar ('-');	/* failed checksum */
	    }
	  else
	    {
	      putDebugChar ('+');	/* successful transfer */

	      /* if a sequence char is present, reply the sequence ID */
	      if (buffer[2] == ':')
		{
		  putDebugChar (buffer[0]);
		  putDebugChar (buffer[1]);

		  return (unsigned char*)&buffer[3];
		}

	      return (unsigned char*)&buffer[0];
	    }
	}
    }
}
/* scan for the sequence $<data>#<checksum>     */
void
getpacket (char *buffer)
{
  unsigned char checksum;
  unsigned char xmitcsum;
  int i;
  int count;
  char ch;

  do
    {
      /* wait around for the start character, ignore all other characters */
      while ((ch = (getDebugChar () & 0x7f)) != '$');
      checksum = 0;
      xmitcsum = -1;

      count = 0;

      /* now, read until a # or end of buffer is found */
      while (count < BUFMAX)
	{
	  ch = getDebugChar () & 0x7f;
	  if (ch == '#')
	    break;
	  checksum = checksum + ch;
	  buffer[count] = ch;
	  count = count + 1;
	}
      buffer[count] = 0;

      if (ch == '#')
	{
	  xmitcsum = hex (getDebugChar () & 0x7f) << 4;
	  xmitcsum += hex (getDebugChar () & 0x7f);
	  if ((remote_debug) && (checksum != xmitcsum))
	    {
	      fprintf (stderr, "bad checksum.  My count = 0x%x, sent=0x%x. buf=%s\n",
		       checksum, xmitcsum, buffer);
	    }

	  if (checksum != xmitcsum)
	    putDebugChar ('-');	/* failed checksum */
	  else
	    {
	      putDebugChar ('+');	/* successful transfer */
	      /* if a sequence char is present, reply the sequence ID */
	      if (buffer[2] == ':')
		{
		  putDebugChar (buffer[0]);
		  putDebugChar (buffer[1]);
		  /* remove sequence chars from buffer */
		  count = strlen (buffer);
		  for (i = 3; i <= count; i++)
		    buffer[i - 3] = buffer[i];
		}
	    }
	}
    }
  while (checksum != xmitcsum);

}
Example #28
0
File: capdl.c Project: scan/seL4
void capDL(void)
{
    int result;
    int done = 0;
    while (done == 0) {
        unsigned char c;
        do {
            c = getDebugChar();
        } while (c != START);
        do {
            result = getDecodedChar(&c);
            if (result) {
                continue;
            }
            switch (c) {
            case PD_COMMAND: {
                /*pgdir */
                unsigned long arg;
                result = getArg(&arg);
                if (result) {
                    continue;
                }
                sendPD(arg);
                putDebugChar(END);
            }
            break;
            case PT_COMMAND: {
                /*pg table */
                unsigned long arg;
                result = getArg(&arg);
                if (result) {
                    continue;
                }
                sendPT(arg);
                putDebugChar(END);
            }
            break;
            case ASID_POOL_COMMAND: {
                /*asid pool */
                unsigned long arg;
                result = getArg(&arg);
                if (result) {
                    continue;
                }
                sendASIDPool(arg);
                putDebugChar(END);
            }
            break;
            case IO_PT_COMMAND: {
                /*io pt table */
                unsigned long address, level;
                result = getArg(&address);
                if (result) {
                    continue;
                }
                result = getArg(&level);
                if (result) {
                    continue;
                }
                sendIOPT(address, level);
                putDebugChar(END);
            }
            break;
            case IO_SPACE_COMMAND: {
                /*io space */
                unsigned long arg;
                result = getArg(&arg);
                if (result) {
                    continue;
                }
                sendIOSpace(arg);
                putDebugChar(END);
            }
            break;
            case RQ_COMMAND: {
                /*runqueues */
                sendRunqueues();
                putDebugChar(END);
                result = 0;
            }
            break;
            case EP_COMMAND: {
                /*endpoint waiters */
                unsigned long arg;
                result = getArg(&arg);
                if (result) {
                    continue;
                }
                sendEPQueue(arg);
                putDebugChar(END);
            }
            break;
            case CN_COMMAND: {
                /*cnode */
                unsigned long address, sizebits;
                result = getArg(&address);
                if (result) {
                    continue;
                }
                result = getArg(&sizebits);
                if (result) {
                    continue;
                }

                sendCNode(address, sizebits);
                putDebugChar(END);
            }
            break;
            case IRQ_COMMAND: {
                sendIRQNode();
                putDebugChar(END);
                result = 0;
            }
            break;
            case VERSION_COMMAND: {
                sendVersion();
                putDebugChar(END);
            }
            break;
            case DONE: {
                done = 1;
                putDebugChar(END);
            }
            default:
                result = 0;
                break;
            }
        } while (result);
    }
}
Example #29
0
unsigned char *
getpacket (void)
{
    unsigned char *buffer = &remcomInBuffer[0];
    unsigned char checksum;
    unsigned char xmitcsum;
    int count;
    char ch;

    while (1)
    {
        /* wait around for the start character, ignore all other characters */
        while ((ch = getDebugChar ()) != '$')
            ;

retry:
        checksum = 0;
        xmitcsum = -1;
        count = 0;

        /* now, read until a # or end of buffer is found */
        while (count < BUFMAX)
        {
            ch = getDebugChar ();
            if (ch == '$')
                goto retry;
            if (ch == '#')
                break;
            checksum = checksum + ch;
            buffer[count] = ch;
            count = count + 1;
        }
        buffer[count] = 0;

        if (ch == '#')
        {
            ch = getDebugChar ();
            xmitcsum = hex (ch) << 4;
            ch = getDebugChar ();
            xmitcsum += hex (ch);

            if (checksum != xmitcsum)
            {
                if (remote_debug)
                {
                    /**
                    fprintf (stderr,
                      "bad checksum.  My count = 0x%x, sent=0x%x. buf=%s\n",
                      checksum, xmitcsum, buffer);
                      */
                }
                putDebugChar ('-');	/* failed checksum */
            }
            else
            {
                putDebugChar ('+');	/* successful transfer */

                /* if a sequence char is present, reply the sequence ID */
                if (buffer[2] == ':')
                {
                    putDebugChar (buffer[0]);
                    putDebugChar (buffer[1]);

                    return &buffer[3];
                }

                return &buffer[0];
            }
        }
    }
}