-   Linux - Software (
-   -   which ttyUSBx is mine? (

dk_embed 09-16-2013 09:43 PM

which ttyUSBx is mine?
the direction /dev/ has three ttyUSB, i know the ttyUSB1 is mine, but software dosen't know, so write demo use polling model detect ttyUSB, for every device use open(),write(), read(), when demo read ack from ttyUSB and think this is my device, but i think this model affect other programe, so if you has good way, please help me. very thank you

eklavya 09-17-2013 08:09 AM

Have you checked sys?
1)Go to cd /sys/devices
2) If we find the directory of the ports: find -name "ttyUSB1". It will probably find them in something like ./pci0000:00/0000:00:1d.0/usb2/2-2/2-2.1/2-2.1:1.0/...
The pci* part is the USB controller. The interesting bit is the 2-2.1 which is the USB device.

If you want to differentiate different USB devices, you can differentiate them using their vendor id and product id.

Every usb device has it's unique vendor id and product id.
You can detect it easily using command

Now it will show the id in terms of something like ID 045e:00cb for every usb device, In this example 045e is vendor ID and 00cb is productid.


a) just run cd /sys/class/tty/
b) readlink ttyUSBn
will give you the full path of the device directory.

briselec 09-19-2013 05:15 AM

You can add a udev rule that creates a symlink to your device when it is plugged in so no matter which tty it's assigned you can access it by the symlink.

dk_embed 09-26-2013 05:39 AM

Thank you
Thank you, very thanks, your advice is very good, I have solved the problem.

dk_embed 09-26-2013 05:47 AM

check vendor and product id is good way

All times are GMT -5. The time now is 03:40 PM.