Posix_QextSerialPort Class Reference

#include <posix_qextserialport.h>

Inheritance diagram for Posix_QextSerialPort:

QextSerialBase QIODevice QextBaseType QextSerialPort List of all members.

Public Member Functions

 aboutToClose ()
 atEnd ()
virtual bool atEnd () const
virtual BaudRateType baudRate () const
virtual qint64 bytesAvailable ()
 bytesToWrite ()
 bytesWritten (qint64 bytes)
 canReadLine ()
virtual void close ()
virtual void construct ()
virtual DataBitsType dataBits () const
 errorString ()
virtual FlowType flowControl () const
virtual void flush ()
 getChar (char *c)
 isOpen ()
 isReadable ()
 isSequential ()
virtual bool isSequential () const
 isTextModeEnabled ()
 isWritable ()
virtual ulong lastError () const
virtual ulong lineStatus ()
virtual bool open (OpenMode mode=0)
 openMode ()
Posix_QextSerialPortoperator= (const Posix_QextSerialPort &s)
virtual ParityType parity () const
 peek (qint64 maxSize)
 peek (char *data, qint64 maxSize)
virtual QString portName () const
 pos ()
 Posix_QextSerialPort (const QString &name, const PortSettings &settings)
 Posix_QextSerialPort (const PortSettings &settings)
 Posix_QextSerialPort (const QString &name)
 Posix_QextSerialPort (const Posix_QextSerialPort &s)
 Posix_QextSerialPort ()
 putChar (char c)
 read (qint64 maxSize)
 read (char *data, qint64 maxSize)
 readAll ()
 readLine (qint64 maxSize=0)
virtual qint64 readLine (char *data, qint64 maxSize)
 readLineData (char *data, qint64 maxSize)
 readyRead ()
 reset ()
 seek (qint64 pos)
virtual void setBaudRate (BaudRateType)
virtual void setDataBits (DataBitsType)
virtual void setDtr (bool set=true)
 setErrorString (const QString &str)
virtual void setFlowControl (FlowType)
 setOpenMode (OpenMode openMode)
virtual void setParity (ParityType)
virtual void setPortName (const QString &name)
virtual void setRts (bool set=true)
virtual void setStopBits (StopBitsType)
 setTextModeEnabled (bool enabled)
virtual void setTimeout (ulong, ulong)
 size ()
virtual qint64 size () const
virtual StopBitsType stopBits () const
virtual void translateError (ulong error)
virtual void ungetChar (char c)
 waitForBytesWritten (int msecs)
 waitForReadyRead (int msecs)
 write (const QByteArray &byteArray)
 write (const char *data, qint64 maxSize)
virtual ~Posix_QextSerialPort ()

Protected Member Functions

virtual qint64 readData (char *data, qint64 maxSize)
virtual qint64 writeData (const char *data, qint64 maxSize)

Protected Attributes

ulong lastErr
QString port
termios Posix_CommConfig
timeval Posix_Copy_Timeout
QFile * Posix_File
timeval Posix_Timeout
PortSettings Settings

Static Protected Attributes

static QMutex * mutex = NULL
static ulong refCount = 0

Detailed Description

Version:
1.0.0
Author:
Stefan Sander
A cross-platform serial port class. This class encapsulates the POSIX portion of QextSerialPort. The user will be notified of errors and possible portability conflicts at run-time by default - this behavior can be turned off by defining _TTY_NOWARN_ (to turn off all warnings) or _TTY_NOWARN_PORT_ (to turn off portability warnings) in the project. Note that _TTY_NOWARN_ will also turn off portability warnings.


Constructor & Destructor Documentation

Posix_QextSerialPort::Posix_QextSerialPort (  ) 

Default constructor. Note that the name of the device used by a QextSerialPort constructed with this constructor will be determined by defined constants, or lack thereof - the default behavior is the same as _TTY_LINUX_. Possible naming conventions and their associated constants are:

Constant         Used By         Naming Convention
----------       -------------   ------------------------
_TTY_WIN_        Windows         COM1, COM2
_TTY_IRIX_       SGI/IRIX        /dev/ttyf1, /dev/ttyf2
_TTY_HPUX_       HP-UX           /dev/tty1p0, /dev/tty2p0
_TTY_SUN_        SunOS/Solaris   /dev/ttya, /dev/ttyb
_TTY_DIGITAL_    Digital UNIX    /dev/tty01, /dev/tty02
_TTY_FREEBSD_    FreeBSD         /dev/ttyd0, /dev/ttyd1
_TTY_LINUX_      Linux           /dev/ttyS0, /dev/ttyS1
<none>           Linux           /dev/ttyS0, /dev/ttyS1

This constructor assigns the device name to the name of the first port on the specified system. See the other constructors if you need to open a different port.

00041 : QextSerialBase()
00042 {
00043     Posix_File=new QFile();
00044 }

Posix_QextSerialPort::Posix_QextSerialPort ( const Posix_QextSerialPort s  ) 

Copy constructor.

00051  : QextSerialBase(s.port)
00052 {
00053     setOpenMode(s.openMode());
00054     port = s.port;
00055     Settings.BaudRate=s.Settings.BaudRate;
00056     Settings.DataBits=s.Settings.DataBits;
00057     Settings.Parity=s.Settings.Parity;
00058     Settings.StopBits=s.Settings.StopBits;
00059     Settings.FlowControl=s.Settings.FlowControl;
00060     lastErr=s.lastErr;
00061 
00062     Posix_File=new QFile();
00063     Posix_File=s.Posix_File;
00064     memcpy(&Posix_Timeout, &s.Posix_Timeout, sizeof(struct timeval));
00065     memcpy(&Posix_Copy_Timeout, &s.Posix_Copy_Timeout, sizeof(struct timeval));
00066     memcpy(&Posix_CommConfig, &s.Posix_CommConfig, sizeof(struct termios));
00067 }

Posix_QextSerialPort::Posix_QextSerialPort ( const QString &  name  ) 

Constructs a serial port attached to the port specified by name. name is the name of the device, which is windowsystem-specific, e.g."COM1" or "/dev/ttyS0".

00076  : QextSerialBase(name)
00077 {
00078     Posix_File=new QFile();
00079 }

Posix_QextSerialPort::Posix_QextSerialPort ( const PortSettings settings  ) 

Constructs a port with default name and specified settings.

