Mercurial > public > ostc_companion
comparison Serial.h @ 10:9a3c1a6f9833
TODO: FIX HW flow control definitions in case of problem during communication. Background: Flags are not defined in terminos header
| author | Ideenmodellierer |
|---|---|
| date | Mon, 12 Jan 2026 13:55:38 +0000 |
| parents | 0b3630a29ad8 |
| children |
comparison
equal
deleted
inserted
replaced
| 9:971b9fd4cd30 | 10:9a3c1a6f9833 |
|---|---|
| 42 #ifndef SERIAL_H | 42 #ifndef SERIAL_H |
| 43 #define SERIAL_H | 43 #define SERIAL_H |
| 44 | 44 |
| 45 class QString; | 45 class QString; |
| 46 | 46 |
| 47 #include <QtGlobal> // Q_OS_WIN | 47 #include <QtGlobal> // Q_OS_WIN |
| 48 | 48 |
| 49 #ifdef Q_OS_WIN | 49 #ifdef Q_OS_WIN |
| 50 #ifndef NOMINMAX | 50 #ifndef NOMINMAX |
| 51 # define NOMINMAX | 51 #define NOMINMAX |
| 52 #endif | 52 #endif |
| 53 //# define NOMINMAX | 53 //# define NOMINMAX |
| 54 # include <windows.h> | 54 #include <windows.h> |
| 55 # define S_HANDLE HANDLE | 55 #define S_HANDLE HANDLE |
| 56 # undef NOMINMAX | 56 #undef NOMINMAX |
| 57 #else | 57 #else |
| 58 # define S_HANDLE int | 58 #define S_HANDLE int |
| 59 #endif | 59 #endif |
| 60 | 60 |
| 61 ////////////////////////////////////////////////////////////////////////////// | 61 ////////////////////////////////////////////////////////////////////////////// |
| 62 // \brief RS232 serial i/o | 62 // \brief RS232 serial i/o |
| 63 class Serial | 63 class Serial |
| 64 { | 64 { |
| 65 S_HANDLE _hSerial; | 65 S_HANDLE _hSerial; |
| 66 bool _isOpen; | 66 bool _isOpen; |
| 67 | 67 |
| 68 public: | 68 public: |
| 69 inline Serial() | 69 inline Serial() |
| 70 : _hSerial(0), | 70 : _hSerial(0) |
| 71 _isOpen(false) | 71 , _isOpen(false) |
| 72 {} | 72 {} |
| 73 | 73 |
| 74 virtual ~Serial(); | 74 virtual ~Serial(); |
| 75 | 75 |
| 76 virtual void open(const QString &port, const QString& type); | 76 virtual void open(const QString &port, const QString &type); |
| 77 virtual void close(); | 77 virtual void close(); |
| 78 | 78 |
| 79 virtual void writeByte(unsigned char byte) const; | 79 virtual void writeByte(unsigned char byte) const; |
| 80 virtual unsigned char readByte() const; | 80 virtual unsigned char readByte() const; |
| 81 | 81 |
| 82 virtual void writeBlock(const unsigned char* ptr, unsigned int size) const; | 82 virtual void writeBlock(const unsigned char *ptr, unsigned int size) const; |
| 83 virtual unsigned int readBlock(unsigned char* ptr, unsigned int size) const; | 83 virtual unsigned int readBlock(unsigned char *ptr, unsigned int size) const; |
| 84 | 84 |
| 85 virtual void purge(); | 85 virtual void purge(); |
| 86 virtual void flush() const; | 86 virtual void flush() const; |
| 87 | 87 |
| 88 void writeShort(unsigned short word) const; | 88 void writeShort(unsigned short word) const; |
