Skip to content

Commit

Permalink
bugfix : cancel sequence when Rx sends CAN.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomonobu Saito authored and Tomonobu Saito committed Dec 11, 2019
1 parent 2e5092e commit 246f023
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions XModem/XModem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ char XModem::waitACK(void)
if (i > 200)
return (-1);
if (inChar == CAN)
return (-1);
return CAN;
} while ((inChar != NAK) && (inChar != ACK) && (inChar != 'C'));
return (inChar);
}
Expand Down Expand Up @@ -130,11 +130,11 @@ void XModem::sendFile(File dataFile, const char *fileName)
this->outputByte((uint8_t)0x00);
}
if (oldChecksum)
port->write((char)255 - checksumBuf);
port->write((char)checksumBuf);
else
{
port->write((char) (crcBuf >> 8));
port->write((char) (crcBuf & 0xFF));
port->write((char)(crcBuf >> 8));
port->write((char)(crcBuf & 0xFF));
}
// Discard ACK/NAK/CAN, in case
// we communicate to an XMODEM-1k client
Expand Down Expand Up @@ -195,6 +195,7 @@ void XModem::sendFile(File dataFile, const char *fileName)
}

inChar = waitACK();
if (CAN == inChar) goto err;
tryNo++;
if (tryNo > MAX_RETRY)
goto err;
Expand Down

0 comments on commit 246f023

Please sign in to comment.