00086  : QextSerialBase()
00087 {
00088     setBaudRate(settings.BaudRate);
00089     setDataBits(settings.DataBits);
00090     setParity(settings.Parity);
00091     setStopBits(settings.StopBits);
00092     setFlowControl(settings.FlowControl);
00093 
00094     Posix_File=new QFile();
00095     setTimeout(settings.Timeout_Sec, settings.Timeout_Millisec);
00096 }

Posix_QextSerialPort::Posix_QextSerialPort ( const QString &  name,
const PortSettings settings 
)

Constructs a port with specified name and settings.

00103  : QextSerialBase(name)
00104 {
00105     setBaudRate(settings.BaudRate);
00106     setDataBits(settings.DataBits);
00107     setParity(settings.Parity);
00108     setStopBits(settings.StopBits);
00109     setFlowControl(settings.FlowControl);
00110 
00111     Posix_File=new QFile();
00112     setTimeout(settings.Timeout_Sec, settings.Timeout_Millisec);
00113 }

Posix_QextSerialPort::~Posix_QextSerialPort (  )  [virtual]

Standard destructor.

00142 {
00143     if (isOpen()) {
00144         close();
00145     }
00146     Posix_File->close();
00147     delete Posix_File;
00148 }


Member Function Documentation

bool QextSerialBase::atEnd (  )  const [virtual, inherited]

This function will return true if the input buffer is empty (or on error), and false otherwise. Call QextSerialBase::lastError() for error information.

00187 {
00188     if (size()) {
00189         return true;
00190     }
00191     return false;
00192 }

BaudRateType QextSerialBase::baudRate ( void   )  const [virtual, inherited]

Returns the baud rate of the serial port. For a list of possible return values see the definition of the enum BaudRateType.

00126 {
00127     return Settings.BaudRate;
00128 }

qint64 Posix_QextSerialPort::bytesAvailable (  )  [virtual]

Returns the number of bytes waiting in the port's receive queue. This function will return 0 if the port is not currently open, or -1 on error. Error information can be retrieved by calling Posix_QextSerialPort::getLastError().

Implements QextSerialBase.

00909 {
00910     LOCK_MUTEX();
00911     if (isOpen()) {
00912         int bytesQueued;
00913         fd_set fileSet;
00914         FD_ZERO(&fileSet);
00915         FD_SET(Posix_File->handle(), &fileSet);
00916 
00917         /*on Linux systems the Posix_Timeout structure will be altered by the select() call.
00918           Make sure we use the right timeout values*/
00919         //memcpy(&Posix_Timeout, &Posix_Copy_Timeout, sizeof(struct timeval));
00920         Posix_Timeout = Posix_Copy_Timeout;
00921         int n=select(Posix_File->handle()+1, &fileSet, NULL, &fileSet, &Posix_Timeout);
00922         if (!n) {
00923             lastErr=E_PORT_TIMEOUT;
00924             UNLOCK_MUTEX();
00925             return -1;
00926         }
00927         if (n==-1 || ioctl(Posix_File->handle(), FIONREAD, &bytesQueued)==-1) {
00928             translateError(errno);
00929             UNLOCK_MUTEX();
00930             return -1;
00931         }
00932         lastErr=E_NO_ERROR;
00933         UNLOCK_MUTEX();
00934         return bytesQueued + QIODevice::bytesAvailable();
00935     }
00936     UNLOCK_MUTEX();
00937     return 0;
00938 }

void Posix_QextSerialPort::close (  )  [virtual]

Closes a serial port. This function has no effect if the serial port associated with the class is not currently open.

Implements QextSerialBase.

00865 {
00866     LOCK_MUTEX();
00867     Posix_File->close();
00868     QIODevice::close();
00869     UNLOCK_MUTEX();
00870 }

void QextSerialBase::construct (  )  [virtual, inherited]

Common constructor function for setting up default port settings. (115200 Baud, 8N1, Hardware flow control where supported, otherwise no flow control, and 500 ms timeout).

00083 {
00084     Settings.BaudRate=BAUD115200;
00085     Settings.DataBits=DATA_8;
00086     Settings.Parity=PAR_NONE;
00087     Settings.StopBits=STOP_1;
00088     Settings.FlowControl=FLOW_HARDWARE;
00089     Settings.Timeout_Sec=0;
00090     Settings.Timeout_Millisec=500;
00091 
00092 #ifdef QT_THREAD_SUPPORT
00093     if (!mutex) {
00094         mutex=new QMutex( QMutex::Recursive );
00095     }
00096     refCount++;
00097 #endif
00098 
00099     setOpenMode(QIODevice::NotOpen);
00100 }

DataBitsType QextSerialBase::dataBits (  )  const [virtual, inherited]

Returns the number of data bits used by the port. For a list of possible values returned by this function, see the definition of the enum DataBitsType.

00136 {
00137     return Settings.DataBits;
00138 }

FlowType QextSerialBase::flowControl (  )  const [virtual, inherited]

Returns the type of flow control used by the port. For a list of possible values returned by this function, see the definition of the enum FlowType.

00166 {
00167     return Settings.FlowControl;
00168 }

void Posix_QextSerialPort::flush (  )  [virtual]

Flushes all pending I/O to the serial port. This function has no effect if the serial port associated with the class is not currently open.

Implements QextSerialBase.

00878 {
00879     LOCK_MUTEX();
00880     if (isOpen()) {
00881         Posix_File->flush();
00882     }
00883     UNLOCK_MUTEX();
00884 }

bool QextSerialBase::isSequential (  )  const [virtual, inherited]

Returns true if device is sequential, otherwise returns false. Serial port is sequential device so this function always returns true. Check QIODevice::isSequential() documentation for more information.

00177 {
00178     return true;
00179 }

ulong QextSerialBase::lastError (  )  const [virtual, inherited]

Returns the code for the last error encountered by the port, or E_NO_ERROR if the last port operation was successful. Possible error codes are:

Error                           Explanation
---------------------------     -------------------------------------------------------------
E_NO_ERROR                      No Error has occured
E_INVALID_FD                    Invalid file descriptor (port was not opened correctly)
E_NO_MEMORY                     Unable to allocate memory tables (POSIX)
E_CAUGHT_NON_BLOCKED_SIGNAL     Caught a non-blocked signal (POSIX)
E_PORT_TIMEOUT                  Operation timed out (POSIX)
E_INVALID_DEVICE                The file opened by the port is not a character device (POSIX)
E_BREAK_CONDITION               The port detected a break condition
E_FRAMING_ERROR                 The port detected a framing error
                                (usually caused by incorrect baud rate settings)
