36 #if defined (FLEXIPORT_STATIC)
37 #define FLEXIPORT_EXPORT
38 #elif defined (flexiport_EXPORTS)
39 #define FLEXIPORT_EXPORT __declspec (dllexport)
41 #define FLEXIPORT_EXPORT __declspec (dllimport)
44 #define FLEXIPORT_EXPORT
107 virtual ssize_t
Read (
void *
const buffer,
size_t count) = 0;
119 virtual ssize_t
ReadFull (
void *
const buffer,
size_t count) = 0;
146 virtual ssize_t
ReadUntil (
void *
const buffer,
size_t count, uint8_t terminator);
197 virtual ssize_t
ReadLine (
char *
const buffer,
size_t count);
223 virtual ssize_t
Skip (
size_t count);
230 virtual ssize_t
SkipUntil (uint8_t terminator,
unsigned int count);
257 virtual ssize_t
Write (
const void *
const buffer,
size_t count) = 0;
266 virtual ssize_t
WriteFull (
const void *
const buffer,
size_t count);
338 Port (
unsigned int debug,
Timeout timeout,
bool canRead,
bool canWrite,
bool alwaysOpen);
341 virtual bool ProcessOption (
const std::string &option,
const std::string &value);
347 void operator= (
const Port&);
Port(unsigned int debug, Timeout timeout, bool canRead, bool canWrite, bool alwaysOpen)
virtual ssize_t SkipUntil(uint8_t terminator, unsigned int count)
Read and dump data until the specified termination character has been seen count times.
virtual ssize_t BytesAvailableWait()=0
Get the number of bytes waiting after blocking for the timeout.
std::string GetPortType() const
Get the port type.
virtual bool CanWrite() const
Get the write permissions of the port.
virtual bool CanRead() const
Get the read permissions of the port.
virtual ssize_t ReadLine(std::string &buffer)
Read a new-line terminated string of data.
virtual bool ProcessOption(const std::string &option, const std::string &value)
virtual ssize_t ReadUntil(void *const buffer, size_t count, uint8_t terminator)
Read data until a specified termination byte is received.
virtual void SetCanWrite(bool canWrite)=0
Set the write permissions of the port.
virtual ssize_t Skip(size_t count)
Dump data until the specified number of bytes have been read.
virtual ssize_t WriteFull(const void *const buffer, size_t count)
Write all the data to the port.
virtual void Flush()=0
Flush the port's input and output buffers, discarding all data.
virtual void SetTimeout(Timeout timeout)=0
Set the timeout value.
virtual ssize_t WriteString(const char *const buffer)
Write a string to the port.
virtual bool IsBlocking() const
Get the blocking property of the port.
virtual ssize_t BytesAvailable()=0
Get the number of bytes waiting to be read at the port.
virtual ssize_t Read(void *const buffer, size_t count)=0
Read from the port.
virtual void Open()=0
Open the port.
virtual void SetCanRead(bool canRead)=0
Set the read permissions of the port.
virtual void Drain()=0
Drain the port's output buffers.
virtual ssize_t ReadString(std::string &buffer)
Read a string.
void ProcessOptions(const std::map< std::string, std::string > &options)
virtual std::string GetStatus() const
Get the status of the port (type, device, etc).
virtual ssize_t WriteString(const std::string &buffer)
virtual void CheckPort(bool read)=0
virtual ssize_t ReadFull(void *const buffer, size_t count)=0
Read the requested quantity of data from the port.
virtual bool IsOpen() const =0
Check if the port is open.
void SetDebug(int debug)
Set the debug level.
virtual Timeout GetTimeout() const
Get the timeout.
virtual ssize_t Write(const void *const buffer, size_t count)=0
Write data to the port.
virtual ssize_t ReadLine(char *const buffer, size_t count)
Read a new-line terminated string of data.
virtual void Close()=0
Close the port.
int GetDebug() const
Get the debug level.
virtual ssize_t ReadStringUntil(std::string &buffer, char terminator)
Read a string until the specified termination character is received.
An object used to represent timeouts.