RS-232 Library Chapter 5
LabWindows/CVI Standard Libraries 5-34 © National Instruments Corporation
XModemReceive tries ((maximum#ofTries + 1) / 2) times to negotiate a CRC error check
transfer. If there is no response, it tries to negotiate a check sum transfer up to
((maximum#ofTries -1) / 2) times.
The file is opened in binary mode, and carriage returns and linefeeds are not treated as ASCII
characters. They are written to the RS-232 line, untouched.
If the size of the file being sent is not an even multiple of the packet size, the file received is
padded with NUL (0) bytes. For example, if the file being sent contains only the string HELLO,
the file written to disk contains the letters HELLO followed by (packet size - 5) bytes of zero. If
the packet size is 128, the file contains the five letters in HELLO and 123 zero bytes.
The standard XModem protocol only supports 128 and 1024 packet sizes. The sender sends an
SOH (0x01) character to indicate that the packet size is 128, or an STX character (0x02) to
indicate that the packet size is 1024. LabWindows/CVI attempts to support any packet size. As a
receiver, when LabWindows/CVI receives an STX character from the sender, it switches to
1024 packet size regardless of what the user specifies. When it receives an SOH character from
the sender, it uses the packet size specified by the user.
For transfers with a large packet size and a low baud rate, a large delay period is recommended.
Example
/* Receive the file c:\test\data from COM1 */
/* NOTE: use \\ in path name in C instead of \. */
int n;
OpenComConfig(1, 9600, 1, 8, 1, 256, 256, 0, 0);
n = XModemReceive (1, "c:\\test\\data");
if (n != 0)
FmtOut ("Error %d in receiving file",rs232err);
else
FmtOut ("File successfully received.");
XModemSendint result = XModemSend (int COMPort, char fileName[]);
Purpose
Reads data from fileName file and sends it in packets over the com port specified by COMPort.
Parameters
Input COMPort integer Range 1 through 32.
fileName string Contains the pathname.