E_IO_ERROR                      There was an I/O error while communicating with the port
E_BUFFER_OVERRUN                Character buffer overrun
E_RECEIVE_OVERFLOW              Receive buffer overflow
E_RECEIVE_PARITY_ERROR          The port detected a parity error in the received data
E_TRANSMIT_OVERFLOW             Transmit buffer overflow
E_READ_FAILED                   General read operation failure
E_WRITE_FAILED                  General write operation failure
00248 {
00249     return lastErr;
00250 }

unsigned long Posix_QextSerialPort::lineStatus ( void   )  [virtual]

returns the line status as stored by the port function. This function will retrieve the states of the following lines: DCD, CTS, DSR, and RI. On POSIX systems, the following additional lines can be monitored: DTR, RTS, Secondary TXD, and Secondary RXD. The value returned is an unsigned long with specific bits indicating which lines are high. The following constants should be used to examine the states of individual lines:

Mask        Line
------      ----
LS_CTS      CTS
LS_DSR      DSR
LS_DCD      DCD
LS_RI       RI
LS_RTS      RTS (POSIX only)
LS_DTR      DTR (POSIX only)
LS_ST       Secondary TXD (POSIX only)
LS_SR       Secondary RXD (POSIX only)

This function will return 0 if the port associated with the class is not currently open.

Implements QextSerialBase.

01042 {
01043     unsigned long Status=0, Temp=0;
01044     LOCK_MUTEX();
01045     if (isOpen()) {
01046         ioctl(Posix_File->handle(), TIOCMGET, &Temp);
01047         if (Temp&TIOCM_CTS) {
01048             Status|=LS_CTS;
01049         }
01050         if (Temp&TIOCM_DSR) {
01051             Status|=LS_DSR;
01052         }
01053         if (Temp&TIOCM_RI) {
01054             Status|=LS_RI;
01055         }
01056         if (Temp&TIOCM_CD) {
01057             Status|=LS_DCD;
01058         }
01059         if (Temp&TIOCM_DTR) {
01060             Status|=LS_DTR;
01061         }
01062         if (Temp&TIOCM_RTS) {
01063             Status|=LS_RTS;
01064         }
01065         if (Temp&TIOCM_ST) {
01066             Status|=LS_ST;
01067         }
01068         if (Temp&TIOCM_SR) {
01069             Status|=LS_SR;
01070         }
01071     }
01072     UNLOCK_MUTEX();
01073     return Status;
01074 }

bool Posix_QextSerialPort::open ( OpenMode  mode = 0  )  [virtual]

Opens the serial port associated to this class. This function has no effect if the port associated with the class is already open. The port is also configured to the current settings, as stored in the Settings structure.

Implements QextSerialBase.

00817 {
00818     LOCK_MUTEX();
00819     if (mode == QIODevice::NotOpen)
00820         return isOpen();
00821     if (!isOpen()) {
00822         /*open the port*/
00823         Posix_File->setFileName(port);
00824         qDebug("Trying to open File");
00825         if (Posix_File->open(QIODevice::ReadWrite|QIODevice::Unbuffered)) {
00826             qDebug("Opened File succesfully");
00827             /*set open mode*/
00828             QIODevice::open(mode);
00829 
00830             /*configure port settings*/
00831             tcgetattr(Posix_File->handle(), &Posix_CommConfig);
00832 
00833             /*set up other port settings*/
00834             Posix_CommConfig.c_cflag|=CREAD|CLOCAL;
00835             Posix_CommConfig.c_lflag&=(~(ICANON|ECHO|ECHOE|ECHOK|ECHONL|ISIG));
00836             Posix_CommConfig.c_iflag&=(~(INPCK|IGNPAR|PARMRK|ISTRIP|ICRNL|IXANY));
00837             Posix_CommConfig.c_oflag&=(~OPOST);
00838             Posix_CommConfig.c_cc[VMIN]=0;
00839             Posix_CommConfig.c_cc[VINTR] = _POSIX_VDISABLE;
00840             Posix_CommConfig.c_cc[VQUIT] = _POSIX_VDISABLE;
00841             Posix_CommConfig.c_cc[VSTART] = _POSIX_VDISABLE;
00842             Posix_CommConfig.c_cc[VSTOP] = _POSIX_VDISABLE;
00843             Posix_CommConfig.c_cc[VSUSP] = _POSIX_VDISABLE;
00844             setBaudRate(Settings.BaudRate);
00845             setDataBits(Settings.DataBits);
00846             setParity(Settings.Parity);
00847             setStopBits(Settings.StopBits);
00848             setFlowControl(Settings.FlowControl);
00849             setTimeout(Settings.Timeout_Sec, Settings.Timeout_Millisec);
00850             tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig);
00851         } else {
00852             qDebug("Could not open File! Error code : %d", Posix_File->error());
00853         }
00854     }
00855     UNLOCK_MUTEX();
00856     return isOpen();
00857 }

Posix_QextSerialPort & Posix_QextSerialPort::operator= ( const Posix_QextSerialPort s  ) 

Override the = operator.

00120 {
00121     setOpenMode(s.openMode());
00122     port = s.port;
00123     Settings.BaudRate=s.Settings.BaudRate;
00124     Settings.DataBits=s.Settings.DataBits;
00125     Settings.Parity=s.Settings.Parity;
00126     Settings.StopBits=s.Settings.StopBits;
00127     Settings.FlowControl=s.Settings.FlowControl;
00128     lastErr=s.lastErr;
00129 
00130     Posix_File=s.Posix_File;
00131     memcpy(&Posix_Timeout, &(s.Posix_Timeout), sizeof(struct timeval));
00132     memcpy(&Posix_Copy_Timeout, &(s.Posix_Copy_Timeout), sizeof(struct timeval));
00133     memcpy(&Posix_CommConfig, &(s.Posix_CommConfig), sizeof(struct termios));
00134     return *this;
00135 }

ParityType QextSerialBase::parity (  )  const [virtual, inherited]

Returns the type of parity used by the port. For a list of possible values returned by this function, see the definition of the enum ParityType.

00146 {
00147     return Settings.Parity;
00148 }

QString QextSerialBase::portName (  )  const [virtual, inherited]

Returns the name set by setPortName().

00116 {
00117     return port;
00118 }

