I am using Teraterm 4.87 as the interface to a target embedded system. The connection is through a USB-SERIAL port and I am using the XMODEM file transfer protocol to download code to the target bootloader. The problem I am having is that the first packet is transmitted twice by Teraterm.
Upon inspection, what appears to be happening is the following:
1) From the terminal, I type in a command that sets my target board into XMODEM RX mode where it starts issuing NAK characters to prompt the sender to begin sending data.
2) During the time I traverse the file transfer menu and select XMODEM, and then type in the file and press return, the target board has had time to send multiple NAK characters which are now queued in Teraterms RX buffer.
3) Teraterm send logic see the initial NAK and correctly sends out the first packet. While waiting for the ACK/NAK response, the sender immediately sees the previous NAK that was sent out by the target board while it was waiting for the first packet. The sender then re-sends the same packet.
4) Eventually, the queued NAK characters are consumed and the ACK is detected.
5) The remainder of the transfer follows normally.
In summary, the problem is that the sender does not flush the input queue before waiting for the first NAK to begin the send.
Ideally, the moment the ENTER key is pressed to signal start of send, Teraterm should flush the input queue and then wait for the next incoming NAK to begin transfer.