SynchroTime
|
The class InterfaceSP provides methods to access serial ports. More...
#include <interface.h>
Public Member Functions | |
InterfaceSP (QObject *parent=0) | |
InterfaceSP::InterfaceSP Constructor of the class InterfaceSP for creating objects with default values. More... | |
InterfaceSP (QObject *parent, const QString &portName) | |
InterfaceSP::InterfaceSP Constructor of the class InterfaceSP for creating objects with default values. More... | |
InterfaceSP (QObject *parent, QSerialPort *port) | |
InterfaceSP::InterfaceSP Constructor of the class InterfaceSP for creating objects with default values. More... | |
~InterfaceSP () | |
Destructor for the class InterfaceSP. More... | |
void | init (void) |
InterfaceSP::init. More... | |
void | initSerialPort (void) |
InterfaceSP::initSerialPort Prepare a instance of the Serial Port. More... | |
void | searchAllSerialPort (void) |
InterfaceSP::searchAllSerialPort Info about all available serial ports. More... | |
bool | searchSerialPort (const QString &portName) |
InterfaceSP::searchSerialPort This method checks a serial port for existence. More... | |
QStringList | availableSerialPorts (void) |
InterfaceSP::availableSerialPorts Return a list with all available serial port names. More... | |
qint64 | writeTheData (const QByteArray &data) |
InterfaceSP::writeTheData Writes the content of byteArray to the Serial Port device. More... | |
bool | readTheData (const quint32 timewait, const quint32 bytes=0U) |
InterfaceSP::readTheData Reads all remaining data from the UART device. More... | |
QSerialPort * | getSocket (void) |
InterfaceSP::getSocket. More... | |
void | initSocket (void) |
InterfaceSP::initSocket. More... | |
bool | openSocket (void) |
InterfaceSP::openSocket. More... | |
void | closeSocket (void) |
InterfaceSP::closeSocket. More... | |
QString | getPortName (void) const |
InterfaceSP::getPortName. More... | |
qint32 | getPortBaudRate (void) const |
InterfaceSP::getPortBaudRate Returns the baud rate of the serial port. More... | |
QString | getDescription (void) const |
InterfaceSP::getDescription. More... | |
QString | getManufacturer (void) const |
InterfaceSP::getManufacturer. More... | |
QString | getSerialNumber (void) const |
InterfaceSP::getSerialNumber. More... | |
quint16 | getProductIdentifier (void) const |
InterfaceSP::getProductIdentifier. More... | |
QSerialPortInfo | getSerialPortInfo (void) const |
InterfaceSP::getSerialPortInfo. More... | |
QSerialPort * | getSerialPort (void) |
InterfaceSP::getSerialPort. More... | |
Public Member Functions inherited from Interface | |
Interface (QObject *parent=0) | |
Interface::Interface Constructor of the class Interface for creating objects with default values. More... | |
void | setBlockSize (const quint16 size) |
Interface::setBlockSize. More... | |
quint16 | getBlockSize (void) const |
Interface::getBlockSize. More... | |
quint32 | getReceivedBytes (void) const |
Interface::getReceivedBytes. More... | |
void | setTimer (QTimer *timer) |
Interface::setTimer. More... | |
QTimer * | getTimer (void) |
Interface::getTimer. More... | |
void | setTimeout (quint32 time) |
Interface::setTimeout. More... | |
quint32 | getTimeout (void) const |
Interface::getTimeout. More... | |
QByteArray & | getReceivedData (void) |
Interface::getReceivedData. More... | |
Public Member Functions inherited from Base | |
Base (QObject *parent=0) | |
Base::Base. More... | |
virtual QString | getClassName (void) |
Base::getClassName. More... | |
QTextStream & | stdOutput (void) |
Base::stdOutput. More... | |
Private Slots | |
void | handleReadyRead () |
void | handleTimeout () |
InterfaceSP::handleTimeout A slot for treatment of the signal Time-Out. More... | |
void | handleError (QSerialPort::SerialPortError error) |
Private Attributes | |
QSerialPort * | serialPort |
Serial Port. More... | |
QSerialPortInfo | serialPortInfo |
qint64 | readBufferSize |
qint64 | bytesAvailable |
The number of bytes that are in the buffer for reading. More... | |
Additional Inherited Members | |
Signals inherited from Interface | |
void | infoMessage (const QVariant &message) const |
void | debugMessage (const QVariant &message) const |
void | errorMessage (const QVariant &message) const |
The class InterfaceSP provides methods to access serial ports.
You can get information about the available serial ports using the QSerialPortInfo helper class, which allows an enumeration of all the serial ports in the system. This is useful to obtain the correct name of the serial port you want to use. You can pass an object of the helper class as an argument to the setPort() or setPortName() methods to assign the desired serial device. After setting the port, you can open it in read-only (r/o), write-only (w/o), or read-write (r/w) mode using the open() method.
InterfaceSP::InterfaceSP | ( | QObject * | parent = 0 | ) |
InterfaceSP::InterfaceSP Constructor of the class InterfaceSP for creating objects with default values.
Create a instance of the class and call following init methods:
[in] | parent | Pointer to the parent object used for QObject |
References init().
InterfaceSP::InterfaceSP | ( | QObject * | parent, |
const QString & | portName | ||
) |
InterfaceSP::InterfaceSP Constructor of the class InterfaceSP for creating objects with default values.
Create a instance of the class and call following init methods:
[in] | parent | Pointer to the parent object used for QObject. |
[in] | portName | a Serial Port Name of the type const QString. |
References init(), initSerialPort(), and searchSerialPort().
InterfaceSP::InterfaceSP | ( | QObject * | parent, |
QSerialPort * | port | ||
) |
InterfaceSP::InterfaceSP Constructor of the class InterfaceSP for creating objects with default values.
Create a instance of the class and call following init methods:
[in] | parent | a pointer an the parent object used for QObject. |
[in] | port | a pointer an the Serial Port Name of the type QSerialPort*. |
References handleError(), handleReadyRead(), init(), and serialPort.
InterfaceSP::~InterfaceSP | ( | ) |
Destructor for the class InterfaceSP.
QStringList InterfaceSP::availableSerialPorts | ( | void | ) |
InterfaceSP::availableSerialPorts Return a list with all available serial port names.
Referenced by SerialThread::run().
|
virtual |
QString InterfaceSP::getDescription | ( | void | ) | const |
Returns the description string of the serial port.
References serialPortInfo.
QString InterfaceSP::getManufacturer | ( | void | ) | const |
Returns the manufacturer string of the serial port.
References serialPortInfo.
qint32 InterfaceSP::getPortBaudRate | ( | void | ) | const |
InterfaceSP::getPortBaudRate Returns the baud rate of the serial port.
Warning: Setting the AllDirections flag is supported on all platforms. Windows and Windows CE support only this mode. Warning: Returns equal baud rate in any direction on Windows, Windows CE. The default value is Baud9600, i.e. 9600 bits per second.
References serialPort.
QString InterfaceSP::getPortName | ( | void | ) | const |
Returns the name of the serial port.
References serialPort.
Referenced by Tests::Case16(), and Tests::Case17().
quint16 InterfaceSP::getProductIdentifier | ( | void | ) | const |
InterfaceSP::getProductIdentifier.
Returns the 16-bit product number for the serial port.
References serialPortInfo.
QString InterfaceSP::getSerialNumber | ( | void | ) | const |
Returns the serial number string of the serial port.
References serialPortInfo.
QSerialPort * InterfaceSP::getSerialPort | ( | void | ) |
Returns the Information of the serial port.
References serialPort.
Referenced by Tests::Case15(), Tests::Case16(), and Tests::Case17().
QSerialPortInfo InterfaceSP::getSerialPortInfo | ( | void | ) | const |
InterfaceSP::getSerialPortInfo.
Returns the Information of the serial port.
References serialPortInfo.
|
virtual |
Returns the Information of the serial port.
Implements Interface.
References serialPort.
|
privateslot |
References serialPort, and Base::stdOutput().
Referenced by initSerialPort(), and InterfaceSP().
|
privateslot |
References bytesAvailable, Interface::getReceivedData(), Interface::getTimeout(), Interface::getTimer(), readBufferSize, and serialPort.
Referenced by initSerialPort(), and InterfaceSP().
|
privateslot |
InterfaceSP::handleTimeout A slot for treatment of the signal Time-Out.
The slot terminates the console application or sends another signal to GUI application.
References Interface::errorMessage(), Interface::getTimeout(), serialPort, and Base::stdOutput().
Referenced by init().
void InterfaceSP::init | ( | void | ) |
This method establishes the necessary fields of the class to read the data, and starts a timeout.
References bytesAvailable, Interface::getTimeout(), Interface::getTimer(), handleTimeout(), readBufferSize, Interface::setTimeout(), and Interface::setTimer().
Referenced by InterfaceSP().
void InterfaceSP::initSerialPort | ( | void | ) |
InterfaceSP::initSerialPort Prepare a instance of the Serial Port.
References handleError(), handleReadyRead(), readBufferSize, serialPort, and serialPortInfo.
Referenced by InterfaceSP().
|
virtual |
Implements Interface.
|
virtual |
|
virtual |
InterfaceSP::readTheData Reads all remaining data from the UART device.
Set a time-out for the read the data from a device.
[in] | timewait | of the type quint32. |
[in] | bytes | the number of bytes to read from the UART. |
Implements Interface.
References Interface::getReceivedBytes(), Interface::getReceivedData(), serialPort, and Base::stdOutput().
Referenced by Tests::Case16(), Tests::Case17(), and writeTheData().
void InterfaceSP::searchAllSerialPort | ( | void | ) |
InterfaceSP::searchAllSerialPort Info about all available serial ports.
References Base::stdOutput().
Referenced by SerialThread::run().
bool InterfaceSP::searchSerialPort | ( | const QString & | portName | ) |
InterfaceSP::searchSerialPort This method checks a serial port for existence.
References serialPortInfo.
Referenced by Tests::Case16(), and InterfaceSP().
|
virtual |
InterfaceSP::writeTheData Writes the content of byteArray to the Serial Port device.
Send the data to a UART device.
data | of type const QByteArray. |
Implements Interface.
References Interface::getBlockSize(), Interface::getReceivedData(), Interface::getTimeout(), Interface::getTimer(), readTheData(), serialPort, and Base::stdOutput().
Referenced by Tests::Case16(), and Tests::Case17().
|
private |
The number of bytes that are in the buffer for reading.
Referenced by handleReadyRead(), and init().
|
private |
The size of the internal read buffer. This limits the amount of data that the client can receive before calling the read() or readAll() methods.
Referenced by handleReadyRead(), init(), and initSerialPort().
|
private |
Serial Port.
Referenced by closeSocket(), getPortBaudRate(), getPortName(), getSerialPort(), getSocket(), handleError(), handleReadyRead(), handleTimeout(), initSerialPort(), InterfaceSP(), openSocket(), readTheData(), and writeTheData().
|
private |
It provides information on this serial ports:
Referenced by getDescription(), getManufacturer(), getProductIdentifier(), getSerialNumber(), getSerialPortInfo(), initSerialPort(), and searchSerialPort().