qint64 Posix_QextSerialPort::readData ( char *  data,
qint64  maxSize 
) [protected, virtual]

Reads a block of data from the serial port. This function will read at most maxSize bytes from the serial port and place them in the buffer pointed to by data. Return value is the number of bytes actually read, or -1 on error.

Warning:
before calling this function ensure that serial port associated with this class is currently open (use isOpen() function to check if port is open).

Implements QextSerialBase.

01086 {
01087     LOCK_MUTEX();
01088     int retVal=0;
01089     retVal=Posix_File->read(data, maxSize);
01090     if (retVal==-1)
01091         lastErr=E_READ_FAILED;
01092     UNLOCK_MUTEX();
01093 
01094     return retVal;
01095 }

qint64 QextSerialBase::readLine ( char *  data,
qint64  maxSize 
) [virtual, inherited]

This function will read a line of buffered input from the port, stopping when either maxSize bytes have been read, the port has no more data available, or a newline is encountered. The value returned is the length of the string that was read.

Reimplemented from QIODevice.

00201 {
00202     qint64 numBytes = bytesAvailable();
00203     char* pData = data;
00204 
00205     if (maxSize < 2)    //maxSize must be larger than 1
00206         return -1;
00207 
00208     /*read a byte at a time for MIN(bytesAvail, maxSize - 1) iterations, or until a newline*/
00209     while (pData<(data+numBytes) && --maxSize) {
00210         readData(pData, 1);
00211         if (*pData++ == '\n') {
00212             break;
00213         }
00214     }
00215     *pData='\0';
00216 
00217     /*return size of data read*/
00218     return (pData-data);
00219 }

void Posix_QextSerialPort::setBaudRate ( BaudRateType  baudRate  )  [virtual]

Sets the baud rate of the serial port. Note that not all rates are applicable on all platforms. The following table shows translations of the various baud rate constants on Windows(including NT/2000) and POSIX platforms. Speeds marked with an * are speeds that are usable on both Windows and POSIX.

Note:
BAUD76800 may not be supported on all POSIX systems. SGI/IRIX systems do not support BAUD1800.
  RATE          Windows Speed   POSIX Speed
  -----------   -------------   -----------
   BAUD50                 110          50
   BAUD75                 110          75
  *BAUD110                110         110
   BAUD134                110         134.5
   BAUD150                110         150
   BAUD200                110         200
  *BAUD300                300         300
  *BAUD600                600         600
  *BAUD1200              1200        1200
   BAUD1800              1200        1800
  *BAUD2400              2400        2400
  *BAUD4800              4800        4800
  *BAUD9600              9600        9600
   BAUD14400            14400        9600
  *BAUD19200            19200       19200
  *BAUD38400            38400       38400
   BAUD56000            56000       38400
  *BAUD57600            57600       57600
   BAUD76800            57600       76800
  *BAUD115200          115200      115200
   BAUD128000          128000      115200
   BAUD256000          256000      115200

Implements QextSerialBase.

