|
libdrmconf 0.15.0
A library to program DMR radios.
|
Implements the XMODEM protocol (1k + crc16 variant) for a packet stream. More...
#include <xmodem.hh>


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. | |
Implements the XMODEM protocol (1k + crc16 variant) for a packet stream.
Provides two methods to send and receive an entire "file".
| bool XModem::receive | ( | QByteArray & | buffer, |
| int | timeout = -1, | ||
| const ErrorStack & | err = ErrorStack() ) |
Receives an entire file from the device.
| buffer | The buffer to store the data in. The contents of the buffer will be cleared. |
| timeout | Specifies the time-out in milliseconds. If a negative number is set, no time-out applies. |
| err | Optional stack for error messages. |
| bool XModem::send | ( | const QByteArray & | buffer, |
| int | timeout = -1, | ||
| const ErrorStack & | err = ErrorStack() ) |
Sends the contents of buffer to the device.
| buffer | [in] Specifies the data to send. |
| timeout | Specifies the time-out in milliseconds. If a negativ number is passed, no time-out applies. |
| err | Specifies the stack for error messages. |