Go to the documentation of this file.
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);
217 virtual ssize_t
ReadLine (std::string &buffer) {
return ReadStringUntil (buffer,
'\n'); }
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);
280 {
return WriteString (buffer.c_str ()); }
313 virtual bool IsBlocking ()
const {
return (_timeout._sec != 0 ||
314 _timeout._usec != 0); }
318 virtual bool CanRead ()
const {
return _canRead; }
322 virtual bool CanWrite ()
const {
return _canWrite; }
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&);
virtual bool IsOpen() const =0
Check if the port is open.
virtual void SetCanRead(bool canRead)=0
Set the read permissions of the port.
virtual ssize_t BytesAvailable()=0
Get the number of bytes waiting to be read at the port.
virtual ssize_t WriteString(const std::string &buffer)
void SetDebug(int debug)
Set the debug level.
virtual ssize_t ReadFull(void *const buffer, size_t count)=0
Read the requested quantity of data from the port.
virtual ssize_t ReadLine(char *const buffer, size_t count)
Read a new-line terminated string of data.
virtual ssize_t Read(void *const buffer, size_t count)=0
Read from the port.
virtual ssize_t WriteString(const char *const buffer)
Write a string to the port.
virtual void Close()=0
Close the port.
virtual bool ProcessOption(const std::string &option, const std::string &value)
virtual ssize_t WriteFull(const void *const buffer, size_t count)
Write all the data to the port.
void ProcessOptions(const std::map< std::string, std::string > &options)
int GetDebug() const
Get the debug level.
virtual Timeout GetTimeout() const
Get the timeout.
virtual void Drain()=0
Drain the port's output buffers.
virtual bool IsBlocking() const
Get the blocking property of the port.
virtual ssize_t Write(const void *const buffer, size_t count)=0
Write data to the port.
virtual ssize_t BytesAvailableWait()=0
Get the number of bytes waiting after blocking for the timeout.
virtual void Open()=0
Open the port.
virtual void SetCanWrite(bool canWrite)=0
Set the write permissions of the port.
virtual bool CanWrite() const
Get the write permissions of the port.
virtual ssize_t ReadString(std::string &buffer)
Read a string.
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 std::string GetStatus() const
Get the status of the port (type, device, etc).
virtual ssize_t ReadStringUntil(std::string &buffer, char terminator)
Read a string until the specified termination character is received.
virtual void SetTimeout(Timeout timeout)=0
Set the timeout value.
virtual bool CanRead() const
Get the read permissions of the port.
Port(unsigned int debug, Timeout timeout, bool canRead, bool canWrite, bool alwaysOpen)
virtual ssize_t ReadUntil(void *const buffer, size_t count, uint8_t terminator)
Read data until a specified termination byte is received.
virtual ssize_t ReadLine(std::string &buffer)
Read a new-line terminated string of data.
virtual void Flush()=0
Flush the port's input and output buffers, discarding all data.
virtual void CheckPort(bool read)=0
virtual ssize_t Skip(size_t count)
Dump data until the specified number of bytes have been read.
An object used to represent timeouts.
std::string GetPortType() const
Get the port type.