Qt Serial Port: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
No edit summary
(→‎News: Notify readers that Qt Serial Port is now officially part of Qt 5)
(21 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{Cleanup | reason=Auto-imported from ExpressionEngine.}}
'''English'''
'''English'''
| [[:QtSerialPort_German|Deutsch]]
| [[:QtSerialPort_German|Deutsch]]
Line 22: Line 24:
| [[:QtSerialPort_Bulgarian|Български]]
| [[:QtSerialPort_Bulgarian|Български]]


[toc align_right="yes" depth="3"]
= QtSerialPort =


'''''Note''': this page is work in progress, needs review.''
'''''Note''': this page is work in progress, needs review.''


== News ==
== News ==
 
* '''2013-07-03''' - As of Qt 5.1, Qt Serial Port is now officially part of Qt. '''You no longer need to build Qt Serial Port manually; simply install Qt 5.1 or later.'''
Fill up
* '''2013-02-26''' - The project moved from the playground to the trunk of Qt5!
 
02/26/2013 - The project moved from the playground to the trunk of Qt5!


== Brief description ==
== Brief description ==
Line 46: Line 43:
== History ==
== History ==


'''QtSerialPort''' originated from the third-party library "QSerialDevice":http://gitorious.org/qserialdevice/qserialdevice/trees/2.0 (branch 2.0), which was recently moved to a repository on https://codereview.qt.io/
'''QtSerialPort''' originated from the third-party library [http://gitorious.org/qserialdevice/qserialdevice/trees/2.0 QSerialDevice] [gitorious.org] (branch 2.0), which was recently moved to a repository on https://codereview.qt.io/


This was done to allow more open development, and to gather and coordinate a community that is interested in developing this module.
This was done to allow more open development, and to gather and coordinate a community that is interested in developing this module.
Line 60: Line 57:
Supports the following operating systems:
Supports the following operating systems:


{background:#009900}. |''. Operating system |''. Support state |''. Note
{| class="wikitable"
|
! style="text-align:left;"| Operating system  
! style="text-align:left;"| Support state  
! style="text-align:left;"| Note
|-
|Windows NT/2K/XP/Vista/7
|Windows NT/2K/XP/Vista/7
|YES
|YES
|Full support
|Full support
|
|-
|Windows CE
|Windows CE
|YES
|YES
|Tested only on 5 and 6 platforms in the emulator
|Tested only on 5 and 6 platforms in the emulator
|
|-
|Gnu/Linux
|Gnu/Linux
|YES
|YES
|Full support
|Full support
|
|-
|MacOSX
|MacOSX
|YES
|YES
|Full support
|Full support
|
|-
|Others Unix
|Others Unix
|YES
|YES
|All POSIX-compatible
|All POSIX-compatible
|
|-
|Symbian<ref>For OS Symbian development of the module is suspended due to lack of developers, as well as the fact that Nokia has abandoned the platform and will not include support for it in Qt5.
|Symbian<ref>For OS Symbian development of the module is suspended due to lack of developers, as well as the fact that Nokia has abandoned the platform and will not include support for it in Qt5.</ref>
</ref>
|YES
|YES
|Partially, tested only in the emulator
|Partially, tested only in the emulator
|
|}
 
<references />


 
=== QSerialPortInfo ===
h3. QSerialPortInfo


'''QSerialPortInfo''' is a helper class. It provides information on the available serial ports on the system.
'''QSerialPortInfo''' is a helper class. It provides information on the available serial ports on the system.
Line 96: Line 94:
Supports the following operating systems:
Supports the following operating systems:


{background:#009900}. |''. Operating system |''. Support state |''. Note
{| class="wikitable"
|
! style="text-align:left;"|Operating system  
! style="text-align:left;"|Support state  
! style="text-align:left;"|Note
|-
|Windows NT/2K/XP/Vista/7
|Windows NT/2K/XP/Vista/7
|YES
|YES
|Full support (using SetupAPI)
|Full support (using SetupAPI)
|
|-
|Windows CE
|Windows CE
|YES
|YES
|Tested only on 5 and 6 platforms in the emulator
|Tested only on 5 and 6 platforms in the emulator
|
|-
|Gnu/Linux
|Gnu/Linux
|YES
|YES
|Full support (using libudev or simple search in /dev)
|Full support (using libudev or simple search in /dev)
|
|-
|MacOSX
|MacOSX
|YES
|YES
|Full support
|Full support
|
|-
|Others Unix
|Others Unix
|YES
|YES
|All POSIX-compatible (only simple search in /dev)
|All POSIX-compatible (only simple search in /dev)
|
|-
|Symbian<ref>Symbian development of the module is suspended due to lack of developers, as well as the fact that Nokia has abandoned the platform and will not include support for it in Qt5.
|Symbian²
</ref>
|YES
|YES
|Partially, tested only in the emulator
|Partially, tested only in the emulator
|
|}
 
²Symbian development of the module is suspended due to lack of developers, as well as the fact that Nokia has abandoned the platform and will not include support for it in Qt5.


== View the source code ==
== View the source code ==


Recently launched a public mirror of the repository project at "Gitorious":http://qt.gitorious.org/qt/qtserialport
Recently launched a public mirror of the repository project at [http://qt.gitorious.org/qt/qtserialport Gitorious]


Now everyone can freely and quickly view the latest changes through a WEB browser.
Now everyone can freely and quickly view the latest changes through a WEB browser.
Line 134: Line 136:
=== For end-users ===
=== For end-users ===


To get the current snapshot of the source code as an archive click on "this":http://qt.gitorious.org/qt/qtserialport/archive-tarball/stable link.
To get the current snapshot of the source code as an archive click on [http://qt.gitorious.org/qt/qtserialport/archive-tarball/stable this] link.


Those who want to use Git can run the following command:
Those who want to use Git can run the following command:


<code>git clone git://gitorious.org/qt/qtserialport.git<code>
<code>git clone git://gitorious.org/qt/qtserialport.git</code>


=== For developers ===
=== For developers ===


To get the source code and contribute to the development you need to register a Qt developer account and set it up for use with Gerrit and Git (see "Setting up Gerrit":http://wiki.qt.io/Setting_up_Gerrit).
To get the source code and contribute to the development you need to register a Qt developer account and set it up for use with Gerrit and Git (see [http://wiki.qt.io/Setting_up_Gerrit Setting up Gerrit]).


You can then check out the repository using git, like this:
You can then check out the repository using git, like this:


</code>git clone ssh://<username>@codereview.qt.io:29418/qt/qtserialport.git</code>
<code>git clone ssh://<username>@codereview.qt.io:29418/qt/qtserialport.git</code>


…with your Gerrit user ID in place of <username>.
…with your Gerrit user ID in place of <username>.
Line 155: Line 157:


Before building you need to:
Before building you need to:
* install Perl<ref>Perl is required only in the case of Qt5, see "here":http://wiki.qt.io/Building_Qt_5_from_Git. When using Qt4 just skip this point.
* install Perl³
</ref>
* ensure that the environment variables are set correctly:
* ensure that the environment variables are set correctly:
'''''' correctly specified the path to the installed Qt4/Qt5
** correctly specified the path to the installed Qt4/Qt5
'''''' correctly specified the path to use the compiler
** correctly specified the path to use the compiler
'''''' correctly specified the path to Perl<ref>Perl is required only in the case of Qt5, see "here":http://wiki.qt.io/Building_Qt_5_from_Git. When using Qt4 just skip this point.
** correctly specified the path to Perl³
</ref>
* create a build directory that is in the same level as the directory with the source code
* create a build directory that is in the same level as the directory with the source code
<code>
<code>
Line 183: Line 183:
</code>
</code>


h3. Build and install from the QtCreator
=== Build and install from the QtCreator ===


Using QtCreator is the simplest and fastest way to manually install the library.
Using QtCreator is the simplest and fastest way to manually install the library.
Line 189: Line 189:
Before building you need to:
Before building you need to:


''' install Perl<ref>Perl is required only in the case of Qt5, see "here":http://wiki.qt.io/Building_Qt_5_from_Git. When using Qt4 just skip this point.
* install Perl³ and check that the path to Perl was correctly specified in a global env
</ref> and check that the path to Perl was correctly specified in a global env
* check that the desired toolchains (kits) of QtCreator have been correctly configured
* check that the desired toolchains (kits) of QtCreator have been correctly configured


Line 204: Line 203:


'''''Note:''' on *nix systems this method can be failed if Qt was installed from the repositories into system directories. Super user privileges may be required for "make install" target_
'''''Note:''' on *nix systems this method can be failed if Qt was installed from the repositories into system directories. Super user privileges may be required for "make install" target_
³Perl is required only in the case of Qt5, see [http://wiki.qt.io/Building_Qt_5_from_Git here]. When using Qt4 just skip this point.


== Usage ==
== Usage ==
Line 212: Line 213:


<code>
<code>
CONFIG ''= serialport
CONFIG += serialport
</code>
</code>


h3. Qt5
=== Qt5 ===


<code>
<code>
QT''= serialport
QT += serialport
</code>
</code>


Line 266: Line 267:
== Documentation generation ==
== Documentation generation ==


There is no need to build the documentation, because the documentation is available "here":http://doc-snapshot.qt.io/qt5-stable/qtserialport-index.html.
There is no need to build the documentation, because the documentation is available [http://doc-snapshot.qt.io/qt5-stable/qtserialport-index.html here].


== For those wishing to contribute to the development ==
== For those wishing to contribute to the development ==


All development is done through "Gerrit":http://wiki.qt.io/Setting_up_Gerrit. Therefore, those wishing to be involved in the development process must have a Qt developer account.
All development is done through [http://wiki.qt.io/Setting_up_Gerrit Gerrit]. Therefore, those wishing to be involved in the development process must have a Qt developer account.


More information about the registration process and development can be found "here":http://wiki.qt.io/Code_Reviews
More information about the registration process and development can be found [http://wiki.qt.io/Code_Reviews here]


== Possible problems ==
== Possible problems ==
Line 280: Line 281:
== Bug Tracking ==
== Bug Tracking ==


Use "bugreports.qt.io":https://bugreports.qt.io, Project "Qt", Component "Serial Port".
Use [https://bugreports.qt.io bugreports.qt.io], Project "Qt", Component "Serial Port".
 
<references />

Revision as of 15:00, 10 March 2015

This article may require cleanup to meet the Qt Wiki's quality standards. Reason: Auto-imported from ExpressionEngine.
Please improve this article if you can. Remove the {{cleanup}} tag and add this page to Updated pages list after it's clean.

English | Deutsch | Русский | Polski | Nederlands | Português | Español | Українською | فارسی | عربي | 한국어 | Suomi | Català | Italiano | 日本語 | Français | Magyar | ಕನ್ನಡ | हिन्दी | ภาษาไทย | 简体中文 | Български


Note: this page is work in progress, needs review.

News

  • 2013-07-03 - As of Qt 5.1, Qt Serial Port is now officially part of Qt. You no longer need to build Qt Serial Port manually; simply install Qt 5.1 or later.
  • 2013-02-26 - The project moved from the playground to the trunk of Qt5!

Brief description

The QtSerialPort module is an add-on module for the Qt5 library, providing a single interface for both hardware and virtual serial ports.

Note: Also added support for Qt4.

Serial interfaces, due to their simplicity and reliability, are still popular in some industries like the development of embedded systems, robotics, etc.

Using the QtSerialPort module, developers can significantly reduce the time needed to implement Qt applications that require access to a serial interface.

History

QtSerialPort originated from the third-party library QSerialDevice [gitorious.org] (branch 2.0), which was recently moved to a repository on https://codereview.qt.io/

This was done to allow more open development, and to gather and coordinate a community that is interested in developing this module.

Functionality

Currently, the module API contains two classes: QSerialPort and QSerialPortInfo.

QSerialPort

QSerialPort is the base class of the module and provides a set of basic methods and properties to access resources on serial ports.

Supports the following operating systems:

Operating system Support state Note
Windows NT/2K/XP/Vista/7 YES Full support
Windows CE YES Tested only on 5 and 6 platforms in the emulator
Gnu/Linux YES Full support
MacOSX YES Full support
Others Unix YES All POSIX-compatible
Symbian[1] YES Partially, tested only in the emulator
  1. For OS Symbian development of the module is suspended due to lack of developers, as well as the fact that Nokia has abandoned the platform and will not include support for it in Qt5.

QSerialPortInfo

QSerialPortInfo is a helper class. It provides information on the available serial ports on the system.

Supports the following operating systems:

Operating system Support state Note
Windows NT/2K/XP/Vista/7 YES Full support (using SetupAPI)
Windows CE YES Tested only on 5 and 6 platforms in the emulator
Gnu/Linux YES Full support (using libudev or simple search in /dev)
MacOSX YES Full support
Others Unix YES All POSIX-compatible (only simple search in /dev)
Symbian² YES Partially, tested only in the emulator

²Symbian development of the module is suspended due to lack of developers, as well as the fact that Nokia has abandoned the platform and will not include support for it in Qt5.

View the source code

Recently launched a public mirror of the repository project at Gitorious

Now everyone can freely and quickly view the latest changes through a WEB browser.

Getting the source code

For end-users

To get the current snapshot of the source code as an archive click on this link.

Those who want to use Git can run the following command:

git clone git://gitorious.org/qt/qtserialport.git

For developers

To get the source code and contribute to the development you need to register a Qt developer account and set it up for use with Gerrit and Git (see Setting up Gerrit).

You can then check out the repository using git, like this:

git clone ssh://<username>@codereview.qt.io:29418/qt/qtserialport.git

…with your Gerrit user ID in place of <username>.

Building and Installing

Build and install from command line

Before building you need to:

  • install Perl³
  • ensure that the environment variables are set correctly:
    • correctly specified the path to the installed Qt4/Qt5
    • correctly specified the path to use the compiler
    • correctly specified the path to Perl³
  • create a build directory that is in the same level as the directory with the source code
/
|- /serialport-src
|- /serialport-build

The following are the recommended steps for building the QtSerialPort library on Qt4/Qt5 from the command line.

cd serialport-build
qmake ../serialport-src/qtserialport.pro
make [or 'nmake' for MSVC compiler, or 'mingw32-make' for MinGW compiler]
make install [or 'nmake install' for MSVC compiler, or 'mingw32-make install' for MinGW compiler]

Note:' on nix systems super user privileges might be required:_

sudo make install

Build and install from the QtCreator

Using QtCreator is the simplest and fastest way to manually install the library.

Before building you need to:

  • install Perl³ and check that the path to Perl was correctly specified in a global env
  • check that the desired toolchains (kits) of QtCreator have been correctly configured

Recommended steps to build the QtSerialPort library for Qt4/Qt5 from QtCreator:

  • download and unpack the QtSerialPort sources
  • run QtCreator and open the "qtserialport.pro" project file
  • get to "Projects->(Your Kit)->Build->Build Steps"
  • add a new make "Build Step" and write to the "Make arguments" the install target
  • from the menus, select "Rebuild Project qtserialport"

As a result, the QtSerialPort library will be automatically compiled and installed into the desired Qt instance (according to the selected Kit).

Note: on *nix systems this method can be failed if Qt was installed from the repositories into system directories. Super user privileges may be required for "make install" target_

³Perl is required only in the case of Qt5, see here. When using Qt4 just skip this point.

Usage

To use the library, add serialport to the *.pro file of your project:

Qt4

CONFIG += serialport

Qt5

QT += serialport

Include the header files of QtSerialPort where appropriate:


#include <QtSerialPort/QSerialPort>
#include <QtSerialPort/QSerialPortInfo>

Simple example

Below is a simple example of main.cpp:

#include <QtCore/QCoreApplication>
#include <QtCore/QDebug>

#include <QtSerialPort/QSerialPort>
#include <QtSerialPort/QSerialPortInfo>

QT_USE_NAMESPACE

int main(int argc, char *argv[])
{
 QCoreApplication a(argc, argv);

// Example use QSerialPortInfo
 foreach (const QSerialPortInfo &amp;info, QSerialPortInfo::availablePorts()) {
 qDebug() << "Name : " << info.portName();
 qDebug() << "Description : " << info.description();
 qDebug() << "Manufacturer: " << info.manufacturer();

// Example use QSerialPort
 QSerialPort serial;
 serial.setPort(info);
 if (serial.open(QIODevice::ReadWrite))
 serial.close();
 }

return a.exec();
}

Note: CONFIG = serial port / QT= serialport must be the first or second line in your .pro file.

Documentation generation

There is no need to build the documentation, because the documentation is available here.

For those wishing to contribute to the development

All development is done through Gerrit. Therefore, those wishing to be involved in the development process must have a Qt developer account.

More information about the registration process and development can be found here

Possible problems

Fill up

Bug Tracking

Use bugreports.qt.io, Project "Qt", Component "Serial Port".