In asynchronous serial port using XModem file transfer:
1 #define SOH 0x01 2 #define STX 0x02 3 #define EOT 0x04 4 #define ACK 0x06 5 #define NAK 0x15 6 #define CAN 0x18 7 #define CTRLZ 0x1A
Xmodem protocol standard (each packet contains 128 bytes of data) frame format
Xmodem packet format
Byte1 Byte2 Byte3 Byte4~131 Byte132~133
Start Of Header(SOH/STX) Packet NumberID ~(Packet NumberID) Packet Data 16-Bit CRC
0 for each transmission sent to the transmission frame structure of 128 bytes, 128 bytes the use CTRLZ insufficient filling, every must send and receive information from the responding unit, and therefore less efficient, has been abandoned :
If the next packet 1 correctly send the ACK, NACK error is retransmitted; forced stopping is <CAN>, the host need not send <EOT> Confirm
2 sender, the sender transmits transmission completion <EOT> notify the recipient. Back to the receiver <ACK> to confirm;
3 is initiated by the transmission is started from the machine, 'C' representation CRC16 check, NAK indicates accumulated and verification. Check after the first CRCH CRCL
Ymodem:
YModem improvement XModem protocol is protocol, fast (a 1024-byte block of information transmission, but it also supports batch file transfers), transmission and stability. YModem into YModem-1K (block 1K, header STX, with more ) and YModem-g (removed CRC, so speed is not waiting for an ACK)
YModem is employed CRC16-CCITT CRC check European version of its generating polynomial: x16 + x12 + x5 + 1
1, the initial frame data format:
SOH 00 FF filename [ pay more as the end 00 ] filezise [00 to pay more as the end] the NUL [00 to fill the remaining expressed] CRCH CRCL
If the file size is less than 1024
SOH 01 FE data[,1A ...1A ] CRCH CRCL
2, the data format of a data frame:
STX 01 FE data[1024] CRCH CRCL
The remaining 128 to 1024: 1024 with insufficient filling 1A: STX [Index] [~ index] Data [, 1A 1A ... ] the CRCH the CRCL
The remaining 0 to 18: 128 by insufficient filling 1A: the SOH [NUM] [NUM ~ ~] Data [, 1A 1A ... ] the CRCH the CRCL
3, the end of the frame data structure:
SOH 00 FF NUL [128 th 00] CRCH CRCL
Process j file named foo.c, size 4196Byte (16 hex is 0x1064) as file transfer:: EG the sizeof ( " foo.c") =. 6; the sizeof ( " 1064") =. 5;