00190 {
00191     LOCK_MUTEX();
00192     if (Settings.BaudRate!=baudRate) {
00193         switch (baudRate) {
00194             case BAUD14400:
00195                 Settings.BaudRate=BAUD9600;
00196                 break;
00197 
00198             case BAUD56000:
00199                 Settings.BaudRate=BAUD38400;
00200                 break;
00201 
00202             case BAUD76800:
00203 
00204 #ifndef B76800
00205                 Settings.BaudRate=BAUD57600;
00206 #else
00207                 Settings.BaudRate=baudRate;
00208 #endif
00209                 break;
00210 
00211             case BAUD128000:
00212             case BAUD256000:
00213                 Settings.BaudRate=BAUD115200;
00214                 break;
00215 
00216             default:
00217                 Settings.BaudRate=baudRate;
00218                 break;
00219         }
00220     }
00221     if (isOpen()) {
00222         switch (baudRate) {
00223 
00224             /*50 baud*/
00225             case BAUD50:
00226                 TTY_PORTABILITY_WARNING("Posix_QextSerialPort Portability Warning: Windows does not support 50 baud operation.");
00227 #ifdef CBAUD
00228                 Posix_CommConfig.c_cflag&=(~CBAUD);
00229                 Posix_CommConfig.c_cflag|=B50;
00230 #else
00231                 cfsetispeed(&Posix_CommConfig, B50);
00232                 cfsetospeed(&Posix_CommConfig, B50);
00233 #endif
00234                 break;
00235 
00236             /*75 baud*/
00237             case BAUD75:
00238                 TTY_PORTABILITY_WARNING("Posix_QextSerialPort Portability Warning: Windows does not support 75 baud operation.");
00239 #ifdef CBAUD
00240                 Posix_CommConfig.c_cflag&=(~CBAUD);
00241                 Posix_CommConfig.c_cflag|=B75;
00242 #else
00243                 cfsetispeed(&Posix_CommConfig, B75);
00244                 cfsetospeed(&Posix_CommConfig, B75);
00245 #endif
00246                 break;
00247 
00248             /*110 baud*/
00249             case BAUD110:
00250 #ifdef CBAUD
00251                 Posix_CommConfig.c_cflag&=(~CBAUD);
00252                 Posix_CommConfig.c_cflag|=B110;
00253 #else
00254                 cfsetispeed(&Posix_CommConfig, B110);
00255                 cfsetospeed(&Posix_CommConfig, B110);
00256 #endif
00257                 break;
00258 
00259             /*134.5 baud*/
00260             case BAUD134:
00261                 TTY_PORTABILITY_WARNING("Posix_QextSerialPort Portability Warning: Windows does not support 134.5 baud operation.");
00262 #ifdef CBAUD
00263                 Posix_CommConfig.c_cflag&=(~CBAUD);
00264                 Posix_CommConfig.c_cflag|=B134;
00265 #else
00266                 cfsetispeed(&Posix_CommConfig, B134);
00267                 cfsetospeed(&Posix_CommConfig, B134);
00268 #endif
00269                 break;
00270 
00271             /*150 baud*/
00272             case BAUD150:
00273                 TTY_PORTABILITY_WARNING("Posix_QextSerialPort Portability Warning: Windows does not support 150 baud operation.");
00274 #ifdef CBAUD
00275                 Posix_CommConfig.c_cflag&=(~CBAUD);
00276                 Posix_CommConfig.c_cflag|=B150;
00277 #else
00278                 cfsetispeed(&Posix_CommConfig, B150);
00279                 cfsetospeed(&Posix_CommConfig, B150);
00280 #endif
00281                 break;
00282 
00283             /*200 baud*/
00284             case BAUD200:
00285                 TTY_PORTABILITY_WARNING("Posix_QextSerialPort Portability Warning: Windows does not support 200 baud operation.");
00286 #ifdef CBAUD
00287                 Posix_CommConfig.c_cflag&=(~CBAUD);
00288                 Posix_CommConfig.c_cflag|=B200;
00289 #else
00290                 cfsetispeed(&Posix_CommConfig, B200);
00291                 cfsetospeed(&Posix_CommConfig, B200);
00292 #endif
00293                 break;
00294 
00295             /*300 baud*/
00296             case BAUD300:
00297 #ifdef CBAUD
00298                 Posix_CommConfig.c_cflag&=(~CBAUD);
00299                 Posix_CommConfig.c_cflag|=B300;
00300 #else
00301                 cfsetispeed(&Posix_CommConfig, B300);
00302                 cfsetospeed(&Posix_CommConfig, B300);
00303 #endif
00304                 break;
00305 
00306             /*600 baud*/
00307             case BAUD600:
00308 #ifdef CBAUD
00309                 Posix_CommConfig.c_cflag&=(~CBAUD);
00310                 Posix_CommConfig.c_cflag|=B600;
00311 #else
00312                 cfsetispeed(&Posix_CommConfig, B600);
00313                 cfsetospeed(&Posix_CommConfig, B600);
00314 #endif
00315                 break;
00316 
00317             /*1200 baud*/
00318             case BAUD1200:
00319 #ifdef CBAUD
00320                 Posix_CommConfig.c_cflag&=(~CBAUD);
00321                 Posix_CommConfig.c_cflag|=B1200;
00322 #else
00323                 cfsetispeed(&Posix_CommConfig, B1200);
00324                 cfsetospeed(&Posix_CommConfig, B1200);
00325 #endif
00326                 break;
00327 
00328             /*1800 baud*/
00329             case BAUD1800:
00330                 TTY_PORTABILITY_WARNING("Posix_QextSerialPort Portability Warning: Windows and IRIX do not support 1800 baud operation.");
00331 #ifdef CBAUD
00332                 Posix_CommConfig.c_cflag&=(~CBAUD);
00333                 Posix_CommConfig.c_cflag|=B1800;
00334 #else
00335                 cfsetispeed(&Posix_CommConfig, B1800);
00336                 cfsetospeed(&Posix_CommConfig, B1800);
00337 #endif
00338                 break;
00339 
00340             /*2400 baud*/
00341             case BAUD2400:
00342 #ifdef CBAUD
00343                 Posix_CommConfig.c_cflag&=(~CBAUD);
00344                 Posix_CommConfig.c_cflag|=B2400;
00345 #else
00346                 cfsetispeed(&Posix_CommConfig, B2400);
00347                 cfsetospeed(&Posix_CommConfig, B2400);
00348 #endif
00349                 break;
00350 
00351             /*4800 baud*/
00352             case BAUD4800:
00353 #ifdef CBAUD
00354                 Posix_CommConfig.c_cflag&=(~CBAUD);
00355                 Posix_CommConfig.c_cflag|=B4800;
00356 #else
00357                 cfsetispeed(&Posix_CommConfig, B4800);
00358                 cfsetospeed(&Posix_CommConfig, B4800);
00359 #endif
00360                 break;
00361 
00362             /*9600 baud*/
00363             case BAUD9600:
00364 #ifdef CBAUD
00365                 Posix_CommConfig.c_cflag&=(~CBAUD);
00366                 Posix_CommConfig.c_cflag|=B9600;
00367 #else
00368                 cfsetispeed(&Posix_CommConfig, B9600);
00369                 cfsetospeed(&Posix_CommConfig, B9600);
00370 #endif
00371                 break;
00372 
00373             /*14400 baud*/
00374             case BAUD14400:
00375                 TTY_WARNING("Posix_QextSerialPort: POSIX does not support 14400 baud operation.  Switching to 9600 baud.");
00376 #ifdef CBAUD
00377                 Posix_CommConfig.c_cflag&=(~CBAUD);
00378                 Posix_CommConfig.c_cflag|=B9600;
00379 #else
00380                 cfsetispeed(&Posix_CommConfig, B9600);
00381                 cfsetospeed(&Posix_CommConfig, B9600);
00382 #endif
00383                 break;
00384 
00385             /*19200 baud*/
00386             case BAUD19200:
00387 #ifdef CBAUD
00388                 Posix_CommConfig.c_cflag&=(~CBAUD);
00389                 Posix_CommConfig.c_cflag|=B19200;
00390 #else
00391                 cfsetispeed(&Posix_CommConfig, B19200);
00392                 cfsetospeed(&Posix_CommConfig, B19200);
00393 #endif
00394                 break;
00395 
00396             /*38400 baud*/
00397             case BAUD38400:
00398 #ifdef CBAUD
00399                 Posix_CommConfig.c_cflag&=(~CBAUD);
00400                 Posix_CommConfig.c_cflag|=B38400;
00401 #else
00402                 cfsetispeed(&Posix_CommConfig, B38400);
00403                 cfsetospeed(&Posix_CommConfig, B38400);
00404 #endif
00405                 break;
00406 
00407             /*56000 baud*/
00408             case BAUD56000:
00409                 TTY_WARNING("Posix_QextSerialPort: POSIX does not support 56000 baud operation.  Switching to 38400 baud.");
00410 #ifdef CBAUD
00411                 Posix_CommConfig.c_cflag&=(~CBAUD);
00412                 Posix_CommConfig.c_cflag|=B38400;
00413 #else
00414                 cfsetispeed(&Posix_CommConfig, B38400);
00415                 cfsetospeed(&Posix_CommConfig, B38400);
00416 #endif
00417                 break;
00418 
00419             /*57600 baud*/
00420             case BAUD57600:
00421 #ifdef CBAUD
00422                 Posix_CommConfig.c_cflag&=(~CBAUD);
00423                 Posix_CommConfig.c_cflag|=B57600;
00424 #else
00425                 cfsetispeed(&Posix_CommConfig, B57600);
00426                 cfsetospeed(&Posix_CommConfig, B57600);
00427 #endif
00428                 break;
00429 
00430             /*76800 baud*/
00431             case BAUD76800:
00432                 TTY_PORTABILITY_WARNING("Posix_QextSerialPort Portability Warning: Windows and some POSIX systems do not support 76800 baud operation.");
00433 #ifdef CBAUD
00434                 Posix_CommConfig.c_cflag&=(~CBAUD);
00435 
00436 #ifdef B76800
00437                 Posix_CommConfig.c_cflag|=B76800;
00438 #else
00439                 TTY_WARNING("Posix_QextSerialPort: Posix_QextSerialPort was compiled without 76800 baud support.  Switching to 57600 baud.");
00440                 Posix_CommConfig.c_cflag|=B57600;
00441 #endif //B76800
00442 #else  //CBAUD
00443 #ifdef B76800
00444                 cfsetispeed(&Posix_CommConfig, B76800);
00445                 cfsetospeed(&Posix_CommConfig, B76800);
00446 #else
00447                 TTY_WARNING("Posix_QextSerialPort: Posix_QextSerialPort was compiled without 76800 baud support.  Switching to 57600 baud.");
00448                 cfsetispeed(&Posix_CommConfig, B57600);
00449                 cfsetospeed(&Posix_CommConfig, B57600);
00450 #endif //B76800
00451 #endif //CBAUD
00452                 break;
00453 
00454             /*115200 baud*/
00455             case BAUD115200:
00456 #ifdef CBAUD
00457                 Posix_CommConfig.c_cflag&=(~CBAUD);
00458                 Posix_CommConfig.c_cflag|=B115200;
00459 #else
00460                 cfsetispeed(&Posix_CommConfig, B115200);
00461                 cfsetospeed(&Posix_CommConfig, B115200);
00462 #endif
00463                 break;
00464 
00465             /*128000 baud*/
00466             case BAUD128000:
00467                 TTY_WARNING("Posix_QextSerialPort: POSIX does not support 128000 baud operation.  Switching to 115200 baud.");
00468 #ifdef CBAUD
00469                 Posix_CommConfig.c_cflag&=(~CBAUD);
00470                 Posix_CommConfig.c_cflag|=B115200;
00471 #else
00472                 cfsetispeed(&Posix_CommConfig, B115200);
00473                 cfsetospeed(&Posix_CommConfig, B115200);
00474 #endif
00475                 break;
00476 
00477             /*256000 baud*/
00478             case BAUD256000:
00479                 TTY_WARNING("Posix_QextSerialPort: POSIX does not support 256000 baud operation.  Switching to 115200 baud.");
00480 #ifdef CBAUD
00481                 Posix_CommConfig.c_cflag&=(~CBAUD);
00482                 Posix_CommConfig.c_cflag|=B115200;
00483 #else
00484                 cfsetispeed(&Posix_CommConfig, B115200);
00485                 cfsetospeed(&Posix_CommConfig, B115200);
00486 #endif
00487                 break;
00488         }
00489         tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig);
00490     }
00491     UNLOCK_MUTEX();
00492 }

