Browse Source

update ymodem.c

Signed-off-by: surenyi <surenyi82@163.com>
master
surenyi 5 years ago
parent
commit
79e3eff1fa
  1. 8
      lib/ymodem.c
  2. 1
      lib/ymodem.h

8
lib/ymodem.c

@ -248,6 +248,7 @@ retry:
rx->errors = 0;
rx->seq = 1;
recv_bytes = 0;
/* start to recv file contents */
fp = &rx->data[PACKET_HEADER];
for (;;) {
@ -311,7 +312,12 @@ retry:
}
if (rx->seq != rx->data[PACKET_SEQNO_INDEX]) {
put_byte(uart, NAK);
if (rx->data[PACKET_SEQNO_INDEX] == 0 && recv_bytes == 0) { /* YMODEM-1K only ? */
put_byte(uart, ACK);
put_byte(uart, WANTCRC);
} else {
put_byte(uart, NAK);
}
#ifdef YMODEM_DEBUG
printf("data phase: seq mismatch %d, expected %d\n", rx->data[PACKET_SEQNO_INDEX], rx->seq);
#endif

1
lib/ymodem.h

@ -26,6 +26,7 @@ extern "C" {
#define NAK (0x15) /* negative acknowledge */
#define CA (0x18) /* two of these in succession aborts transfer */
#define WANTCRC (0x43) /* 'C' == 0x43, request 16-bit CRC */
#define WANTG (0x47) /* 'G' == 0x47 */
#define ABORT1 (0x41) /* 'A' == 0x41, abort by user */
#define ABORT2 (0x61) /* 'a' == 0x61, abort by user */

Loading…
Cancel
Save