7 #ifndef IG_OMW_IO_SERIALPORT_H
8 #define IG_OMW_IO_SERIALPORT_H
15 #include "../../omw/defs.h"
16 #include "../../omw/string.h"
17 #include "../../omw/vector.h"
30 using baud_type = uint32_t;
32 #if defined(OMW_PLAT_WIN)
33 static void initDcb(
void* DCB_customDcb, baud_type baud);
34 #elif defined(OMW_PLAT_UNIX)
42 #if defined(OMW_PLAT_WIN)
43 int open(
const std::string& port,
void* DCB_customDcb,
const void* COMMTIMEOUTS_customTmo =
nullptr);
44 #elif defined(OMW_PLAT_UNIX)
48 int read(uint8_t* buffer,
size_t bufferSize,
size_t* nBytesRead);
49 int read(
char* buffer,
size_t bufferSize,
size_t* nBytesRead) {
return read(
reinterpret_cast<uint8_t*
>(buffer), bufferSize, nBytesRead); }
50 int readByte(uint8_t*
byte,
size_t* nBytesRead) {
return read(
byte, 1, nBytesRead); }
51 int write(
const uint8_t* data,
size_t count,
size_t* nBytesWritten =
nullptr);
52 int write(
const char* data,
size_t count,
size_t* nBytesWritten =
nullptr) {
return write(
reinterpret_cast<const uint8_t*
>(data), count, nBytesWritten); }
54 bool isOpen()
const {
return m_isOpen; }
55 bool good()
const {
return m_good; }
68 #if defined(OMW_PLAT_WIN)
70 #elif defined(OMW_PLAT_UNIX)
84 void sortSerialPortList(std::vector<omw::string>& ports);
85 void sortSerialPortList(std::vector<std::string>& ports);
90 #endif // IG_OMW_IO_SERIALPORT_H