USB Communication Using Qt
-
Thank you for the reply Florent.Revelut and Franzk.
Would be great if you could finally do that project you had in mind and document it. Then you can sell it to the unintelectuals like me ;)
-
Hi Candyman,
there can be found some source code based on Qt for serial connections. You will across a couple of derivatives obviously orginating from the same starting point.
"See for instance":http://qextserialport.sourceforge.net/
It can be used with USB-serial (PC-device). What the differences for USB-USB are, I am blank. Would be great to know, how to do it. -
Yes we use the usb-serial approach by way of an FT-245 convertor chip on the comms side of our devices. This just marshalls between usb and standard RS-232 comms which allows us to use qextserialport on /dev/ttyUSB0 or COM1 for e.g. Without such a chip, libusb is the way to go but Qt can still be used for other aspects of the application though.
-
On windows you refer to serial devices as \.\COM1, \.\COM2 etc. Which in C++ translates to
@
"\\.\COM1"
@when you escape all those backslashes.
-
Thanks ZapB
However, the serial com part is easy.
How does
@
"/dev/ttyUSB0"
@
translate on a windows system?
Is it
@"\\.\USB0"@ ? -
Could you not use QExtSerialPort to simply list the available ports, instead of guessing their names?
-
/dev/ttyUSB0 is simply the name that the kernel (or udev or whatever else you are using) assigns to serial over USB devices ie when using a usb-serial convertor. So when using this type of device under windows the corresponding device is COM1.
If you are not using a usb-serial convertor then you have to use the libusb functionality for communicating - that is you cannot simply use COM1 etc.
-
[quote author="Andre" date="1303983404"]Could you not use QExtSerialPort to simply list the available ports, instead of guessing their names?[/quote]
Not that I am aware off. Probably, you have to do it brute force by checking all com ports.
[quote author="ZapB" date="1303983794"]If you are not using a usb-serial convertor then you have to use the libusb functionality for communicating - that is you cannot simply use COM1 etc.[/quote]
That gives me something to chew on...
Thanks for your valuable responses
-
[quote author="koahnig" date="1303984402"]
[quote author="Andre" date="1303983404"]Could you not use QExtSerialPort to simply list the available ports, instead of guessing their names?[/quote]Not that I am aware off. Probably, you have to do it brute force by checking all com ports.
[/quote]
There is an enumerator in the source code: http://qextserialport.cvs.sourceforge.net/viewvc/qextserialport/qextserialport/
-
[quote author="Andre" date="1303985184"]
There is an enumerator in the source code: http://qextserialport.cvs.sourceforge.net/viewvc/qextserialport/qextserialport/
[/quote]you mean the enum on NamingConvention ?
I did not come across this yet. But it is nowherelse referenced. So it could be dead source. -
No, there is a device enumeration function in qextserialport that probes what serial devices you have available.
-
I mean this class: http://qextserialport.cvs.sourceforge.net/viewvc/qextserialport/qextserialport/qextserialenumerator.h?revision=1.3&view=markup
Sure, old code, and not in the docs, but the code is there...
-
BTW the sourceforge project is no longer active. The new home is "here":http://code.google.com/p/qextserialport/
-
Got it!
Thanks again. Will try to use it. Apperently, it was not part of the example I have come across. -
@Koahnig, if I don't come right with libusb I can fall back on serial to USB as you suggested. Tnx for the link to qextserport.
@ZapB, tnx for the info serial to USB converter chip. If required I will modify my hardware and go the serial route.
I will post here again on completion of the project with info on how to do it for others that might find it useful. -
OK. For info, the QStateMachine framework can be very handy for controlling hardware devices so it may be worth a look in you case. Good luck with your project.
-
@Candiman Thx for feedback. Good to know that it helped. Good luck with your project. Please make sure to post a link in this thread. I am interested to see the outcome.
@ZapB Thx for updated link. Wasn't aware of this. There seem to be a couple of derivatives of the source floating around. Actually I started out with one, but some things required reversal. So it is good to know where the original source code is. Have fun. -
@all
Hi, I have found this thread because I have a similar problem.
I have to communicate with a serial external device folowing a simple yet precise protocol. I have tried a fast test to develop the protocol using RXTCComm java library that works not so good and now I was searching for a Qt approach that is the final goal of the other side of the device.
I try to put all your advices together and see if a working stuff can be done. If it maybe useful I put the project on the project area so who is interested can follow. As the project is ready and setup it will be on projects.forum.nokia.com/mill-machine I will announce it on t the forum appropriate area and in the Qt embedded group.
Cheers.
Anticipating many thanks to all.
-
Great. Tnx Alicemirror.