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
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
a) just run cd /sys/class/tty/
b) readlink ttyUSBn
will give you the full path of the device directory.
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.
Thank you, very thanks, your advice is very good， I have solved the problem.
check vendor and product id is good way
|All times are GMT -5. The time now is 09:01 AM.|