This acts as a test program for the Y-Modem implementation and is a useful utility in its own right. It also supports receiving a 'log' after transmitting files; this can be used when sending a file to a development board and receiving instrumentation output which comes back on same port.
Usage: ymodem [OPTION]... FILE [DST-FILE]
-s[y|x|k] Send file.
If 'y' is specifieied Y-Modem protocol is used. (Default)
If 'x' is specifieied X-Modem protocol is used.
If 'k' is specifieied X-Modem 1K protocol is used.
-r[y|g|x|c] Receive file.
If 'y' is specifieied Y-Modem protocol is used. (Default)
If 'g' is specifieied Y-Modem G protocol is used.
If 'x' is specifieied X-Modem protocol is used.
If 'c' is specifieied X-Modem CRC protocol is used.
-pPORT Use communications port PORT.
-bBAUD Set baud rate for port to BAUD.
-tTIMEOUT Set timeout for transfer start (in seconds).
-lfLOG Capture log after transfer and write it to file LOG.
-ltLOGTIMEOUT Timeout for log capture (in seconds).
-lxSTRING End log capture when STRING is received.
-le Echo the captured log to STDOUT.
FILE is optional when receiving a file by Y-Modem: options -ry or -rg DST-FILE is the name sent to receiver when using Y-Modem. Default is FILE.
Program exit values:
-le option to echo the captured log to STDOUT. 2007-05-28
Classes | |
| class | InFile |
| class | OutFile |
Defines | |
| #define | DEFAULT_PORT 1 |
| #define | DEFAULT_BAUD 115200 |
| #define | DEFAULT_TIMEOUT 30 |
| #define | DEFAULT_LOG_TIMEOUT 10 |
| #define | MAX_LOG_END_STRING_LENGTH 128 |
| #define | STRINGIFY2(a) #a |
| #define | STRINGIFY(a) STRINGIFY2(a) |
Enumerations | |
| enum | Error { ErrorNoMemory = -500, ErrorLogFileError = -501 } |
Functions | |
| void | Help () |
| void | UsageError (const char *format,...) |
| void | Error (int error, const char *format,...) |
| bool | GetIntArg (const char *argStr, unsigned &arg) |
| Parse an integer command-line argument. | |
| bool | GetTimeoutArg (const char *argStr, unsigned &arg) |
| Parse an command-line timeout argument. | |
| void | ParseArgs (int argc, char **argv) |
| void | CaptureLog (SerialPort *port) |
| void | Send (SerialPort *port) |
| void | Receive (SerialPort *port) |
| int | main (int argc, char **argv) |
Variables | |
| const char * | ProgramName |
| unsigned | PortNum = DEFAULT_PORT |
| unsigned | PortBaud = DEFAULT_BAUD |
| unsigned | Timeout = DEFAULT_TIMEOUT*1000 |
| bool | XModemFlag = false |
| bool | CrcFlag = false |
| bool | KModeFlag = false |
| bool | GModeFlag = false |
| bool | SendFlag = false |
| bool | ReceiveFlag = false |
| const char * | FileName = 0 |
| const char * | DstFileName = 0 |
| const char * | LogFileName = 0 |
| unsigned | LogTimeout = DEFAULT_LOG_TIMEOUT*1000 |
| const char * | LogEndString = 0 |
| size_t | LogEndStringLength = 0 |
| bool | LogEcho = false |
| FILE * | LogFile = 0 |
|
|
Default value for PortNum Definition at line 89 of file ymodem_main.cpp. |
|
|
Default value for PortBaud Definition at line 90 of file ymodem_main.cpp. |
|
|
Default value (in seconds) for Timeout Definition at line 91 of file ymodem_main.cpp. |
|
|
Default value (in seconds) for LogTimeout Definition at line 92 of file ymodem_main.cpp. |
|
|
Maximum length for LogEndString Definition at line 93 of file ymodem_main.cpp. |
|
|
Helper for STRINGIFY Definition at line 122 of file ymodem_main.cpp. |
|
|
Convert a into a quoted string Definition at line 123 of file ymodem_main.cpp. |
|
|
Definition at line 116 of file ymodem_main.cpp. |
|
|
Display help message, then exit. Definition at line 128 of file ymodem_main.cpp. |
|
||||||||||||
|
Print message when a bad command line is detected. Then do
Definition at line 164 of file ymodem_main.cpp. |
|
||||||||||||||||
|
Print message when a error is detected. Then do
Definition at line 183 of file ymodem_main.cpp. |
|
||||||||||||
|
Parse an integer command-line argument. This converts a decimal string into an unsigned integer.
Definition at line 206 of file ymodem_main.cpp. |
|
||||||||||||
|
Parse an command-line timeout argument. This converts a decimal string representing a number of seconds into an unsigned integer representing milliseconds.
Definition at line 228 of file ymodem_main.cpp. |
|
||||||||||||
|
Parse all of the command-line arguments.
Definition at line 247 of file ymodem_main.cpp. |
|
|
Capture data from the serial port and write it to the 'capture log' file. Log capture ends either when no data has been received for LogTimeout milliseconds, or when characters matching LogEndString are found.
Definition at line 573 of file ymodem_main.cpp. |
|
|
Send the file.
Definition at line 653 of file ymodem_main.cpp. |
|
|
Receive a file.
Definition at line 685 of file ymodem_main.cpp. |
|
||||||||||||
|
Main function.
Definition at line 725 of file ymodem_main.cpp. |
|
|
Name of this program Definition at line 96 of file ymodem_main.cpp. |
|
|
Serial port number to use Definition at line 97 of file ymodem_main.cpp. |
|
|
Baud rate for serial port Definition at line 98 of file ymodem_main.cpp. |
|
|
Timeout (in milliseconds) before aborting transfer Definition at line 99 of file ymodem_main.cpp. |
|
|
True for X-Modem, false for Y-Modem Definition at line 100 of file ymodem_main.cpp. |
|
|
True for X-Modem CRC mode Definition at line 101 of file ymodem_main.cpp. |
|
|
True for Y-Modem G mode Definition at line 103 of file ymodem_main.cpp. |
|
|
True if sending file Definition at line 104 of file ymodem_main.cpp. |
|
|
True if receiving file Definition at line 105 of file ymodem_main.cpp. |
|
|
Name of file to be transferred Definition at line 106 of file ymodem_main.cpp. |
|
|
File name to send to receiver in Y-Modem transer Definition at line 107 of file ymodem_main.cpp. |
|
|
Name of file for 'capture log' Definition at line 108 of file ymodem_main.cpp. |
|
|
Timeout (in milliseconds) before aborting 'capture log' Definition at line 109 of file ymodem_main.cpp. |
|
|
String to terminate 'capture log' Definition at line 110 of file ymodem_main.cpp. |
|
|
Length of LogEndString Definition at line 111 of file ymodem_main.cpp. |
|
|
True if log should be echoed to STDOUT Definition at line 112 of file ymodem_main.cpp. |
|
|
Handle of the 'capture log' file Definition at line 564 of file ymodem_main.cpp. |
1.4.4