C Language Development Kit/Functions/XModemReceive
From OptiWiki
< C Language Development Kit | Functions(Redirected from C Language Development Kit/Functions/Xmodemreceive)
| Description | This function uses the Xmodem protocol to receive blocks of data through the serial communications port last opened with comopen(). The xmodemreceive() function supports blocks with a block size of 128 or 1024 bytes (selected by the transmitting side). Xmodem/CRC and Xmodem/Checksum are also supported (selected by the transmitting side). If the data in the last block does not fill the block completely, EOF (0x1A) characters are appended to make the block complete. | ||||||||||||||||||||
| Syntax | int xmodemreceive(char * filename); | ||||||||||||||||||||
| Arguments | Points to a string with the name of the file where the data is to be stored. The file is opened and closed by the xmodemreceive(), so the file is either overwritten, or created.
char * filename | ||||||||||||||||||||
| Returns | An error code that can have one of the following values:
| ||||||||||||||||||||
| Remarks | The name of the file is not received by xmodemreceive(), only the data is transferred. The COM port of the handheld terminal that is used for transmission must have been opened by comopen() before calling xmodemreceive(). | ||||||||||||||||||||
| Example | #include "lib.h" #include <stdio.h> void main( void ) { comopen( COM0 ); //direct cable, 9600,N,8,1 while( 1 ) { while( 1 ) { resetkey(); resetreceive(); printf("\fReceiving..\n"); if( xmodemreceive("test.dat") != XMR_OK) { printf("\fERROR:\nfile not received\npress any key"); while( !kbhit() ) idle(); continue; } printf("file Received OK\n\rPress key\n\r"); while( !kbhit()) idle(); break; } while( 1 ) { resetkey(); resetreceive(); printf("\fSending..\n"); if( xmodemtransmit("test.dat") != XMT_OK ) { printf("\fERROR:\nfile not send\npress any key"); while( !kbhit()) idle(); continue; } printf("file send OK\n\rPress key\n\r"); while( !kbhit() ) idle(); break; } } } |
