December 23, 2010

stuk stuk
Ant Farmer
545 posts

Serial port number in windows

Page  
1

Hi, there is a way (library or api) to get a com port number of a device connect on a computer?
Everytime i connect some device i get to open the control panel, i want get this information quickly.
Thank’s.

27 replies

December 23, 2010

Andre Andre
Robot Herder
6295 posts

There is no such API in Qt.

 Signature 

Looking for Qt developers to join our team @ i-Optics: https://qt-project.org/forums/viewthread/25393/

December 23, 2010

stuk stuk
Ant Farmer
545 posts

I know but i’m post on a group Qt Windows, maybe some user can know the problem and a possible solution.

Andre wrote:
There is no such API in Qt.

December 23, 2010

Immii Immii
Lab Rat
239 posts

My colleagues uses serial port and they use QextSerialPort [qextserialport.sourceforge.net], have look of this, this may help

December 23, 2010

stuk stuk
Ant Farmer
545 posts

I just know, my problem is not to use serial, but know what com port number the os assign to a device.

Immii wrote:
My colleagues uses serial port and they use QextSerialPort [qextserialport.sourceforge.net], have look of this, this may help

December 23, 2010

Andre Andre
Robot Herder
6295 posts

Judging by your wording, I guess you’re talking about USB devices that act as a serial device? Or are you talking about real serial ports on your system?

I just did a bit of Googling [google.nl], and it already turned up some starting points, like the third hit [google.nl] on that query. This is really Windows specific, though it would be nice to have a Qt-like API to get these kinds of notifications in a platform independent way. In KDE, I guess it would be in Solid. Perhaps the Windows port of that part of the KDE project contains the code you need?

 Signature 

Looking for Qt developers to join our team @ i-Optics: https://qt-project.org/forums/viewthread/25393/

December 23, 2010

stuk stuk
Ant Farmer
545 posts

I need know what the com port is assignet to a serial-usb adapter, because every time that i insert a device i always go to control panel, i want create a program to quickly get this information.
After much time of googling i see this link [naughter.com] , but is hard to port on a mingw, i lost many headers.
But i think there aren’t much way to do this. And yes is very useful if this can be cross-platform. But for unix a simple dmesg can resolve this :P

Andre wrote:
Judging by your wording, I guess you’re talking about USB devices that act as a serial device? Or are you talking about real serial ports on your system?

I just did a bit of Googling [google.nl], and it already turned up some starting points, like the third hit [google.nl] on that query. This is really Windows specific, though it would be nice to have a Qt-like API to get these kinds of notifications in a platform independent way. In KDE, I guess it would be in Solid. Perhaps the Windows port of that part of the KDE project contains the code you need?

December 23, 2010

Andre Andre
Robot Herder
6295 posts

Looks like an interesting project. If anything, it shows that Windows is a bit of a mess if you need to try 9 ways to actually get all the serial ports. If it is hard to use with MinGw, then why not use it with MSVC instead? You could make it a small, separate process that just communicates the data to your main application when needed. You can use any IPC mechanism you want for that, including just outputting the data over the stdout and reading that with QProcess.

Still, you could try and see if the simple way of reading out the registry would be enough in your case? You can use QSettings for that…

 Signature 

Looking for Qt developers to join our team @ i-Optics: https://qt-project.org/forums/viewthread/25393/

December 23, 2010

gronerth gronerth
Lab Rat
76 posts

You can do with QextSerialPort. Example code:

  1. QList<QextPortInfo> ports = QextSerialEnumerator::getPorts();
  2.     qDebug() << "SerialSettings::LoadPorts(): List of ports availables:\n";
  3.     for (int i = 0; i < ports.size(); i++) {
  4.             qDebug() << "port name: " << ports.at(i).portName;
  5.             qDebug() << "friendly name: " << ports.at(i).friendName;
  6.             qDebug() << "physical name: " << ports.at(i).physName;
  7.             qDebug() << "enumerator name: " << ports.at(i).enumName;
  8.             qDebug() << "===================================";
  9.       }

 Signature 

——————————
JETG

December 27, 2010

stuk stuk
Ant Farmer
545 posts

What is it?!?
When this function was added to the project?!?
QextSerialEnumerator?!? QextPortInfo?!?

gronerth wrote:
You can do with QextSerialPort. Example code:

@QList<QextPortInfo> ports = QextSerialEnumerator::getPorts(); qDebug() << “SerialSettings::LoadPorts(): List of ports availables:\n”; for (int i = 0; i < ports.size(); i++) { qDebug() << “port name: “ << ports.at(i).portName; qDebug() << “friendly name: “ << ports.at(i).friendName; qDebug() << “physical name: “ << ports.at(i).physName; qDebug() << “enumerator name: “ << ports.at(i).enumName; qDebug() << “===================================”; }
@

December 27, 2010

Vass Vass
Ant Farmer
740 posts

This methods of this library: QExtSerialPort [qextserialport.sourceforge.net]

 Signature 


Vasiliy

December 27, 2010

Andre Andre
Robot Herder
6295 posts

It might just be me, but I don’t see the classes mentioned in the code fragment in the documentation linked from the page you give. I am looking at http://qextserialport.sourceforge.net/qextserialport-1.1.x/

Is this new API? Newer than the latest API docs on the webpage?

 Signature 

Looking for Qt developers to join our team @ i-Optics: https://qt-project.org/forums/viewthread/25393/

December 27, 2010

stuk stuk
Ant Farmer
545 posts

This API is very strange!

Look this http://code.google.com/p/qextserialport/source/browse/#hg/src [code.google.com]

December 27, 2010

gronerth gronerth
Lab Rat
76 posts

The api version that i have downloaded is: qextserialport-1.2win-alpha (win version), you can download from here: http://sourceforge.net/projects/qextserialport/files/qextserialport alpha/

 Signature 

——————————
JETG

December 27, 2010

stuk stuk
Ant Farmer
545 posts

This is a new alpha API, that include enumerator :) Great news!

gronerth wrote:
The api version that i have downloaded is: qextserialport-1.2win-alpha (win version), you can download from here: http://sourceforge.net/projects/qextserialport/files/qextserialport alpha/

December 27, 2010

gronerth gronerth
Lab Rat
76 posts

Yeap, hope that works for your app!

 Signature 

——————————
JETG

Page  
1

  ‹‹ slot in inherited class is not working...      Is it possible to find a sample to know how to use Qt to have a line-chart based on a set of data? ››

You must log in to post a reply. Not a member yet? Register here!