forked from wirenboard/wb-mqtt-serial
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfile_descriptor_port.h
38 lines (32 loc) · 1.14 KB
/
file_descriptor_port.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#pragma once
#include "port.h"
#include "port_settings.h"
/*!
* Abstract port class for file descriptor based ports implementation
*/
class TFileDescriptorPort: public TPort
{
public:
TFileDescriptorPort(const PPortSettings & settings);
~TFileDescriptorPort();
void WriteBytes(const uint8_t * buf, int count) override;
uint8_t ReadByte() override;
int ReadFrame(uint8_t * buf, int count,
const std::chrono::microseconds & timeout = std::chrono::microseconds(-1),
TFrameCompletePred frame_complete = 0) override;
void SkipNoise() override;
void Close() override;
void CheckPortOpen() const override;
bool IsOpen() const override;
void Sleep(const std::chrono::microseconds & us) override;
bool Wait(const PBinarySemaphore & semaphore, const TTimePoint & until) override;
void SetDebug(bool debug) override;
bool Debug() const override;
TTimePoint CurrentTime() const override;
protected:
bool Select(const std::chrono::microseconds& us);
virtual void OnReadyEmptyFd();
int Fd;
bool DebugEnabled;
PPortSettings Settings;
};