void Posix_QextSerialPort::setDataBits ( DataBitsType  dataBits  )  [virtual]

Sets the number of data bits used by the serial port. Possible values of dataBits are:

    DATA_5      5 data bits
    DATA_6      6 data bits
    DATA_7      7 data bits
    DATA_8      8 data bits

Note:
This function is subject to the following restrictions:
5 data bits cannot be used with 2 stop bits.
8 data bits cannot be used with space parity on POSIX systems.

Implements QextSerialBase.

00513 {
00514     LOCK_MUTEX();
00515     if (Settings.DataBits!=dataBits) {
00516         if ((Settings.StopBits==STOP_2 && dataBits==DATA_5) ||
00517             (Settings.StopBits==STOP_1_5 && dataBits!=DATA_5) ||
00518             (Settings.Parity==PAR_SPACE && dataBits==DATA_8)) {
00519         }
00520         else {
00521             Settings.DataBits=dataBits;
00522         }
00523     }
00524     if (isOpen()) {
00525         switch(dataBits) {
00526 
00527             /*5 data bits*/
00528             case DATA_5:
00529                 if (Settings.StopBits==STOP_2) {
00530                     TTY_WARNING("Posix_QextSerialPort: 5 Data bits cannot be used with 2 stop bits.");
00531                 }
00532                 else {
00533                     Settings.DataBits=dataBits;
00534                     Posix_CommConfig.c_cflag&=(~CSIZE);
00535                     Posix_CommConfig.c_cflag|=CS5;
00536                     tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig);
00537                 }
00538                 break;
00539 
00540             /*6 data bits*/
00541             case DATA_6:
00542                 if (Settings.StopBits==STOP_1_5) {
00543                     TTY_WARNING("Posix_QextSerialPort: 6 Data bits cannot be used with 1.5 stop bits.");
00544                 }
00545                 else {
00546                     Settings.DataBits=dataBits;
00547                     Posix_CommConfig.c_cflag&=(~CSIZE);
00548                     Posix_CommConfig.c_cflag|=CS6;
00549                     tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig);
00550                 }
00551                 break;
00552 
00553             /*7 data bits*/
00554             case DATA_7:
00555                 if (Settings.StopBits==STOP_1_5) {
00556                     TTY_WARNING("Posix_QextSerialPort: 7 Data bits cannot be used with 1.5 stop bits.");
00557                 }
00558                 else {
00559                     Settings.DataBits=dataBits;
00560                     Posix_CommConfig.c_cflag&=(~CSIZE);
00561                     Posix_CommConfig.c_cflag|=CS7;
00562                     tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig);
00563                 }
00564                 break;
00565 
00566             /*8 data bits*/
00567             case DATA_8:
00568                 if (Settings.StopBits==STOP_1_5) {
00569                     TTY_WARNING("Posix_QextSerialPort: 8 Data bits cannot be used with 1.5 stop bits.");
00570                 }
00571                 else {
00572                     Settings.DataBits=dataBits;
00573                     Posix_CommConfig.c_cflag&=(~CSIZE);
00574                     Posix_CommConfig.c_cflag|=CS8;
00575                     tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig);
00576                 }
00577                 break;
00578         }
00579     }
00580     UNLOCK_MUTEX();
00581 }

void Posix_QextSerialPort::setDtr ( bool  set = true  )  [virtual]

Sets DTR line to the requested state (high by default). This function will have no effect if the port associated with the class is not currently open.

Implements QextSerialBase.

