. 1.0.0
Открытые члены | Открытые атрибуты | Защищенные члены | Защищенные данные | Полный список членов класса
Класс Win_QextSerialPort

Windows serial port class. Подробнее...

Граф наследования:Win_QextSerialPort:
QextSerialBase

Открытые члены

 Win_QextSerialPort ()
 
 Win_QextSerialPort (Win_QextSerialPort const &s)
 
 Win_QextSerialPort (const char *name)
 
 Win_QextSerialPort (const PortSettings &settings)
 
 Win_QextSerialPort (const char *name, const PortSettings &settings)
 
Win_QextSerialPortoperator= (Win_QextSerialPort const &s)
 
virtual ~Win_QextSerialPort ()
 
virtual bool open (int mode=0)
 
virtual void close ()
 
virtual void flush ()
 
virtual Offset size () const
 
virtual int getch ()
 
virtual int putch (int)
 
virtual int ungetch (int)
 
virtual void setFlowControl (FlowType)
 
virtual void setParity (ParityType)
 
virtual void setDataBits (DataBitsType)
 
virtual void setStopBits (StopBitsType)
 
virtual void setBaudRate (BaudRateType)
 
virtual void setDtr (bool set=true)
 
virtual void setRts (bool set=true)
 
virtual unsigned long lineStatus (void)
 
virtual int bytesWaiting ()
 
virtual void translateError (unsigned long)
 
virtual void setTimeout (unsigned long=0, unsigned long=0)
 
virtual Q_LONG readBlock (char *data, unsigned long maxlen)
 
virtual Q_LONG writeBlock (const char *data, unsigned long len)
 
- Открытые члены унаследованные от QextSerialBase
 QextSerialBase ()
 
 QextSerialBase (const char *name)
 
virtual ~QextSerialBase ()
 
virtual const charname () const
 
virtual void setName (const char *name)
 
virtual bool open (const char *name)
 
virtual Q_LONG readLine (char *data, Q_ULONG maxlen)
 
virtual bool atEnd () const
 
virtual FlowType flowControl () const
 
virtual ParityType parity () const
 
virtual DataBitsType dataBits () const
 
virtual StopBitsType stopBits () const
 
virtual BaudRateType baudRate () const
 
virtual bool isOpen () const
 
virtual unsigned long lastError () const
 
virtual bool isOpen (void)
 

Открытые атрибуты

HANDLE Win_Handle
 

Защищенные члены

void construct (void)
 

Защищенные данные

COMMCONFIG Win_CommConfig
 
COMMTIMEOUTS Win_CommTimeouts
 
- Защищенные данные унаследованные от QextSerialBase
bool portOpen
 
unsigned long lastErr
 
char portName [PORT_NAME_SIZE_LIMIT+1]
 
PortSettings Settings
 

Подробное описание

Windows serial port class.

Версия
0.70 (pre-alpha)
Автор
Wayne Roth

A cross-platform serial port class. This class encapsulates the Windows 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 defining TTY_NOWARN also defines TTY_NOWARN_PORT.

Заметки
On Windows NT/2000/XP this class uses Win32 serial port functions by default. The user may select POSIX behavior under NT, 2000, or XP ONLY by defining TTY_POSIX in the project. I can make no guarantees as to the quality of POSIX support under NT/2000 however.

Конструктор(ы)

◆ Win_QextSerialPort() [1/5]

Win_QextSerialPort::Win_QextSerialPort ( )

Default constructor. Note that the name of the device used by a Win_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 associates the object with the first port on the system, e.g. COM1 for Windows platforms. See the other constructor if you need a port other than the first.

Перекрестные ссылки construct().

◆ Win_QextSerialPort() [2/5]

Win_QextSerialPort::Win_QextSerialPort ( Win_QextSerialPort const & s)

Win_QextSerialPort::Win_QextSerialPort(const Win_QextSerialPort&) Copy constructor.

Перекрестные ссылки construct().

◆ Win_QextSerialPort() [3/5]

Win_QextSerialPort::Win_QextSerialPort ( const char * devName)

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

Перекрестные ссылки construct().

◆ Win_QextSerialPort() [4/5]

Win_QextSerialPort::Win_QextSerialPort ( const PortSettings & settings)

Constructs a port with default name and specified settings.

Перекрестные ссылки construct(), setBaudRate(), setDataBits(), setFlowControl(), setParity(), setStopBits() и setTimeout().

◆ Win_QextSerialPort() [5/5]

Win_QextSerialPort::Win_QextSerialPort ( const char * name,
const PortSettings & settings )

Constructs a port with specified name and settings.

Перекрестные ссылки construct(), QextSerialBase::name(), setBaudRate(), setDataBits(), setFlowControl(), QextSerialBase::setName(), setParity(), setStopBits() и setTimeout().

◆ ~Win_QextSerialPort()

Win_QextSerialPort::~Win_QextSerialPort ( )
virtual

Standard destructor.

Перекрестные ссылки close().

Методы

◆ bytesWaiting()

