How to find which device is attached to a USB-serial port in Linux using C? -


we making device , has 8 serial ports. runs on monta vista pro5 kernel. , working in c.

suppose: device gets attached ttyusb0, ttyusb1 , ttyusb2. next device gets connected ttyusb3 , ttyusb4. how can know device gets attached port ?? ie ttyusb0 or ttyusb1 or on. there way directly query device , find port attached to. or, in c, open ttyusb0, query somehow , reply device ??

a rather complicated way: stat of, /dev/ttyusb0. device number. , search in /proc/bus/usb/devices , find vendor id or identify device.

or: there way reserve ttyusb0,ttyusb1 , ttyusb2 1 device, ttyusb3 , on when plugged in ? way know device connected port.

help please..... :)

thanks in advance. nubin stanley

you can use udev rules create symbolic links device:

(these rules go in /etc/udev/rules.d/-name.rules -- @ udev documentation

kernel=="ttyusb*", attrs{idvendor}=="<vendorid>", mode="0666", symlink+="mydev" 

you have specify vendor id and/or product id device. devices available @ /dev/mydev in above example.

you can use various other parameters create appropriate unique symbolic links use. check udev man page.


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -