본문 바로가기

카테고리 없음

Qt Serial Port Rs485



We've hard-coded the port to be /dev/ttyUSB0, but it would be nice if the availablePorts returned the port connected to the FTDI device. Here is the code I'm using. If I remove the #ifndef statement, nothing is output to the terminal for an Android build. Port = new QSerialPort(portName). Browse other questions tagged qt serial-port qt5 or ask your own question. The Overflow Blog Podcast 259: from web comics to React core with Rachel Nabors. How we built it: our new Articles feature for Stack Overflow Teams. RS485 communication over TCP/IP.

  • Status:Closed
  • Resolution: Done
  • Fix Version/s:5.3.0 Alpha
  • Labels:
  • Environment:
  • Platform/s:
  • Commits:

When using an FTDI USB to RS485 device on an Android tablet, QSerialPortInfo::availablePorts() returns nothing, when a device is connected.

We're using an add-on module for Android in /system/lib/modules/ftdi_sio.ko, which recognizes the FTDI device and populates /dev/ttyUSB0, however this device isn't shown by QSerialPortInfo::availablePort().

We've hard-coded the port to be /dev/ttyUSB0, but it would be nice if the availablePorts() returned the port connected to the FTDI device. Here is the code I'm using. If I remove the #ifndef statement, nothing is output to the terminal for an Android build.

<code>
port = new QSerialPort(portName);

#ifndef Q_OS_ANDROID
qDebug() << '*********Populating Serial Port(s)************';
foreach(const QSerialPortInfo &info, QSerialPortInfo::availablePorts())

{ qDebug() << 'Name : ' << info.portName(); qDebug() << 'Description : ' << info.description(); qDebug() << 'Product ID : ' << info.productIdentifier(); qDebug() << 'Manufacturer: ' << info.manufacturer(); if( info.manufacturer() 'FTDI') port->setPort(info); }

#endif
<code>

Attachments

Qt Serial Port Rs485

Gerrit Reviews

No reviews matched the request. Check your Options in the drop-down menu of this sections header.
Votes:
0Vote for this issue
Watchers:
6Start watching this issue

Hide There are 3 closed Gerrit changes

Fixed info update for FTDI devices on Android
Gerrit Review:
Fixed info update for FTDI devices on Android
Gerrit Review:
Fixed info update for FTDI devices on Android
Gerrit Review:

Provides information about existing serial ports. More...

Header: #include <QSerialPortInfo>
qmake: QT += serialport
Since: Qt 5.1

Public Functions

QSerialPortInfo()
QSerialPortInfo(const QSerialPort &port)
QSerialPortInfo(const QString &name)
QSerialPortInfo(const QSerialPortInfo &other)
~QSerialPortInfo()
QString description() const
bool hasProductIdentifier() const
bool hasVendorIdentifier() const
bool isBusy() const
bool isNull() const
QString manufacturer() const
QString portName() const
quint16 productIdentifier() const
QString serialNumber() const
void swap(QSerialPortInfo &other)
QString systemLocation() const
quint16 vendorIdentifier() const
QSerialPortInfo & operator=(const QSerialPortInfo &other)

Static Public Members

QList<QSerialPortInfo> availablePorts()
QList<qint32> standardBaudRates()

Detailed Description

Provides information about existing serial ports.

Use the static functions to generate a list of QSerialPortInfo objects. Each QSerialPortInfo object in the list represents a single serial port and can be queried for the port name, system location, description, and manufacturer. The QSerialPortInfo class can also be used as an input parameter for the setPort() method of the QSerialPort class.

See also QSerialPort.

Member Function Documentation

QSerialPortInfo::QSerialPortInfo()

Constructs an empty QSerialPortInfo object.

See also isNull().

QSerialPortInfo::QSerialPortInfo(const QSerialPort &port)

Constructs a QSerialPortInfo object from serial port.

QSerialPortInfo::QSerialPortInfo(const QString &name)

Constructs a QSerialPortInfo object from serial port name.

This constructor finds the relevant serial port among the available ones according to the port name name, and constructs the serial port info instance for that port.

QSerialPortInfo::QSerialPortInfo(const QSerialPortInfo &other)

Constructs a copy of other.

QSerialPortInfo::~QSerialPortInfo()

Destroys the QSerialPortInfo object. References to the values in the object become invalid.

[static] QList<QSerialPortInfo> QSerialPortInfo::availablePorts()

Returns a list of available serial ports on the system.

QString QSerialPortInfo::description() const

Returns the description string of the serial port, if available; otherwise returns an empty string.

Rs485 Interface

See also manufacturer() and serialNumber().

bool QSerialPortInfo::hasProductIdentifier() const

Returns true if there is a valid 16-bit product number present; otherwise returns false.

See also productIdentifier(), vendorIdentifier(), and hasVendorIdentifier().

bool QSerialPortInfo::hasVendorIdentifier() const

Rs485 serial cable

Returns true if there is a valid 16-bit vendor number present; otherwise returns false.

See also vendorIdentifier(), productIdentifier(), and hasProductIdentifier().

bool QSerialPortInfo::isBusy() const

Returns true if serial port is busy; otherwise returns false.

See also isNull().

bool QSerialPortInfo::isNull() const

Returns whether this QSerialPortInfo object holds a serial port definition.

See also isBusy().

QString QSerialPortInfo::manufacturer() const

Returns the manufacturer string of the serial port, if available; otherwise returns an empty string.

See also description() and serialNumber().

QString QSerialPortInfo::portName() const

Returns the name of the serial port.

See also systemLocation().

quint16 QSerialPortInfo::productIdentifier() const

Rs485 Serial Connection

Returns the 16-bit product number for the serial port, if available; otherwise returns zero.

See also hasProductIdentifier(), vendorIdentifier(), and hasVendorIdentifier().

QString QSerialPortInfo::serialNumber() const

Returns the serial number string of the serial port, if available; otherwise returns an empty string.

Note: The serial number may include letters.

This function was introduced in Qt 5.3.

See also description() and manufacturer().

[static] QList<qint32> QSerialPortInfo::standardBaudRates()

Rs485 serial protocol

Returns a list of available standard baud rates supported by the target platform.

Rs485 Serial Communication

void QSerialPortInfo::swap(QSerialPortInfo &other)

Swaps QSerialPortInfoother with this QSerialPortInfo. This operation is very fast and never fails.

QString QSerialPortInfo::systemLocation() const

Returns the system location of the serial port.

See also portName().

quint16 QSerialPortInfo::vendorIdentifier() const

Returns the 16-bit vendor number for the serial port, if available; otherwise returns zero.

See also hasVendorIdentifier(), productIdentifier(), and hasProductIdentifier().

Rs485 Serial Cable

QSerialPortInfo &QSerialPortInfo::operator=(const QSerialPortInfo &other)

Sets the QSerialPortInfo object to be equal to other.

Rs485 Serial Protocol

Connection

© 2020 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.