YModemRx Class Reference
[Comms - Y-Modem (and X-Modem) transmission protocol]

Y-Modem receiver object. More...

#include <ymodem_rx.h>

Inheritance diagram for YModemRx:
Inheritance graph
[legend]

List of all members.

Classes

class  OutBlock0
class  OutStream

Public Types

enum  RxError {
  ErrorOutputStreamError = -400,
  ErrorTransmitterNotBehaving = -401,
  ErrorTranferTerminatedByTransmitter = -402,
  ErrorReceivedBadData = -403,
  ErrorMultipleFilesSent = -404
}

Public Member Functions

 YModemRx (SerialPort &port)
int ReceiveX (OutStream &out, unsigned timeout, bool useCrc)
int ReceiveY (OutStream &out, unsigned timeout, bool gMode)

Private Member Functions

int ReceiveInitialise (OutStream &out, unsigned timeout)
int ReceiveBlock (OutStream &out)
int OutChar (uint8_t c)

Private Attributes

bool ExpectCRC
 Set to true if blocks will have a CRC rather than a checksum.

Detailed Description

Y-Modem receiver object.

Definition at line 38 of file ymodem_rx.h.


Member Enumeration Documentation

Enumeration of possible error values.

Enumerator:
ErrorOutputStreamError 

Error with output stream

ErrorTransmitterNotBehaving 

Unexpected data received

ErrorTranferTerminatedByTransmitter 

Transfer was terminated by sender

ErrorReceivedBadData 

Received invalid data

ErrorMultipleFilesSent 

More than one file was sent. (We only support one.)

Definition at line 106 of file ymodem_rx.h.


Constructor & Destructor Documentation

YModemRx::YModemRx ( SerialPort port  ) 

Construct a Y-Modem object which will transmit data over the given port.

Parameters:
port The port.

Definition at line 45 of file ymodem_rx.cpp.


Member Function Documentation

int YModemRx::ReceiveX ( OutStream out,
unsigned  timeout,
bool  useCrc 
)

Receive data using X-Modem.

Parameters:
out The stream of data write received data to.
timeout Time in milliseconds to wait sender to become ready.
useCrc If true the CRC checking protocol wil be used.
Returns:
Zero if transfer was successful, or a negative error value if failed.

Definition at line 209 of file ymodem_rx.cpp.

int YModemRx::ReceiveY ( OutStream out,
unsigned  timeout,
bool  gMode 
)

Receive data using Y-Modem.

Parameters:
out The stream of data write received data to.
timeout Time in milliseconds to wait sender to become ready.
gMode If true the Y-Modem G protocol wil be used.
Returns:
Zero if transfer was successful, or a negative error value if failed.

Definition at line 315 of file ymodem_rx.cpp.

int YModemRx::ReceiveInitialise ( OutStream out,
unsigned  timeout 
) [private]

Receive first block of data.

Parameters:
out The stream of data write received data to.
timeout Time in milliseconds to wait sender to become ready.
Returns:
Zero if transfer was successful, or a negative error value if failed.

Definition at line 189 of file ymodem_rx.cpp.

int YModemRx::ReceiveBlock ( OutStream out  )  [private]

Receive a block of data. If ExpectCRC is true, possible formats of blocks are:

  • 128 byte block with CRC - SOH, blk-num, ~blk-num, data[128], CRC-hi, CRC-lo
  • 1k byte block with CRC - STX, blk-num, ~blk-num, data[1024], CRC-hi, CRC-lo

If ExpectCRC is false, possible formats of blocks are:

  • 128 byte block with checksum - SOH, blk-num, ~blk-num, data[128], chsum
  • 1k byte block with checksum - STX, blk-num, ~blk-num, data[1024], chsum
Parameters:
out The stream of data write received data to.
Returns:
The number of data bytes in the received block, zero if transfer ended, or a negative error value if failed.

Definition at line 82 of file ymodem_rx.cpp.

int YModemRx::OutChar ( uint8_t  c  )  [private]

Transmit a single character.

Parameters:
c The character.
Returns:
One if successful, or a negative error value if failed.

Definition at line 58 of file ymodem_rx.cpp.


The documentation for this class was generated from the following files:

Generated by  doxygen 1.6.1