SynchroTime
Public Member Functions | Private Slots | Private Attributes | List of all members
InterfaceSP Class Reference

The class InterfaceSP provides methods to access serial ports. More...

#include <interface.h>

Inheritance diagram for InterfaceSP:
Inheritance graph
Collaboration diagram for InterfaceSP:
Collaboration graph

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
 

Detailed Description

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.

Note
The serial port is always opened with exclusive access (that is, no other process or thread can access an already opened serial port).

Constructor & Destructor Documentation

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:

  1. InterfaceSP::init()
Parameters
[in]parentPointer to the parent object used for QObject

References init().

Here is the call graph for this function:

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:

  1. InterfaceSP::init()
  2. InterfaceSP::searchSerialPort( const QString & portName )
  3. InterfaceSP::initSerialPort()
Parameters
[in]parentPointer to the parent object used for QObject.
[in]portNamea Serial Port Name of the type const QString.

References init(), initSerialPort(), and searchSerialPort().

Here is the call graph for this function:

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:

  1. InterfaceSP::init()
Parameters
[in]parenta pointer an the parent object used for QObject.
[in]porta pointer an the Serial Port Name of the type QSerialPort*.

References handleError(), handleReadyRead(), init(), and serialPort.

Here is the call graph for this function:

InterfaceSP::~InterfaceSP ( )

Destructor for the class InterfaceSP.

Member Function Documentation

QStringList InterfaceSP::availableSerialPorts ( void  )

InterfaceSP::availableSerialPorts Return a list with all available serial port names.

Returns
serialPorts of the type QStringList

Referenced by SerialThread::run().

Here is the caller graph for this function:

void InterfaceSP::closeSocket ( void  )
virtual

InterfaceSP::closeSocket.

Implements Interface.

References serialPort.

QString InterfaceSP::getDescription ( void  ) const

InterfaceSP::getDescription.

Returns the description string of the serial port.

Returns
description of the type QString.

References serialPortInfo.

QString InterfaceSP::getManufacturer ( void  ) const

InterfaceSP::getManufacturer.

Returns the manufacturer string of the serial port.

Returns
manufacturer of the type QString.

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.

Returns
portBaudRate of the type int.
Note
If the setting is set before opening the port, the actual serial port setting is done automatically in the QSerialPort::open() method right after that the opening of the port succeeds.

References serialPort.

QString InterfaceSP::getPortName ( void  ) const

InterfaceSP::getPortName.

Returns the name of the serial port.

Returns
portName of the type QString.

References serialPort.

Referenced by Tests::Case16(), and Tests::Case17().

Here is the caller graph for this function:

quint16 InterfaceSP::getProductIdentifier ( void  ) const

InterfaceSP::getProductIdentifier.

Returns the 16-bit product number for the serial port.

Returns
productIdentifier of the type quint16.

References serialPortInfo.

QString InterfaceSP::getSerialNumber ( void  ) const

InterfaceSP::getSerialNumber.

Returns the serial number string of the serial port.

Returns
serialNumber of the type QString.

References serialPortInfo.

QSerialPort * InterfaceSP::getSerialPort ( void  )

InterfaceSP::getSerialPort.

Returns the Information of the serial port.

Returns
serialPort of the type QSerialPort*.

References serialPort.

Referenced by Tests::Case15(), Tests::Case16(), and Tests::Case17().

Here is the caller graph for this function:

QSerialPortInfo InterfaceSP::getSerialPortInfo ( void  ) const

InterfaceSP::getSerialPortInfo.

Returns the Information of the serial port.

Returns
serialPortInfo of the type QSerialPortInfo.

References serialPortInfo.

QSerialPort * InterfaceSP::getSocket ( void  )
virtual

InterfaceSP::getSocket.

Returns the Information of the serial port.

Returns
serialPort of the type QSerialPort*.

Implements Interface.

References serialPort.

void InterfaceSP::handleError ( QSerialPort::SerialPortError  error)
privateslot
Todo:

References serialPort, and Base::stdOutput().

Referenced by initSerialPort(), and InterfaceSP().

Here is the call graph for this function:

Here is the caller graph for this function:

void InterfaceSP::handleReadyRead ( void  )
privateslot
Todo:

References bytesAvailable, Interface::getReceivedData(), Interface::getTimeout(), Interface::getTimer(), readBufferSize, and serialPort.

Referenced by initSerialPort(), and InterfaceSP().

Here is the call graph for this function:

Here is the caller graph for this function:

void InterfaceSP::handleTimeout ( )
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().

Here is the call graph for this function:

Here is the caller graph for this function:

void InterfaceSP::init ( void  )

InterfaceSP::init.

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().

Here is the call graph for this function:

Here is the caller graph for this function:

void InterfaceSP::initSerialPort ( void  )

InterfaceSP::initSerialPort Prepare a instance of the Serial Port.

References handleError(), handleReadyRead(), readBufferSize, serialPort, and serialPortInfo.

Referenced by InterfaceSP().

Here is the call graph for this function:

Here is the caller graph for this function:

void InterfaceSP::initSocket ( void  )
virtual
bool InterfaceSP::openSocket ( void  )
virtual
bool InterfaceSP::readTheData ( const quint32  timewait,
const quint32  bytes = 0U 
)
virtual

InterfaceSP::readTheData Reads all remaining data from the UART device.

Set a time-out for the read the data from a device.

Parameters
[in]timewaitof the type quint32.
[in]bytesthe 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().

Here is the call graph for this function:

Here is the caller graph for this function:

void InterfaceSP::searchAllSerialPort ( void  )

InterfaceSP::searchAllSerialPort Info about all available serial ports.

References Base::stdOutput().

Referenced by SerialThread::run().

Here is the call graph for this function:

Here is the caller graph for this function:

bool InterfaceSP::searchSerialPort ( const QString &  portName)

InterfaceSP::searchSerialPort This method checks a serial port for existence.

References serialPortInfo.

Referenced by Tests::Case16(), and InterfaceSP().

Here is the caller graph for this function:

qint64 InterfaceSP::writeTheData ( const QByteArray &  data)
virtual

InterfaceSP::writeTheData Writes the content of byteArray to the Serial Port device.

Send the data to a UART device.

Parameters
dataof type const QByteArray.
Returns
bytesWritten of the type qint64.

Implements Interface.

References Interface::getBlockSize(), Interface::getReceivedData(), Interface::getTimeout(), Interface::getTimer(), readTheData(), serialPort, and Base::stdOutput().

Referenced by Tests::Case16(), and Tests::Case17().

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

qint64 InterfaceSP::bytesAvailable
private

The number of bytes that are in the buffer for reading.

Referenced by handleReadyRead(), and init().

qint64 InterfaceSP::readBufferSize
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().

QSerialPort* InterfaceSP::serialPort
private
QSerialPortInfo InterfaceSP::serialPortInfo
private

It provides information on this serial ports:

  • The name of serial port
  • The description string of the serial port
  • The manufacturer string of the serial port
  • The serial number string of the serial port
  • The 16-bit product number for the serial port
  • The 16-bit vendor number for the serial port
  • The list of available standard baud rates supported by the current serial port

Referenced by getDescription(), getManufacturer(), getProductIdentifier(), getSerialNumber(), getSerialPortInfo(), initSerialPort(), and searchSerialPort().


The documentation for this class was generated from the following files: