Hello,
I have a FTDI, USB to Serial connected to my own device, I try to list all port (as I can have multiple device connected), open a communication port & send data to my device.
I have no problem for communicating on Windows, but on Linux & Mac I can’t get the informations on my serial port.
This is the code I used to show port :
{
for (QSerialPortInfo port : QSerialPortInfo::availablePorts())
{
//Their is some sorting to do for just list the port I want, with vendor Id & product Id
qDebug() << port.portName() << port.vendorIdentifier() << port.productIdentifier()
<< port.hasProductIdentifier() << port.hasVendorIdentifier() << port.isBusy();
ports += port.portName();
}
return ports;
}
QStringList SerialPortChannel::availablePorts()
{
QStringList ports;
for (QSerialPortInfo port : QSerialPortInfo::availablePorts())
{
//Their is some sorting to do for just list the port I want, with vendor Id & product Id
qDebug() << port.portName() << port.vendorIdentifier() << port.productIdentifier()
<< port.hasProductIdentifier() << port.hasVendorIdentifier() << port.isBusy();
ports += port.portName();
}
return ports;
}
To copy to clipboard, switch view to plain text mode
This is the my class constructor where I open the port :
SerialPortChannel
::SerialPortChannel(QString port
) , m_port(port)
{
if(online)
qDebug() << "Connected to : " << port;
//Configure the port
m_port.setBaudRate(QSerialPort::Baud115200);
m_port.setDataBits(QSerialPort::Data8);
m_port.setStopBits(QSerialPort::OneStop);
m_port.setParity(QSerialPort::NoParity);
m_port.setFlowControl(QSerialPort::NoFlowControl);
}
SerialPortChannel::SerialPortChannel(QString port)
: QObject()
, m_port(port)
{
online = m_port.open(QIODevice::WriteOnly);
if(online)
qDebug() << "Connected to : " << port;
//Configure the port
m_port.setBaudRate(QSerialPort::Baud115200);
m_port.setDataBits(QSerialPort::Data8);
m_port.setStopBits(QSerialPort::OneStop);
m_port.setParity(QSerialPort::NoParity);
m_port.setFlowControl(QSerialPort::NoFlowControl);
}
To copy to clipboard, switch view to plain text mode
This work well on Windows, I can see my port.
On Linux (Tested on Ubuntu 13.04 & Mint 15 Olivia ) : I can see my device with some name like : ttysUSB0, but any other informations like vendor id and product id are null. I can’t open a communication, open return false. I have all informations listed on my OS, so it’s a bug in my application.
On Mac (10.8.5) , I can’t even see the name and all others informations, but the device is connected to my Os as I can see him in the system info panel.
What did I do wrong ? Is it something to configure on Linux or Mac ?
Bookmarks