LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (http://www.linuxquestions.org/questions/linux-software-2/)
-   -   which ttyUSBx is mine? (http://www.linuxquestions.org/questions/linux-software-2/which-ttyusbx-is-mine-4175477380/)

dk_embed 09-16-2013 08: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 07: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
Code:

lsusb
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.

OR

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

briselec 09-19-2013 04: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 04:39 AM

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

dk_embed 09-26-2013 04:47 AM

THANK you
 
check vendor and product id is good way


All times are GMT -5. The time now is 03:59 AM.