LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-11-2011, 07:57 AM   #1
Simon_6162
Member
 
Registered: Jul 2004
Location: UK
Distribution: Fedora, Gentoo, Redhat Enterprise
Posts: 141

Rep: Reputation: 16
Help identifying a USB device


Hi,

I'm in the middle of making a PIC18 USB project that takes the microchip CDC library and an lirc config file to work as a USB based IR transmitter for RC5 remotes. When I attached the PIC18 running the CDC firmware the Linux kernel happily creates me a serial device which I can communicate over at /dev/ttyACM0, thanks to the cdc-acm.ko module. If I was to plugin a second such device it would be at /dev/ttyACM1 and so on.

My question is, how can I work out from /dev/ttyACM1 what the physical usb device is and read the produce id, version id and descriptor? If I look in dmesg I only get a new ttyACM is now available, it doesn't tell me the vendor id, product id and description.

I'm currently writing to /dev/ttyACM0 using python and pyserial, but i want to not hard code /dev/ttyACM0, and have it look at all serial devices and say which ones are acutally usb and then have a description which matches the one of my PIC. I can the usb info from lsusb, but this doesn't help me match up to a serial device.

This is possibly more of a kernel architecture question than programming but hopefully not to inappropriate.

Thanks

Simon
 
Old 08-11-2011, 08:56 AM   #2
macemoneta
Senior Member
 
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
Blog Entries: 2

Rep: Reputation: 344Reputation: 344Reputation: 344Reputation: 344
You can look in the /sys hierarchy. For example:

Code:
$ ls /sys/class/tty/ttyACM0/device/driver/
8-2:1.0  8-2:1.1  bind  module  new_id  remove_id  uevent  unbind

$ cat /sys/class/tty/ttyACM0/device/driver/8-2\:1.0/interface
Motorola Communication Interface

$ cat /sys/class/tty/ttyACM0/device/driver/8-2\:1.0/modalias 
usb:v22B8p4902d0001dc02dsc00dp00ic02isc02ip01
 
1 members found this post helpful.
Old 08-11-2011, 09:01 AM   #3
Simon_6162
Member
 
Registered: Jul 2004
Location: UK
Distribution: Fedora, Gentoo, Redhat Enterprise
Posts: 141

Original Poster
Rep: Reputation: 16
That looks like it will do the job, thanks allot.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
USB drive not working properly, read only device? (USB key storage device) Arodef Linux - Hardware 14 01-01-2010 07:32 AM
Identifying Block Device Linux_Kidd Linux - General 0 01-04-2007 07:26 PM
How to force kernel to use a USB 2.0-compatible device (ehci_hcd) as a USB 1.1 device eze Linux - Hardware 0 05-16-2006 05:24 AM
Need help identifying and mounting/unmounting USB drive. calathar Linux - Newbie 2 05-01-2005 03:50 AM
HP Deskjet (USB) & CUPS & Slackware 9.1: Unable to open USB device "usb:/dev/usb/lp0&qu arnostienen Slackware 2 01-29-2004 03:22 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:19 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration