1

Good evening, my project is to create a desktop application. This application will allow me to communicate from the PC to an stm32 microcontroller via the usb port.

I use the class: QSerialPort available on Qt

I want to know the number of USB port connected on my PC.

Here is my code:

#include <QCoreApplication>
#include <QDebug>
#include <QSerialPort>
#include <QSerialPortInfo>


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

    QDebug () << "Number of serial ports:" << QSerialPortInfo :: availablePorts (). Count ();

Return 0;
}    

So I plugged my microcontroller stm32f4, an external hard drive with a usb cable ... My problem is this: When I run the program under Qt there is no compilation problem but the result of the debug shows me the following line: "Number of serial ports: 0" Usb ports connected.

Following the activation of bluetooth or the insertion of a 3g key there is detection of these ports, but the others remain undetected.

I didn't understand where the mistake comes from !!

hyde
  • 60,639
  • 21
  • 115
  • 176
oumaima
  • 21
  • 4

1 Answers1

0

Qt only has native support for USB Serial ports. (eg: COM/TTY)

If you want to know low level details (eg: physical port number) of the USB port the STM is connected to, you have to use platform specific code.

Libusb can help you with that.

Jeroen3
  • 919
  • 5
  • 20
  • I thought of trying the example of STM32 Virtual Com Port to see if the card will be detected as a COM port. For that I followed this video: https://youtube.com/watch?v=Dy8CcO5i42Y .But it remains detected as USB in the device manager and the problem persists. – oumaima Apr 12 '17 at 18:55
  • It will be both seen as "USB" device, and if correct drivers are installed also under "Ports (COM & LPT)". I recommend you reinstall ST's virtual com drivers. – Jeroen3 Apr 16 '17 at 15:59