Home · All Classes · Annotated · Functions

QSerialPort Class Reference

The QSerialPort class provides a simple serial device interface. More...

#include <QSerialPort>

Inherits QSerialIODevice.

Public Functions

Static Public Members

Protected Functions

Additional Inherited Members


Detailed Description

The QSerialPort class provides a simple serial device interface.

This class manages a very simple serial device, which is accessed at a specific baud rate with no parity, 8 data bits, and 1 stop bit. It is intended for communicating with GSM modems and the like.

The recommended way to create an instance of this class is to call the QSerialPort::create() method.

See also QSerialIODevice.


Member Function Documentation

QSerialPort::QSerialPort ( const QString & device, int rate = 38400, bool trackStatus = false )

Construct a new serial device handler object for the specified device at the given rate. After construction, it is necessary to call QSerialPort::open() to complete initialization.

If trackStatus is true, then the device should attempt to track changes in DSR, DCD, and CTS. This may require the use of a regular timeout, which will be detrimental to battery life.

Status tracking should only be enabled when absolutely required. It isn't required for modems that support GSM 07.10 multiplexing, as the multiplexing mechanism has its own method of tracking status changes that does not require the use of a timeout.

The device name is usually something like "/dev/ttyS0", but it can have the special form "sim:hostname", where "hostname" is the name of a host running a phone simulator daemon (usually localhost). The phone simulator mode is intended for debugging purposes only.

QSerialPort::~QSerialPort ()

Destruct this serial device. If the device is currently open, it will be closed.

qint64 QSerialPort::bytesAvailable () const   [virtual]

Return the number of bytes that are currently waiting to be read.

Reimplemented from QIODevice.

bool QSerialPort::carrier () const   [virtual]

Get the current state of the DCD (carrier) modem status line.

Reimplemented from QSerialIODevice.

void QSerialPort::close ()   [virtual]

Close the serial device.

Reimplemented from QIODevice.

QSerialPort * QSerialPort::create ( const QString & name, int defaultRate = 115200, bool flowControl = false )   [static]

Create and open a serial device from a name of the form "device:rate". Returns NULL if the device could not be opened. The defaultRate parameter indicates the default rate to use if ":rate" was not included in the device name. If flowControl is true, then CTS/RTS flow control should be enabled on the device.

bool QSerialPort::cts () const   [virtual]

Get the current state of the CTS modem status line.

Reimplemented from QSerialIODevice.

void QSerialPort::discard ()   [virtual]

Discard pending buffered data without transmitting it. The companion function QIODevice::flush() waits for the buffers to empty. This function will do nothing if the underlying implementation cannot discard buffers.

Reimplemented from QSerialIODevice.

bool QSerialPort::dsr () const   [virtual]

Get the current state of the DSR modem status line.

Reimplemented from QSerialIODevice.

bool QSerialPort::dtr () const   [virtual]

Get the current state of the DTR modem status line.

Reimplemented from QSerialIODevice.

See also setDtr().

bool QSerialPort::flowControl () const

Get the state of CTS/RTS flow control on the serial device. The default value is false.

See also setFlowControl().

bool QSerialPort::flush ()

Flush all buffered data to the physical serial device.

bool QSerialPort::isValid () const   [virtual]

Determine if this device is valid.

Reimplemented from QSerialIODevice.

bool QSerialPort::open ( OpenMode mode )   [virtual]

Open the serial device with the specified mode.

Reimplemented from QIODevice.

int QSerialPort::rate () const   [virtual]

Get the serial device's baud rate.

Reimplemented from QSerialIODevice.

qint64 QSerialPort::readData ( char * data, qint64 maxlen )   [virtual protected]

Read bytes from the serial port into the buffer data. Up to maxlen bytes of data will be read.

Reimplemented from QIODevice.

bool QSerialPort::rts () const   [virtual]

Get the current state of the RTS modem status line.

Reimplemented from QSerialIODevice.

See also setRts().

void QSerialPort::setDtr ( bool value )   [virtual]

Set the state of the DTR modem status line to value.

Reimplemented from QSerialIODevice.

See also dtr().

void QSerialPort::setFlowControl ( bool value )

Set the state of CTS/RTS flow control on the serial device to value. This must be called before QSerialPort::open(). Changes to the value after opening will be ignored.

See also flowControl().

void QSerialPort::setRts ( bool value )   [virtual]

Set the state of the RTS modem status line to value.

Reimplemented from QSerialIODevice.

See also rts().

bool QSerialPort::waitForReadyRead ( int msecs )   [virtual]

Wait up to msecs milliseconds for the serial device to have data ready to read.

Reimplemented from QIODevice.

qint64 QSerialPort::writeData ( const char * data, qint64 len )   [virtual protected]

Write len bytes from the buffer data to the serial port.

Reimplemented from QIODevice.


Copyright © 2006 Trolltech Trademarks
Qtopia 4.1.7