C Language Development Kit/Functions/XModemTransmit
From OptiWiki
< C Language Development Kit | Functions(Redirected from C Language Development Kit/Functions/Xmodemtransmit)
| Description | This function uses the Xmodem protocol to transmit data through the serial communications port last opened with comopen(). xmodemtransmit() first polls with Xmodem/CRC and if there is no response it tries to poll with Xmodem/Checksum. The block size can be set to 128 or 1024 bytes with the systemsetting() function. The default block size is 128 bytes. If the data in the last block does not fill the block completely, EOF (0x1A) characters are appended up to make the block complete. | ||||||||||||||||
| Syntax | int xmodemtransmit(char * filename); | ||||||||||||||||
| Arguments | Points to a string with the name of the file that is to be transmitted.
char * filename | ||||||||||||||||
| Returns | An error code that can have one of the following values:
| ||||||||||||||||
| Remarks | The name of the file is not transmitted to the receiving side, 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 xmodemtransmit(). | ||||||||||||||||
| 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; } } } |
