[1317] | 1 |
|
---|
| 2 | /*!
|
---|
| 3 | \class QextSerialPort
|
---|
| 4 | \version 1.0.0
|
---|
| 5 | \author Stefan Sander
|
---|
| 6 |
|
---|
| 7 | A cross-platform serial port class.
|
---|
| 8 | This class encapsulates a serial port on both POSIX and Windows systems. The user will be
|
---|
| 9 | notified of errors and possible portability conflicts at run-time by default - this behavior can
|
---|
| 10 | be turned off by defining _TTY_NOWARN_ (to turn off all warnings) or _TTY_NOWARN_PORT_ (to turn
|
---|
| 11 | off portability warnings) in the project.
|
---|
| 12 |
|
---|
| 13 | \note
|
---|
| 14 | On Windows NT/2000/XP this class uses Win32 serial port functions by default. The user may
|
---|
| 15 | select POSIX behavior under NT, 2000, or XP ONLY by defining _TTY_POSIX_ in the project. I can
|
---|
| 16 | make no guarantees as to the quality of POSIX support under NT/2000 however.
|
---|
| 17 |
|
---|
| 18 | */
|
---|
| 19 |
|
---|
| 20 | #include <stdio.h>
|
---|
| 21 | #include "qextserialport.h"
|
---|
| 22 |
|
---|
| 23 | /*!
|
---|
| 24 | \fn QextSerialPort::QextSerialPort()
|
---|
| 25 | Default constructor. Note that the naming convention used by a QextSerialPort constructed with
|
---|
| 26 | this constructor will be determined by #defined constants, or lack thereof - the default behavior
|
---|
| 27 | is the same as _TTY_LINUX_. Possible naming conventions and their associated constants are:
|
---|
| 28 |
|
---|
| 29 | \verbatim
|
---|
| 30 |
|
---|
| 31 | Constant Used By Naming Convention
|
---|
| 32 | ---------- ------------- ------------------------
|
---|
| 33 | _TTY_WIN_ Windows COM1, COM2
|
---|
| 34 | _TTY_IRIX_ SGI/IRIX /dev/ttyf1, /dev/ttyf2
|
---|
| 35 | _TTY_HPUX_ HP-UX /dev/tty1p0, /dev/tty2p0
|
---|
| 36 | _TTY_SUN_ SunOS/Solaris /dev/ttya, /dev/ttyb
|
---|
| 37 | _TTY_DIGITAL_ Digital UNIX /dev/tty01, /dev/tty02
|
---|
| 38 | _TTY_FREEBSD_ FreeBSD /dev/ttyd0, /dev/ttyd1
|
---|
| 39 | _TTY_LINUX_ Linux /dev/ttyS0, /dev/ttyS1
|
---|
| 40 | <none> Linux /dev/ttyS0, /dev/ttyS1
|
---|
| 41 | \endverbatim
|
---|
| 42 |
|
---|
| 43 | The object will be associated with the first port in the system, e.g. COM1 on Windows systems.
|
---|
| 44 | See the other constructors if you need to use a port other than the first.
|
---|
| 45 | */
|
---|
| 46 | QextSerialPort::QextSerialPort()
|
---|
| 47 | : QextBaseType()
|
---|
| 48 | {}
|
---|
| 49 |
|
---|
| 50 | /*!
|
---|
| 51 | \fn QextSerialPort::QextSerialPort(const QString & name)
|
---|
| 52 | Constructs a serial port attached to the port specified by name.
|
---|
| 53 | name is the name of the device, which is windowsystem-specific,
|
---|
| 54 | e.g."COM1" or "/dev/ttyS0".
|
---|
| 55 | */
|
---|
| 56 | QextSerialPort::QextSerialPort(const QString & name)
|
---|
| 57 | : QextBaseType(name)
|
---|
| 58 | {}
|
---|
| 59 |
|
---|
| 60 | /*!
|
---|
| 61 | \fn QextSerialPort::QextSerialPort(PortSettings const& settings)
|
---|
| 62 | Constructs a port with default name and settings specified by the settings parameter.
|
---|
| 63 | */
|
---|
| 64 | QextSerialPort::QextSerialPort(PortSettings const& settings)
|
---|
| 65 | : QextBaseType(settings)
|
---|
| 66 | {}
|
---|
| 67 |
|
---|
| 68 | /*!
|
---|
| 69 | \fn QextSerialPort::QextSerialPort(const QString & name, PortSettings const& settings)
|
---|
| 70 | Constructs a port with the name and settings specified.
|
---|
| 71 | */
|
---|
| 72 | QextSerialPort::QextSerialPort(const QString & name, PortSettings const& settings)
|
---|
| 73 | : QextBaseType(name, settings)
|
---|
| 74 | {}
|
---|
| 75 |
|
---|
| 76 | /*!
|
---|
| 77 | \fn QextSerialPort::QextSerialPort(const QextSerialPort& s)
|
---|
| 78 | Copy constructor.
|
---|
| 79 | */
|
---|
| 80 | QextSerialPort::QextSerialPort(const QextSerialPort& s)
|
---|
| 81 | : QextBaseType(s)
|
---|
| 82 | {}
|
---|
| 83 |
|
---|
| 84 | /*!
|
---|
| 85 | \fn QextSerialPort& QextSerialPort::operator=(const QextSerialPort& s)
|
---|
| 86 | Overrides the = operator.
|
---|
| 87 | */
|
---|
| 88 | QextSerialPort& QextSerialPort::operator=(const QextSerialPort& s)
|
---|
| 89 | {
|
---|
| 90 | return (QextSerialPort&)QextBaseType::operator=(s);
|
---|
| 91 | }
|
---|
| 92 |
|
---|
| 93 | /*!
|
---|
| 94 | \fn QextSerialPort::~QextSerialPort()
|
---|
| 95 | Standard destructor.
|
---|
| 96 | */
|
---|
| 97 | QextSerialPort::~QextSerialPort()
|
---|
| 98 | {}
|
---|