A serial port handler.
More...
#include <Radiant/SerialPort.hpp>
|
|
bool | close () |
| | Close the serial port. |
| |
| const QString & | deviceName () |
| | Returns the name of the device. More... |
| |
| bool | isOpen () const |
| | Checks if the port is open. More... |
| |
| bool | open (const char *device, bool stopBit, bool parityBit, int baud, int bits, int waitBytes, int waitTimeUS) |
| | Opens a serial port for communications. More... |
| |
| virtual int | read (void *buf, int bytes, bool waitfordata=true) |
| | Read bytes from the port. More... |
| |
|
| SerialPort () |
| | Constructor. |
| |
| virtual int | write (const void *buf, int bytes) |
| | Write bytes to the port. More... |
| |
| int | writeByte (uint8_t byte) |
| | Writes a byte to the port. More... |
| |
|
virtual | ~SerialPort () |
| | Delete the object and close the port. |
| |
|
| BinaryStream () |
| | Constructor. |
| |
| virtual bool | isHungUp () const |
| | Returns true if the stream has been closed. More... |
| |
| virtual bool | isPendingInput (unsigned int waitMicroSeconds=0) |
| | Returns true if the stream has at least one byte waiting to be read; otherwise returns false. More... |
| |
|
virtual | ~BinaryStream () |
| | Destructor. |
| |
A serial port handler.
This class is for binary IO with serial ports.
- Author
- Tommi Ilmonen
| const QString& Radiant::SerialPort::deviceName |
( |
| ) |
|
|
inline |
Returns the name of the device.
- Returns
- Name of the device
| bool Radiant::SerialPort::isOpen |
( |
| ) |
const |
|
virtual |
Checks if the port is open.
- Returns
- True if the port is open, false otherwise
Reimplemented from Radiant::BinaryStream.
| bool Radiant::SerialPort::open |
( |
const char * |
device, |
|
|
bool |
stopBit, |
|
|
bool |
parityBit, |
|
|
int |
baud, |
|
|
int |
bits, |
|
|
int |
waitBytes, |
|
|
int |
waitTimeUS |
|
) |
| |
Opens a serial port for communications.
If the port was open, this method will close it before opening it.
- Parameters
-
| device | name of the device to open |
| stopBit | Use two stop bits instead of one |
| parityBit | Use parity stop bit? |
| baud | The baud rate |
| bits | The number of data bits |
| waitBytes | The number of bytes to read before returning |
| waitTimeUS | Time to wait in microseconds |
- Returns
- true on success
| virtual int Radiant::SerialPort::read |
( |
void * |
buf, |
|
|
int |
bytes, |
|
|
bool |
waitfordata = true |
|
) |
| |
|
virtual |
Read bytes from the port.
- Parameters
-
| [out] | buf | output buffer |
| bytes | max bytes to read |
| waitfordata | ignored |
- Returns
- number of bytes read
Implements Radiant::BinaryStream.
| virtual int Radiant::SerialPort::write |
( |
const void * |
buf, |
|
|
int |
bytes |
|
) |
| |
|
virtual |
Write bytes to the port.
- Parameters
-
| buf | buffer to write from |
| bytes | bytes to write |
- Returns
- number of bytes written
Implements Radiant::BinaryStream.
| int Radiant::SerialPort::writeByte |
( |
uint8_t |
byte | ) |
|
Writes a byte to the port.
- Parameters
-
- Returns
- Number of bytes written