PDA

View Full Version : Notification to the Qt application while USB plug/unplug



sreeram
16th July 2013, 07:29
Hi All,

I am working with Qt application handling usb devices on LInux os(3.1.0 kernel version) . I am able to interact with USB devices using Qt application with Libusb. But i am not able to communicate with usb device which is connected while Qt application is running(USB Hotplug).For interacting with new devices I am calling libusb api in every function then my application is able to communicate with new enumerated usb device also.

Is there any other way to call it (libusb API ) while usb connecting and removing(when Qt application got notification ) instead of calling before every operation.

Thanks & Regards
Sreeram

sreeram
16th July 2013, 12:13
Hi

Any idea anyone ????


Thanks
Sreeram

sreeram
18th July 2013, 12:11
Hi All

Finally I have found some solution from internet regarding usb hotplug in Qt application.

Code qdbus using udev:
--------------------------------------
QDBusConnection :: systemBus (). Connect (
"Org.freedesktop.UDisks"
"/ Org / freedesktop / UDisks",
"Org.freedesktop.UDisks"
"DeviceAdded"
this, SLOT (deviceAdded (QDBusObjectPath));

This I got from follwing link but I am not sure this will solve my qt application hotplug problem.

http://idevlife.com/177851/

If any one has idea on this QDbus please clarify How this function works in qt application, Then i can impliment this function in my qt application.

I have two questios on this function->

1.How this Qdbusconnection giving signal to Qt application when the usb device is plug/unplug
2.To get usb plug/unplug notification we have to call this function or it will run call automaticall while usb plug or unplug.

Please clarify to me above two questions then i can use code directly to my qt application.

Thanks & Regards
Sreeram

anda_skoa
20th July 2013, 19:25
First, your initial question did not contain enough information for anyone to help you without wildly guessing
Second, you complained about not getting a response within not even 5 hours of your first posting. That alone will make a lot of people just ignore you.

Regarding the solution you found on the internet:
QtDBus is a module in Qt that allows Qt programs to interact with the D-Bus message passing system. On Linux this is used for communication between processes of the same user session (so called session bus) and between system services and end user programs (so called system bus).

The example you have is a usage of the second type, e.g. the program interacting with the UDev system service.

The UDev system service seems to have a D-Bus API that emits a signal when a new device is attached. Using QtDBus you can map this signal to a Qt signal or, as in your example, connect it to a Qt slot.

Cheers,
_