Look-up USB mounting point

Hi all,

I'm developing a short program to look-up for all devices connected to the computer. Using udev and libusb libraries I achieved some progress but I can not find the way to find the mount point.

For instance, given a device that I can retrieve using libusb, I would like to know where it is mounted so I can pass this information to another function to connect to the port.

Thanks in advance,

Carles.

As USB is a hot pluggable _port_ then it is not possible to code for it as a permanent event.

Example...

/dev/ttyUSB0 exists and is up and running and you are in connection with an external device. Some clown comes along and trips over the cable pulling it out whilst in mid flight.

What does your detection code then do?

It says that the _port_ is in use, one of a possible 127 USB devices, but in reality connectivity has been broken...

You can ONLY use your idea IF and only IF you can guarantee no external event to create a _crash_.

Also things occur when you plug your item(s) in AFTER running a language like say Python running from a shell...

It probably will NOT be seen by Python although the shell might see it...

So be very careful before creating auto-detect scripts on dynamic _port_(s)...

Bazza...

Hi Wisecracker,

The thing is as follows:

My program starts and checks where the devices have been mapped.
I know the devices have been plugged but what I don't know is what name do they get.
Using the libusb library I can confirm they are plugged but I still don't know whether they are /dev/ttyUSB0 or /dev/ttyUSB1 or ...

It must be possible to retrieve what is the mount point from C++.

Thanks again,

Carles.

Again be very careful.

/dev/ttyACM0 is also a USB device...

Apple OSX, (at least from 10.7.5), has its own brand of naming USB devices...

I am assuming you are using a Linux flavour...

You could try before any plug(g)able devices are attached:-

ls /dev > /path/to/devcies.txt

Plug the USB items in, allow a couple of seconds to settle, then:-

ls /dev > /path/to/newdevices.txt

Then compare the two files...

Crude I know, but a simple way...

As I said before you can ONLY do this IF and only IF you can guarantee _permanent_ connectivity...

mount will tell you mountpoints.