00980 {
00981     LOCK_MUTEX();
00982     if (isOpen()) {
00983         int status;
00984         ioctl(Posix_File->handle(), TIOCMGET, &status);
00985         if (set) {
00986             status|=TIOCM_DTR;
00987         }
00988         else {
00989             status&=~TIOCM_DTR;
00990         }
00991         ioctl(Posix_File->handle(), TIOCMSET, &status);
00992     }
00993     UNLOCK_MUTEX();
00994 }

void Posix_QextSerialPort::setFlowControl ( FlowType  flow  )  [virtual]

Sets the flow control used by the port. Possible values of flow are:

    FLOW_OFF            No flow control
    FLOW_HARDWARE       Hardware (RTS/CTS) flow control
    FLOW_XONXOFF        Software (XON/XOFF) flow control
Note:
FLOW_HARDWARE may not be supported on all versions of UNIX. In cases where it is unsupported, FLOW_HARDWARE is the same as FLOW_OFF.

Implements QextSerialBase.

00746 {
00747     LOCK_MUTEX();
00748     if (Settings.FlowControl!=flow) {
00749         Settings.FlowControl=flow;
00750     }
00751     if (isOpen()) {
00752         switch(flow) {
00753 
00754             /*no flow control*/
00755             case FLOW_OFF:
00756                 Posix_CommConfig.c_cflag&=(~CRTSCTS);
00757                 Posix_CommConfig.c_iflag&=(~(IXON|IXOFF|IXANY));
00758                 tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig);
00759                 break;
00760 
00761             /*software (XON/XOFF) flow control*/
00762             case FLOW_XONXOFF:
00763                 Posix_CommConfig.c_cflag&=(~CRTSCTS);
00764                 Posix_CommConfig.c_iflag|=(IXON|IXOFF|IXANY);
00765                 tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig);
00766                 break;
00767 
00768             case FLOW_HARDWARE:
00769                 Posix_CommConfig.c_cflag|=CRTSCTS;
00770                 Posix_CommConfig.c_iflag&=(~(IXON|IXOFF|IXANY));
00771                 tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig);
00772                 break;
00773         }
00774     }
00775     UNLOCK_MUTEX();
00776 }

void Posix_QextSerialPort::setParity ( ParityType  parity  )  [virtual]

Sets the parity associated with the serial port. The possible values of parity are:

    PAR_SPACE       Space Parity
    PAR_MARK        Mark Parity
    PAR_NONE        No Parity
    PAR_EVEN        Even Parity
    PAR_ODD         Odd Parity

Note:
This function is subject to the following limitations:
POSIX systems do not support mark parity.
POSIX systems support space parity only if tricked into doing so, and only with fewer than 8 data bits. Use space parity very carefully with POSIX systems.

Implements QextSerialBase.

00604 {
00605     LOCK_MUTEX();
00606     if (Settings.Parity!=parity) {
00607         if (parity==PAR_MARK || (parity==PAR_SPACE && Settings.DataBits==DATA_8)) {
00608         }
00609         else {
00610             Settings.Parity=parity;
00611         }
00612     }
00613     if (isOpen()) {
00614         switch (parity) {
00615 
00616             /*space parity*/
00617             case PAR_SPACE:
00618                 if (Settings.DataBits==DATA_8) {
00619                     TTY_PORTABILITY_WARNING("Posix_QextSerialPort:  Space parity is only supported in POSIX with 7 or fewer data bits");
00620                 }
00621                 else {
00622 
00623                     /*space parity not directly supported - add an extra data bit to simulate it*/
00624                     Posix_CommConfig.c_cflag&=~(PARENB|CSIZE);
00625                     switch(Settings.DataBits) {
00626                         case DATA_5:
00627                             Settings.DataBits=DATA_6;
00628                             Posix_CommConfig.c_cflag|=CS6;
00629                             break;
00630 
00631                         case DATA_6:
00632                             Settings.DataBits=DATA_7;
00633                             Posix_CommConfig.c_cflag|=CS7;
00634                             break;
00635 
00636                         case DATA_7:
00637                             Settings.DataBits=DATA_8;
00638                             Posix_CommConfig.c_cflag|=CS8;
00639                             break;
00640 
00641                         case DATA_8:
00642                             break;
00643                     }
00644                     tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig);
00645                 }
00646                 break;
00647 
00648             /*mark parity - WINDOWS ONLY*/
00649             case PAR_MARK:
00650                 TTY_WARNING("Posix_QextSerialPort: Mark parity is not supported by POSIX.");
00651                 break;
00652 
00653             /*no parity*/
00654             case PAR_NONE:
00655                 Posix_CommConfig.c_cflag&=(~PARENB);
00656                 tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig);
00657                 break;
00658 
00659             /*even parity*/
00660             case PAR_EVEN:
00661                 Posix_CommConfig.c_cflag&=(~PARODD);
00662                 Posix_CommConfig.c_cflag|=PARENB;
00663                 tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig);
00664                 break;
00665 
00666             /*odd parity*/
00667             case PAR_ODD:
00668                 Posix_CommConfig.c_cflag|=(PARENB|PARODD);
00669                 tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig);
00670                 break;
00671         }
00672     }
00673     UNLOCK_MUTEX();
00674 }

void QextSerialBase::setPortName ( const QString &  name  )  [virtual, inherited]

Sets the name of the device associated with the object, e.g. "COM1", or "/dev/ttyS0".

00107 {
00108     port = name;
00109 }

void Posix_QextSerialPort::setRts ( bool  set = true  )  [virtual]

Sets RTS line to the requested state (high by default). This function will have no effect if the port associated with the class is not currently open.

Implements QextSerialBase.

01002 {
01003     LOCK_MUTEX();
01004     if (isOpen()) {
01005         int status;
01006         ioctl(Posix_File->handle(), TIOCMGET, &status);
01007         if (set) {
01008             status|=TIOCM_RTS;
01009         }
01010         else {
01011             status&=~TIOCM_RTS;
01012         }
01013         ioctl(Posix_File->handle(), TIOCMSET, &status);
01014     }
01015     UNLOCK_MUTEX();
01016 }

void Posix_QextSerialPort::setStopBits ( StopBitsType  stopBits  )  [virtual]

Sets the number of stop bits used by the serial port. Possible values of stopBits are:

    STOP_1      1 stop bit
    STOP_1_5    1.5 stop bits
    STOP_2      2 stop bits
Note:
This function is subject to the following restrictions:
2 stop bits cannot be used with 5 data bits.
POSIX does not support 1.5 stop bits.

