31 #ifndef _uart_peripheral_h_ 32 #define _uart_peripheral_h_ 34 #include "Peripheral.h" 35 #include "packet/command_packet.h" 52 kUartPeripheral_UnusedTimeout = 0,
54 kUartPeripheral_DefaultReadTimeoutMs = 1000,
55 kUartPeripheral_DefaultBaudRate = 9600
67 UartPeripheral(
const char *port,
long speed = kUartPeripheral_DefaultBaudRate);
83 virtual status_t
read(uint8_t *buffer, uint32_t requestedBytes, uint32_t *actualBytes, uint32_t unused_timeoutMs);
89 virtual status_t
write(
const uint8_t *buffer, uint32_t byteCount);
100 bool init(
const char *port,
long speed);
110 #endif // _uart_peripheral_h_ Definition: BlfwkErrors.h:16
Peripheral that talks to the target device over COM port hardware.
Definition: UartPeripheral.h:45
void flushRX()
Flush.
Definition: UartPeripheral.cpp:126
int m_fileDescriptor
Port file descriptor.
Definition: UartPeripheral.h:102
_uart_peripheral_constants
Constants.
Definition: UartPeripheral.h:49
virtual status_t write(const uint8_t *buffer, uint32_t byteCount)
Write bytes.
Definition: UartPeripheral.cpp:145
UartPeripheral(const char *port, long speed=kUartPeripheral_DefaultBaudRate)
Parameterized constructor that opens the serial port.
Definition: UartPeripheral.cpp:43
uint8_t m_buffer[kDefaultMaxPacketSize]
Buffer for bytes used to build read packet.
Definition: UartPeripheral.h:103
bool init(const char *port, long speed)
Initialize.
Definition: UartPeripheral.cpp:54
Represents a peripheral.
Definition: Peripheral.h:48
virtual status_t read(uint8_t *buffer, uint32_t requestedBytes, uint32_t *actualBytes, uint32_t unused_timeoutMs)
Read bytes.
Definition: UartPeripheral.cpp:87
virtual ~UartPeripheral()
Destructor.
Definition: UartPeripheral.cpp:78