- while (retries <= 10) {
- do {
- c = readchar (timeout);
- if (c == SERIAL_TIMEOUT) {
- debuglogs (3, "array_get_packet: got time out from serial port.\n");
- }
- debuglogs (3, "Waiting for a '$', got a %c\n", c);
- } while (c != '$');
-
- retries = 0;
- while (retries <= 10) {
- c = readchar (timeout);
- debuglogs (3, "array_get_packet: got a '%c'\n", c);
- switch (c) {
- case SERIAL_TIMEOUT:
- debuglogs (3, "Timeout in mid-packet, retrying\n");
- return 0;
- case '$':
- debuglogs (3, "Saw new packet start in middle of old one\n");
- return 0; /* Start a new packet, count retries */
- case '#':
- *bp = '\0';
- pktcsum = from_hex (readchar (timeout)) << 4;
- pktcsum |= from_hex (readchar (timeout));
- if (csum == 0)
- debuglogs (3, "\nGDB packet checksum zero, must be a bogus packet\n");
- if (csum == pktcsum) {
- debuglogs (3, "\nGDB packet checksum correct, packet data is \"%s\",\n", packet);
- printf_monitor ("@");
- expect_prompt (1);
- return 1;
- }
- debuglogs (3, "Bad checksum, sentsum=0x%x, csum=0x%x\n", pktcsum, csum);
- return 0;
- case '*': /* Run length encoding */
- debuglogs (5, "Run length encoding in packet\n");
- csum += c;
- c = readchar (timeout);
- csum += c;
- c = c - ' ' + 3; /* Compute repeat count */
-
- if (c > 0 && c < 255 && bp + c - 1 < packet + PBUFSIZ - 1) {
- memset (bp, *(bp - 1), c);
- bp += c;
- continue;
+ while (retries <= 10)
+ {
+ do
+ {
+ c = readchar (timeout);
+ if (c == SERIAL_TIMEOUT)
+ {
+ debuglogs (3, "array_get_packet: got time out from serial port.\n");
+ }
+ debuglogs (3, "Waiting for a '$', got a %c\n", c);