View topic - How to get device path and mount path using usbdi callbacks

How to get device path and mount path using usbdi callbacks

anything that doesn't fit to other groups.

How to get device path and mount path using usbdi callbacks

Postby selva » Fri May 17, 2019 8:41 am

Hi,

I am in the progress of implementing a service which will detect usb plugin/removal using usbdi callback functions. Callback function has a parameter "usbd_device_instance_t * usbInstance" from which i can get device vendor id,product id and the device class information. But how do i get a mount point in case of a mass storage device and a device path in case of a HID device?
selva
New Member
 
Posts: 7
Joined: Wed Apr 17, 2019 6:20 am

Re: How to get device path and mount path using usbdi callba

Postby nico04 » Fri May 17, 2019 12:44 pm

Hi,

You can't get mount point or device path from usbdi API.
This is because USB DDK is not aware of these informations.

Depending on your OS version, you can use usblauncher to get device information through PPS.

notes :
- USB DDK API : http://www.qnx.com/developers/docs/6.4.1/ddk_en/usb/
- usblauncher : http://www.qnx.com/developers/docs/6.6. ... ncher.html
nico04
Senior Member
 
Posts: 142
Joined: Wed Sep 29, 2010 9:59 am
Location: France

Re: How to get device path and mount path using usbdi callba

Postby selva » Mon May 20, 2019 5:48 am

Thank you for your response. Is there any other way to do that without using usb_launcher service?
selva
New Member
 
Posts: 7
Joined: Wed Apr 17, 2019 6:20 am

Re: How to get device path and mount path using usbdi callba

Postby nico04 » Mon May 20, 2019 7:04 am

usblauncher does more than publishing information. It also manages the plug&play when USB devices are connected.
The rules file associated with USB launcher allows to launch a specific driver with/without specific options when a USB device is connected.
That's the case for mass storage.

For HID devices, this is different. io-hid is in charge of their management. io-hid connects to the USB stack.
However, some HID devices are still managed by usb-launcher to launch a specific driver (iPod).

How are the USB devices mounted in your system ?
nico04
Senior Member
 
Posts: 142
Joined: Wed Sep 29, 2010 9:59 am
Location: France

Re: How to get device path and mount path using usbdi callba

Postby selva » Mon May 20, 2019 7:22 am

Yes. In my case, my application should handle all the USB Devices plugin/removal activities (which you described that usb launcher and io-hid takes care in qnx). My application should take the control over all the USB devices attached to the system(USB detection, loading a driver, mounting usb mass storage, etc). Is it possible to do all those things?
selva
New Member
 
Posts: 7
Joined: Wed Apr 17, 2019 6:20 am

Re: How to get device path and mount path using usbdi callba

Postby nico04 » Mon May 20, 2019 7:43 am

Why not using usblauncher ?
nico04
Senior Member
 
Posts: 142
Joined: Wed Sep 29, 2010 9:59 am
Location: France

Re: How to get device path and mount path using usbdi callba

Postby selva » Thu May 23, 2019 7:26 am

In case of using usb launcher, How to identify the device object of the device connected? is it requires directory scanning ?
selva
New Member
 
Posts: 7
Joined: Wed Apr 17, 2019 6:20 am

Re: How to get device path and mount path using usbdi callba

Postby nico04 » Thu May 23, 2019 8:18 am

PPS files are created/removed dynamically when connecting/unconnecting USB devices.
nico04
Senior Member
 
Posts: 142
Joined: Wed Sep 29, 2010 9:59 am
Location: France

Re: How to get device path and mount path using usbdi callba

Postby nico04 » Thu May 23, 2019 8:31 am

You can subscribe to a PPS directory.
With
Code: Select all
fd_usb_device = open("/pps/qnx/device/.all?wait,delta", O_RDONLY);
your code gets notified when a device is connected/unconnected.

When reading the opened file, you immediately receive :
Code: Select all
@usb_ctrl