Implements QextSerialBase.

00693 {
00694     LOCK_MUTEX();
00695     if (Settings.StopBits!=stopBits) {
00696         if ((Settings.DataBits==DATA_5 && stopBits==STOP_2) || stopBits==STOP_1_5) {}
00697         else {
00698             Settings.StopBits=stopBits;
00699         }
00700     }
00701     if (isOpen()) {
00702         switch (stopBits) {
00703 
00704             /*one stop bit*/
00705             case STOP_1:
00706                 Settings.StopBits=stopBits;
00707                 Posix_CommConfig.c_cflag&=(~CSTOPB);
00708                 tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig);
00709                 break;
00710 
00711             /*1.5 stop bits*/
00712             case STOP_1_5:
00713                 TTY_WARNING("Posix_QextSerialPort: 1.5 stop bit operation is not supported by POSIX.");
00714                 break;
00715 
00716             /*two stop bits*/
00717             case STOP_2:
00718                 if (Settings.DataBits==DATA_5) {
00719                     TTY_WARNING("Posix_QextSerialPort: 2 stop bits cannot be used with 5 data bits");
00720                 }
00721                 else {
00722                     Settings.StopBits=stopBits;
00723                     Posix_CommConfig.c_cflag|=CSTOPB;
00724                     tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig);
00725                 }
00726                 break;
00727         }
00728     }
00729     UNLOCK_MUTEX();
00730 }

void Posix_QextSerialPort::setTimeout ( ulong  sec,
ulong  millisec 
) [virtual]

Sets the read and write timeouts for the port to sec seconds and millisec milliseconds. Note that this is a per-character timeout, i.e. the port will wait this long for each individual character, not for the whole read operation. This timeout also applies to the bytesWaiting() function.

Note:
POSIX does not support millisecond-level control for I/O timeout values. Any timeout set using this function will be set to the next lowest tenth of a second for the purposes of detecting read or write timeouts. For example a timeout of 550 milliseconds will be seen by the class as a timeout of 500 milliseconds for the purposes of reading and writing the port. However millisecond-level control is allowed by the select() system call, so for example a 550-millisecond timeout will be seen as 550 milliseconds on POSIX systems for the purpose of detecting available bytes in the read buffer.

Implements QextSerialBase.

00796 {
00797     LOCK_MUTEX();
00798     Settings.Timeout_Sec=sec;
00799     Settings.Timeout_Millisec=millisec;
00800     Posix_Copy_Timeout.tv_sec=sec;
00801     Posix_Copy_Timeout.tv_usec=millisec;
00802     if (isOpen()) {
00803         tcgetattr(Posix_File->handle(), &Posix_CommConfig);
00804         Posix_CommConfig.c_cc[VTIME]=sec*10+millisec/100;
00805         tcsetattr(Posix_File->handle(), TCSAFLUSH, &Posix_CommConfig);
00806     }
00807     UNLOCK_MUTEX();
00808 }

qint64 Posix_QextSerialPort::size (  )  const [virtual]

This function will return the number of bytes waiting in the receive queue of the serial port. It is included primarily to provide a complete QIODevice interface, and will not record errors in the lastErr member (because it is const). This function is also not thread-safe - in multithreading situations, use Posix_QextSerialPort::bytesWaiting() instead.

Implements QextSerialBase.

00894 {
00895     int numBytes;
00896     if (ioctl(Posix_File->handle(), FIONREAD, &numBytes)<0) {
00897         numBytes=0;
00898     }
00899     return (qint64)numBytes;
00900 }

StopBitsType QextSerialBase::stopBits (  )  const [virtual, inherited]

Returns the number of stop bits used by the port. For a list of possible return values, see the definition of the enum StopBitsType.

00156 {
00157     return Settings.StopBits;
00158 }

void Posix_QextSerialPort::translateError ( ulong  error  )  [virtual]

Translates a system-specific error code to a QextSerialPort error code. Used internally.

Implements QextSerialBase.

00957 {
00958     switch (error) {
00959         case EBADF:
00960         case ENOTTY:
00961             lastErr=E_INVALID_FD;
00962             break;
00963 
00964         case EINTR:
00965             lastErr=E_CAUGHT_NON_BLOCKED_SIGNAL;
00966             break;
00967 
00968         case ENOMEM:
00969             lastErr=E_NO_MEMORY;
00970             break;
00971     }
00972 }

void Posix_QextSerialPort::ungetChar ( char  c  )  [virtual]

This function is included to implement the full QIODevice interface, and currently has no purpose within this class. This function is meaningless on an unbuffered device and currently only prints a warning message to that effect.

Implements QextSerialBase.

00947 {
00948     /*meaningless on unbuffered sequential device - return error and print a warning*/
00949     TTY_WARNING("Posix_QextSerialPort: ungetChar() called on an unbuffered sequential device - operation is meaningless");
00950 }

qint64 Posix_QextSerialPort::writeData ( const char *  data,
qint64  maxSize 
) [protected, virtual]

Writes a block of data to the serial port. This function will write maxSize bytes from the buffer pointed to by data to the serial port. Return value is the number of bytes actually written, or -1 on error.

Warning:
before calling this function ensure that serial port associated with this class is currently open (use isOpen() function to check if port is open).

Implements QextSerialBase.

01107 {
01108     LOCK_MUTEX();
01109     int retVal=0;
01110     retVal=Posix_File->write(data, maxSize);
01111     if (retVal==-1)
01112        lastErr=E_WRITE_FAILED;
01113     UNLOCK_MUTEX();
01114 
01115     flush();
01116     return retVal;
01117 }


Member Data Documentation

ulong QextSerialBase::lastErr [protected, inherited]

QMutex * QextSerialBase::mutex = NULL [static, protected, inherited]

QString QextSerialBase::port [protected, inherited]

struct termios Posix_QextSerialPort::Posix_CommConfig [protected]

struct timeval Posix_QextSerialPort::Posix_Copy_Timeout [protected]

QFile* Posix_QextSerialPort::Posix_File [protected]

struct timeval Posix_QextSerialPort::Posix_Timeout [protected]

unsigned long QextSerialBase::refCount = 0 [static, protected, inherited]

PortSettings QextSerialBase::Settings [protected, inherited]


The documentation for this class was generated from the following files:
Generated on Sun Mar 25 04:21:54 2007 for QextSerialPort by  doxygen 1.4.7