Skip to content

Commit

Permalink
!fixme! temporarily disable skipping checksum
Browse files Browse the repository at this point in the history
Because of skipping the checksum, when we start a new session and disable no ack mode, the next command will fail to send twice because we still have the checksum in the buffer and then expect to receive an ACK
  • Loading branch information
perigoso committed Jul 21, 2023
1 parent 71cc1f6 commit 460cc7b
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/gdb_packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ size_t gdb_getpacket(char *const packet, const size_t size)
uint8_t rx_checksum = 0, checksum = 0;

while (true) {
const char rx_char = state != PACKET_GDB_COMPLETE ? gdb_if_getchar() : '\0';
// const char rx_char = state != PACKET_GDB_COMPLETE ? gdb_if_getchar() : '\0';
const char rx_char = gdb_if_getchar();
if (rx_char == '\x04') {
/* EOT (end of transmission) - connection was closed */
packet[0] = '\x04';
Expand Down Expand Up @@ -161,8 +162,12 @@ size_t gdb_getpacket(char *const packet, const size_t size)
}
if (rx_char == GDB_PACKET_END) {
/* End of GDB packet */
/* Move to checksum capture or knowlingly ignore the checksum that follows in no ack mode (as per spec) */
state = noackmode ? PACKET_GDB_COMPLETE : PACKET_GDB_CHECKSUM_UPPER;
// if (noackmode)
// /* knowlingly ignore the checksum that follows in no ack mode (as per spec) */
// state = PACKET_GDB_COMPLETE;
// else
/* Move to checksum capture */
state = PACKET_GDB_CHECKSUM_UPPER;
break;
}

Expand Down Expand Up @@ -198,10 +203,11 @@ size_t gdb_getpacket(char *const packet, const size_t size)
case PACKET_GDB_CHECKSUM_LOWER:
/* Checksum lower nibble */
rx_checksum |= unhex_digit(rx_char); /* BITWISE OR lower nibble with upper nibble */
state = PACKET_GDB_COMPLETE;
break;

case PACKET_GDB_COMPLETE:
// state = PACKET_GDB_COMPLETE;
// break;
// case PACKET_GDB_COMPLETE:

if (!noackmode)
/* (N)Acknowledge packet */
gdb_if_putchar(rx_checksum == checksum ? GDB_PACKET_ACK : GDB_PACKET_NACK, 1U);
Expand Down

0 comments on commit 460cc7b

Please sign in to comment.