Difference between revisions of "Protocols"
Line 19: | Line 19: | ||
Each block contains a sequence number. When a block with the same number as the previous one is received, the receiver ignores the block. | Each block contains a sequence number. When a block with the same number as the previous one is received, the receiver ignores the block. | ||
{| class="xmodemseq" | {| class="xmodemseq" | ||
Line 51: | Line 47: | ||
| ACK | | ACK | ||
|} | |} | ||
The receiver has a timeout of 10 seconds, after which it transmits a NAK. The message sequence starts with the receiver sending the first timeout NAK to the sender, which may be sent immediately. All errors are retried for at most 10 times. | |||
A NAK must be sent by the receiver if the block data are invalid. If the block number is not the expected next one or a repetition of the recent one, the sequence is out of sync, and the receiver shall send a CAN. | |||
=== Standard XModem === | === Standard XModem === | ||
Line 70: | Line 70: | ||
|} | |} | ||
The number is a sequence number which increases by one for each successive block. The /Number field is the one's complement of the Number field and calculates as 255-Number. When the number reaches 256 it is reset to 0. | The number is a sequence number which increases by one for each successive block. The first block starts at 1. The /Number field is the one's complement of the Number field and calculates as 255-Number. When the number reaches 256 it is reset to 0. | ||
The checksum field contains the least significant byte of the sum of the data bytes of this block. | The checksum field contains the least significant byte of the sum of the data bytes of this block. | ||
Line 95: | Line 95: | ||
=== XModem/CRC === | === XModem/CRC === | ||
In this variant, a more powerful checksum algorithm is used, the CRC16 algorithm. In order to negotiate this variant for both sender and receiver, the receiver sends a "C" as the first message instead of the NAK. | |||
{| class="xmodem" | |||
! 1 | |||
! 1 | |||
! 1 | |||
! style="width:200px" | 128 | |||
! 2 | |||
|- | |||
| SOH | |||
| Number | |||
| /Number | |||
| Data bytes | |||
| CRC16 | |||
|} |
Revision as of 21:43, 7 May 2011
Communication with devices
Here is a commented log when formatting a SSSD floppy disk with the TI disk controller. Actually, this dump was achieved using MESS and putting in some printf lines.
XModem protocol
The XModem protocol transmits data in a sequence of blocks. Each block contains a part of the file to be transmitted.
Block | Block | Block | ... | Block |
The last block may require padding if the number of remaining bytes does not suffice to fill the block.
Each block contains a sequence number. When a block with the same number as the previous one is received, the receiver ignores the block.
Sender sending | Block | Block | ... | Block | EOT | ||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Receiver sending | NAK | ACK | ACK | ... | ACK | ACK |
The receiver has a timeout of 10 seconds, after which it transmits a NAK. The message sequence starts with the receiver sending the first timeout NAK to the sender, which may be sent immediately. All errors are retried for at most 10 times.
A NAK must be sent by the receiver if the block data are invalid. If the block number is not the expected next one or a repetition of the recent one, the sequence is out of sync, and the receiver shall send a CAN.
Standard XModem
Each block is defined in this way (numbers tell the number of bytes for each field):
1 | 1 | 1 | 128 | 1 |
---|---|---|---|---|
SOH | Number | /Number | Data bytes | Checksum |
The number is a sequence number which increases by one for each successive block. The first block starts at 1. The /Number field is the one's complement of the Number field and calculates as 255-Number. When the number reaches 256 it is reset to 0.
The checksum field contains the least significant byte of the sum of the data bytes of this block.
XModem-1K
XModem-1K is a variation of XModem with 1K (1024) bytes for each data block.
1 | 1 | 1 | 1024 | 1 |
---|---|---|---|---|
STX | Number | /Number | Data bytes | Checksum |
The sender may switch between 128-byte and 1024-byte blocks after receiving an ACK from the receiver.
XModem/CRC
In this variant, a more powerful checksum algorithm is used, the CRC16 algorithm. In order to negotiate this variant for both sender and receiver, the receiver sends a "C" as the first message instead of the NAK.
1 | 1 | 1 | 128 | 2 |
---|---|---|---|---|
SOH | Number | /Number | Data bytes | CRC16 |