int Win_QextSerialPort::bytesWaiting ( )
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 Win_QextSerialPort::getLastError().

Замещает QextSerialBase.

Перекрестные ссылки translateError().

◆ close()

void Win_QextSerialPort::close ( )
virtual

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

Замещает QextSerialBase.

Используется в ~Win_QextSerialPort().

◆ construct()

void Win_QextSerialPort::construct ( void )
protectedvirtual

Common constructor function, called by all versions of Win_QextSerialPort::Win_QextSerialPort(). Sets up default port settings (115200 8N1 Hardware flow control where supported, otherwise no flow control, and 500 ms timeout).

Переопределяет метод предка QextSerialBase.

Перекрестные ссылки QextSerialBase::construct(), setBaudRate(), setDataBits(), setFlowControl(), setParity(), setStopBits() и setTimeout().

Используется в Win_QextSerialPort(), Win_QextSerialPort(), Win_QextSerialPort(), Win_QextSerialPort() и Win_QextSerialPort().

◆ flush()

void Win_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.

Замещает QextSerialBase.

Используется в putch().

◆ getch()

int Win_QextSerialPort::getch ( )
virtual

Returns a single character from the serial port, or -1 on error. This function has no effect if the serial port associated with the class is not currently open.

Замещает QextSerialBase.

◆ lineStatus()

unsigned long Win_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

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

Замещает QextSerialBase.

◆ open()

bool Win_QextSerialPort::open ( int mode = 0)
virtual

Opens a serial port. Note that this function does not specify which device to open. If you need to open a device by name, see Win_QextSerialPort::open(const char*). 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.

Замещает QextSerialBase.

Перекрестные ссылки setBaudRate(), setDataBits(), setFlowControl(), setParity(), setStopBits() и setTimeout().

◆ putch()

int Win_QextSerialPort::putch ( int ch)
virtual

Writes a single character to the serial port. Return value is the byte written, or -1 on error. This function has no effect if the serial port associated with the class is not currently open.

Замещает QextSerialBase.

Перекрестные ссылки flush().

◆ readBlock()

Q_LONG Win_QextSerialPort::readBlock ( char * data,
unsigned long maxlen )
virtual

Reads a block of data from the serial port. This function will read at most maxlen 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. This function will have no effect if the serial port associated with the class is not currently open.

Замещает QextSerialBase.

◆ setBaudRate()

void Win_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.

  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

Замещает QextSerialBase.

Перекрестные ссылки QextSerialBase::baudRate().

Используется в construct(), open(), Win_QextSerialPort() и Win_QextSerialPort().

◆ setDataBits()

void Win_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
Заметки
This function is subject to the following restrictions:
5 data bits cannot be used with 2 stop bits.
1.5 stop bits can only be used with 5 data bits.
8 data bits cannot be used with space parity on POSIX systems.

Замещает QextSerialBase.

Перекрестные ссылки QextSerialBase::dataBits().

Используется в construct(), open(), Win_QextSerialPort() и Win_QextSerialPort().

◆ setDtr()

void Win_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.

Замещает QextSerialBase.

◆ setFlowControl()

void Win_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

Замещает QextSerialBase.

Используется в construct(), open(), Win_QextSerialPort() и Win_QextSerialPort().

◆ setParity()

void Win_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

Замещает QextSerialBase.

Перекрестные ссылки QextSerialBase::parity().

Используется в construct(), open(), Win_QextSerialPort() и Win_QextSerialPort().

◆ setRts()

void Win_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.

Замещает QextSerialBase.

◆ setStopBits()

void Win_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
Заметки
This function is subject to the following restrictions:
2 stop bits cannot be used with 5 data bits.
1.5 stop bits cannot be used with 6 or more data bits.
POSIX does not support 1.5 stop bits.

Замещает QextSerialBase.

Перекрестные ссылки QextSerialBase::stopBits().

Используется в construct(), open(), Win_QextSerialPort() и Win_QextSerialPort().

◆ setTimeout()

void Win_QextSerialPort::setTimeout ( unsigned long sec = 0,
unsigned long millisec = 0 )
virtual

Sets the read and write timeouts for the port to sec seconds and millisec milliseconds.

Замещает QextSerialBase.

Используется в construct(), open(), Win_QextSerialPort() и Win_QextSerialPort().

◆ size()

Offset Win_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 Win_QextSerialPort::bytesWaiting() instead.

Замещает QextSerialBase.

◆ translateError()

void Win_QextSerialPort::translateError ( unsigned long error)
virtual

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

Замещает QextSerialBase.

Используется в bytesWaiting().

◆ ungetch()

int Win_QextSerialPort::ungetch ( int )
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.

Переопределяет метод предка QextSerialBase.

◆ writeBlock()

Q_LONG Win_QextSerialPort::writeBlock ( const char * data,
unsigned long len )
virtual

Writes a block of data to the serial port. This function will write len 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. This function will have no effect if the serial port associated with the class is not currently open.

Замещает QextSerialBase.


Объявления и описания членов классов находятся в файлах: