I'm trying to create a file sender program for the XMODEM protocol. This is the simplest of all modem protocols. No error correction other than a simple checksum byte.
My references have been this wiki article http://en.wikipedia.org/wiki/XMODEM
and this document that appears to be official http://techheap.packetizer.com/commu...ms/xmodem.html
Unfortunately I haven't found out a couple important things.
One of these is, what do I do if the data I'm sending is not an exact multiple of 128 bytes?
I know it needs to be by bytes up to a 128byte boundary, with the value of these bytes being 0x1A (an ascii SUB control character), but it doesn't say how to indicate to the receiving program that the file is less than a multiple of 128 bytes. Without this indication, there is no way for a receiving program (such as HyperTerminal) to know if the 0x1A bytes at the end are just padding, and not part of the actual file. I tried to ignore the padding bytes when calculating the checksum, so hoping that the receiving program would be able to use this information to ignore the proper number of padding bytes, but at least in HyperTerminal, this caused it to think that the file had an error (checksum sent didn't match checksum calculated including all padding bytes) and always replied with NAK. I found that I had to use all the padding bytes in the checksum in order to get HyperTerminal to recognize it as correct and reply with ACK. But then it wrote all the data to the file including the padding bytes.
If you know about the part of the XMODEM protocol that indicates the intended file size to the receiver (something that may not appear in most documentation), please help me out.
My references have been this wiki article http://en.wikipedia.org/wiki/XMODEM
and this document that appears to be official http://techheap.packetizer.com/commu...ms/xmodem.html
Unfortunately I haven't found out a couple important things.
One of these is, what do I do if the data I'm sending is not an exact multiple of 128 bytes?
I know it needs to be by bytes up to a 128byte boundary, with the value of these bytes being 0x1A (an ascii SUB control character), but it doesn't say how to indicate to the receiving program that the file is less than a multiple of 128 bytes. Without this indication, there is no way for a receiving program (such as HyperTerminal) to know if the 0x1A bytes at the end are just padding, and not part of the actual file. I tried to ignore the padding bytes when calculating the checksum, so hoping that the receiving program would be able to use this information to ignore the proper number of padding bytes, but at least in HyperTerminal, this caused it to think that the file had an error (checksum sent didn't match checksum calculated including all padding bytes) and always replied with NAK. I found that I had to use all the padding bytes in the checksum in order to get HyperTerminal to recognize it as correct and reply with ACK. But then it wrote all the data to the file including the padding bytes.
If you know about the part of the XMODEM protocol that indicates the intended file size to the receiver (something that may not appear in most documentation), please help me out.