When a device is connected, you get (just an example) :
Code: Select all
+@usb-0.2
@usb-0.2
bus::USB
busno::0x00
devno::0x02
vendor_id::0xXXX
product_id::0xXXX
configurations::1
configuration::1
device_class::0xef
device_subclass::0x02
device_protocol::0x01
max_packet_size0::64
manufacturer::XXXXXXXXXX
product::XXXXXXXXXX
upstream_device_address::1
upstream_host_controller::0
upstream_port::3
upstream_port_speed::Full
topology::(1,3),(0,1)
drivers_matched::0
drivers_running::0


When the device is unconnected, you get :
Code: Select all
*@usb-0.2
-@usb-0.2


You can try with
Code: Select all
cat /pps/qnx/device/.all?wait,delta
in a terminal (while usblauncher is running).
nico04
Senior Member
 
Posts: 142
Joined: Wed Sep 29, 2010 9:59 am
Location: France

Re: How to get device path and mount path using usbdi callba

Postby selva » Thu May 23, 2019 9:37 am

This one Makes sense. One more idea stroked in my mind. Is it possible to identify the device object of the connected/disconnected device with the details returned by usbdi callback function?
selva
New Member
 
Posts: 7
Joined: Wed Apr 17, 2019 6:20 am

Re: How to get device path and mount path using usbdi callba

Postby nico04 » Thu May 23, 2019 11:17 am

When USB devices are connected, other files are published in other directories.

An example, with a mass storage device :

/ #cat /pps/qnx/device/usb-0.2
[n]@usb-0.2
bus::USB
busno::0x00
configuration::1
configurations::1
device_class::0x00
devno::0x02
drivers_matched::1
drivers_running::1
max_packet_size0::64
product::USB Mass Storage Device
product_id::0xba01
serial_number::03AD0000000471
topology::(1,3),(0,1)
upstream_device_address::1
upstream_host_controller::0
upstream_port::3
upstream_port_speed::High
vendor_id::0x4146

/ #cat /pps/qnx/driver/1536016
[n]@1536016
PPS_DEVICE_ID::/pps/qnx/device/usb-0.2
arguments::cam quiet blk cache=1m,vnode=384,auto=none,delwri=2:2,rmvto=none,noatime disk name=hd_usb cdrom name=cd_usb umass priority=21,vid=0x4146,did=0xba01,bu
sno=0,devno=0x2,iface=0,ign_remove
interface::0
interface_class::0x08
interface_protocol::0x50
interface_subclass::0x06
name::devb-umass
pid::1536016

/ #cat /pps/qnx/mount/hd_usb0
[n]@hd_usb0
PPS_DRIVER_ID::/pps/qnx/driver/1536016
blocks_size::512
blocks_total::8323072
mnt_status::0 (No error)
partition_count::1
raw::/dev/hd_usb0

/ #cat /pps/qnx/mount/hd_usb0.0
[n]@hd_usb0.0
PPS_DRIVER_ID::/pps/qnx/driver/1536016
PPS_RAWMOUNT_ID::/pps/qnx/mount/hd_usb0
blocks_size::512
blocks_total::511968
fs_type::dos (fat32)
label::TEST
mnt_status::0 (No error)
mount::/mnt/usb0
partition::/dev/hd_usb0t11
partition_order::0
raw::/dev/hd_usb0
read_only::0
nico04
Senior Member
 
Posts: 142
Joined: Wed Sep 29, 2010 9:59 am
Location: France

Re: How to get device path and mount path using usbdi callba

Postby selva » Mon Jun 03, 2019 12:12 pm

How to identify the PID of the device object? so that i will be able identify the driver object belongs to the device object. How the device object, driver object and mount objects are related? Is there any way to identify the driver object and mount object of a device object without reading each file inside it?
selva
New Member
 
Posts: 7
Joined: Wed Apr 17, 2019 6:20 am


Return to General Programming

Who is online

Users browsing this forum: No registered users and 3 guests