USB communication in Qt
-
hi,
I searched official documentation for USB in Qt and read questions on this forum but no documentation. I want to Send and Receive data from USB of Raspberry pi And USB of Windows PC. I also ran across some web pages like github and typed "" QT += usb "" in project file and i got " Project ERROR: Unknown module(s) in QT: usb ". there should be a better way to achieve this communication. -
@Andrex_Qt said in USB communication in Qt:
Project ERROR: Unknown module(s) in QT: usb
Did you build and install that project from GitHub first?
Also, it is not clear what kind of USB communication you mean. -
@Andrex_Qt said in USB communication in Qt:
serially
Do you mean serial port? For that there is https://doc.qt.io/qt-5/qtserialport-index.html
"I did and it didnt work" - you should say what exactly did not work.
-
@jsulm
ok
I tried to install following as i am using ubuntu and cros-compilling it
sudo add-apt-repository ppa:fpoussin/ppa
sudo apt install libqt5usb5 libqt5usb5-dev
for libqt5usb5 and libqt5usb5-dev i get "unable to locate package".
And I want to send data over searially using USB to USB data cable from RPi to PC. -
@Andrex_Qt If you're cross compiling then installing Qt packages on your Ubuntu host machine will not help you. You need a sysroot for your target device. Then you cross compile Qt and then the project from GitHub.
And as I said: if you want serial communication then use https://doc.qt.io/qt-5/qtserialport-index.html
-
@Andrex_Qt said in USB communication in Qt:
sudo add-apt-repository ppa:fpoussin/ppa
sudo apt install libqt5usb5 libqt5usb5-devThese actions will install a pre-built USB module into the machine where you run such commands. As you mentioned you're cross-compiling please be aware that (also mentioned in another reply) installing the library in the host PC won't help you. And I doubt such pre-built library is available for ARM...
So it leads you to cross-compiling the module on your own. Please follow the steps from github and be aware that libusb-1.0-0-dev and pkg-config packages should be installed in RPi device and then rsync to the host PC before cross-compiling.
Once you succeed installing the module, you need to rsync again from host PC to RPi so the module is available in the device.
Also check the examples from Qt USB module for further reference.
-
@Andrex_Qt said in USB communication in Qt:
I want to Send and Receive data from USB of Raspberry pi And USB of Windows PC.
I'm think, it is not possible. AFAIK, the USB specification declares the 'master-slave' approach. I.e. a master is a host, and a slave is a device (or other think).
So, from your case you need to configure your RPi as a OTG device - it will be a slave (seems a linux allows to do it), and the Windows PC will be as a host. So, only a host will send a requests to the slave. I want to say, that I'm not sure that a libusb (or other xxx_usb library) will help you due to specific of a USB bus.
I'm think that a simplest way is to configure your RPi as a Serial/Gadget device . In this case, from the RPi side you will work with a "virtual" serial port (e.g. ttyGS0). From the Windows PC you will work with a serial ports too (when you will connect the RPi to the PC, than your RPi will be detected as a serial port in Windows device manager).
But, I'm never tried this.