libdrmconf 0.15.0
A library to program DMR radios.
Loading...
Searching...
No Matches
XModem Class Reference

Implements the XMODEM protocol (1k + crc16 variant) for a packet stream. More...

#include <xmodem.hh>

Inheritance diagram for XModem:
Collaboration diagram for XModem:

Public Member Functions

 XModem (OpenRTXLinkStream *transferLayer, QObject *parent=nullptr)
 Constructs a xmodem connection via the USB device specified by descriptor.
bool receive (QByteArray &buffer, int timeout=-1, const ErrorStack &err=ErrorStack())
 Receives an entire file from the device.
bool send (const QByteArray &buffer, int timeout=-1, const ErrorStack &err=ErrorStack())
 Sends the contents of buffer to the device.

Protected Types

enum class  State { Init , Transfer , Error }
 Possible states of the state machine.
enum  CtrlByte {
  SOH = 0x01 , STX = 0x02 , EOT = 0x04 , ACK = 0x06 ,
  NAK = 0x15 , CAN = 0x18 , CRC = 0x43
}
 Possible XMODEM control bytes.

Protected Member Functions

bool rxByte (uint8_t &b, int timeout=-1, const ErrorStack &err=ErrorStack())
 Recives a single byte from the device.
bool txByte (uint8_t b, int timeout=-1, const ErrorStack &err=ErrorStack())
 Sends a single byte to the device.
bool rxBytes (uint8_t *data, unsigned int size, int timeout=-1, const ErrorStack &err=ErrorStack())
 Receives exactly size bytes from the device.
bool txBytes (const uint8_t *data, unsigned int size, int timeout=-1, const ErrorStack &err=ErrorStack())
 Sends exactly size bytes to the device.

Static Protected Member Functions

static uint16_t crc_ccitt (const QByteArray &data)
 Computes the CRC16 checksum.

Detailed Description

Implements the XMODEM protocol (1k + crc16 variant) for a packet stream.

Provides two methods to send and receive an entire "file".

Member Function Documentation

◆ receive()

bool XModem::receive ( QByteArray & buffer,
int timeout = -1,
const ErrorStack & err = ErrorStack() )

Receives an entire file from the device.

Parameters
bufferThe buffer to store the data in. The contents of the buffer will be cleared.
timeoutSpecifies the time-out in milliseconds. If a negative number is set, no time-out applies.
errOptional stack for error messages.

◆ send()

bool XModem::send ( const QByteArray & buffer,
int timeout = -1,
const ErrorStack & err = ErrorStack() )

Sends the contents of buffer to the device.

Parameters
buffer[in] Specifies the data to send.
timeoutSpecifies the time-out in milliseconds. If a negativ number is passed, no time-out applies.
errSpecifies the stack for error messages.

The documentation for this class was generated from the following files:
  • /builddir/build/BUILD/qdmr-0.15.0-build/qdmr-0.15.0/lib/xmodem.hh
  • /builddir/build/BUILD/qdmr-0.15.0-build/qdmr-0.15.0/lib/xmodem.cc