22 #if defined (_WIN32) || defined (_WIN64)
30 #include <sys/types.h>
38 #include <sys/ioctl.h>
43 #define UNUSED(x) (void)(x)
71 char openDevice (
const char *Device,
const unsigned int Bauds);
87 char readChar (
char *pByte,
const unsigned int timeOut_ms=0);
102 unsigned int maxNbBytes,
103 const unsigned int timeOut_ms=0);
112 char writeBytes (
const void *Buffer,
const unsigned int NbBytes);
115 int readBytes (
void *buffer,
unsigned int maxNbBytes,
const unsigned int timeOut_ms=0,
unsigned int sleepDuration_us=100);
138 bool DTR(
bool status);
143 bool RTS(
bool status);
168 int readStringNoTimeOut (
char *String,
char FinalChar,
unsigned int MaxNbBytes);
171 bool currentStateRTS;
172 bool currentStateDTR;
178 #if defined (_WIN32) || defined( _WIN64)
182 COMMTIMEOUTS timeouts;
211 struct timeval previousTime;
This class is used for communication over a serial device.
Definition: serialib.h:50
bool setRTS()
Set the bit RTS (pin 7) RTS stands for Data Terminal Ready.
Definition: serialib.cpp:720
serialib()
Constructor of the class serialib.
Definition: serialib.cpp:26
bool DTR(bool status)
Set or unset the bit DTR (pin 4) DTR stands for Data Terminal Ready Convenience method :This method c...
Definition: serialib.cpp:635
bool isDSR()
Get the DSR's status (pin 6) DSR stands for Data Set Ready.
Definition: serialib.cpp:792
bool isDTR()
Get the DTR's status (pin 4) DTR stands for Data Terminal Ready May behave abnormally on Windows.
Definition: serialib.cpp:861
int available()
Return the number of bytes in the received buffer (UNIX only)
Definition: serialib.cpp:600
char flushReceiver()
Empty receiver buffer.
Definition: serialib.cpp:581
bool RTS(bool status)
Set or unset the bit RTS (pin 7) RTS stands for Data Termina Ready Convenience method :This method ca...
Definition: serialib.cpp:703
char openDevice(const char *Device, const unsigned int Bauds)
Open the serial port.
Definition: serialib.cpp:92
bool isDCD()
Get the DCD's status (pin 1) CDC stands for Data Carrier Detect.
Definition: serialib.cpp:818
bool isRI()
Get the RING's status (pin 9) Ring Indicator.
Definition: serialib.cpp:839
char writeString(const char *String)
Write a string on the current serial port.
Definition: serialib.cpp:273
char readChar(char *pByte, const unsigned int timeOut_ms=0)
Wait for a byte from the serial device and return the data read.
Definition: serialib.cpp:339
bool setDTR()
Set the bit DTR (pin 4) DTR stands for Data Terminal Ready.
Definition: serialib.cpp:652
void closeDevice()
Close the connection with the current device.
Definition: serialib.cpp:217
char writeBytes(const void *Buffer, const unsigned int NbBytes)
Write an array of data on the current serial port.
Definition: serialib.cpp:307
char writeChar(char)
Write a char on the current serial port.
Definition: serialib.cpp:241
int readBytes(void *buffer, unsigned int maxNbBytes, const unsigned int timeOut_ms=0, unsigned int sleepDuration_us=100)
Read an array of bytes from the serial device (with timeout)
Definition: serialib.cpp:513
bool clearRTS()
Clear the bit RTS (pin 7) RTS stands for Data Terminal Ready.
Definition: serialib.cpp:745
int readString(char *receivedString, char finalChar, unsigned int maxNbBytes, const unsigned int timeOut_ms=0)
Read a string from the serial device (with timeout)
Definition: serialib.cpp:439
bool isRTS()
Get the RTS's status (pin 7) RTS stands for Request To Send May behave abnormally on Windows.
Definition: serialib.cpp:882
~serialib()
Destructor of the class serialib. It close the connection.
Definition: serialib.cpp:40
bool isCTS()
Get the CTS's status (pin 8) CTS stands for Clear To Send.
Definition: serialib.cpp:770
bool clearDTR()
Clear the bit DTR (pin 4) DTR stands for Data Terminal Ready.
Definition: serialib.cpp:675
This class can manage a timer which is used as a timeout.
Definition: serialib.h:197
timeOut()
Constructor of the class timeOut.
Definition: serialib.cpp:909
void initTimer()
Initialise the timer. It writes the current time of the day in the structure PreviousTime.
Definition: serialib.cpp:917
unsigned long int elapsedTime_ms()
Returns the time elapsed since initialization. It write the current time of the day in the structure ...
Definition: serialib.cpp:928