LinuxQuestions.org
Support LQ: Use code LQCO20 and save 20% on CrossOver Office
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
LinkBack Search this Thread
Old 06-23-2008, 12:30 AM   #1
jbsp72
LQ Newbie
 
Registered: Jun 2008
Posts: 3

Rep: Reputation: 0
Question How to know which usb port usb device is connected to?


Hi,

The usb device I am working with doesnot have a serial no, so to uniquely identify I thought I may use the information of which port it is connected to , to uniquely identify it.

I found out all the usb ports are listed in /dev/input/by-path. On my machine I have four entries in this directory . How can I find out which usb port My usb device is connected to. Is there some API call or something which I can use. I have to do this from inside a c code.

Thanks
Shivu
 
Old 06-23-2008, 04:46 AM   #2
Swagata Paul
Member
 
Registered: Jun 2008
Location: Kolkata, India
Posts: 57

Rep: Reputation: 15
hi,

use the command "tail -f /var/log/messages"
plug the USB device to any usb port.
Wait & see the changes on the conmmand screen.
then,use the command "lsusb" to get the Bus & Device ID.

Repeat the operations by unplugging & plugging the device to another port.
 
Old 06-23-2008, 05:08 AM   #3
jbsp72
LQ Newbie
 
Registered: Jun 2008
Posts: 3

Original Poster
Rep: Reputation: 0
I need to know the port no programatically I guess I can get it by parsing the /proc/bus/usb/devices file but is their no better way like a API or something

Thanks
Shivu
 
Old 03-04-2010, 01:02 AM   #4
greenberet
Member
 
Registered: Jun 2006
Posts: 50

Rep: Reputation: 15
Hey,

I have the same problem. I need to know the port to which my usb drive is conncted. But, it seems that the bus ID and the device ID are not constant but keep changing depending on the pen-drive. Thus, they are not unique to the port.

Here is the output of /var/log/messages, when i plug in two different drives, one 128 MB and one 512 MB, into the same port.


Mar 4 08:19:18 localhost kernel: usb 3-1: new full speed USB device using uhci_hcd and address 6
Mar 4 08:19:18 localhost kernel: usb 3-1: New USB device found, idVendor=09a6, idProduct=8001
Mar 4 08:19:18 localhost kernel: usb 3-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
Mar 4 08:19:18 localhost kernel: usb 3-1: configuration #1 chosen from 1 choice
Mar 4 08:19:18 localhost kernel: scsi18 : SCSI emulation for USB Mass Storage devices
Mar 4 08:19:23 localhost kernel: scsi 18:0:0:0: Direct-Access USB 2.0 Flash Disk 1.06 PQ: 0 ANSI: 0 CCS
Mar 4 08:19:23 localhost kernel: sd 18:0:0:0: Attached scsi generic sg3 type 0
Mar 4 08:19:23 localhost kernel: sd 18:0:0:0: [sdc] 260320 512-byte logical blocks: (133 MB/127 MiB)
Mar 4 08:19:23 localhost kernel: sd 18:0:0:0: [sdc] Write Protect is off
Mar 4 08:19:23 localhost kernel: sd 18:0:0:0: [sdc] Assuming drive cache: write through
Mar 4 08:19:23 localhost kernel: sd 18:0:0:0: [sdc] Assuming drive cache: write through
Mar 4 08:19:23 localhost kernel: sdc: sdc1
Mar 4 08:19:23 localhost kernel: sdc: p1 size 260320 exceeds device capacity, limited to end of disk
Mar 4 08:19:23 localhost kernel: sd 18:0:0:0: [sdc] Assuming drive cache: write through
Mar 4 08:19:23 localhost kernel: sd 18:0:0:0: [sdc] Attached SCSI removable disk
Mar 4 08:19:52 localhost kernel: usb 3-1: USB disconnect, address 6
Mar 4 08:20:10 localhost kernel: usb 1-3: new high speed USB device using ehci_hcd and address 19
Mar 4 08:20:10 localhost kernel: usb 1-3: New USB device found, idVendor=0ea0, idProduct=2168
Mar 4 08:20:10 localhost kernel: usb 1-3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
Mar 4 08:20:10 localhost kernel: usb 1-3: Product: Flash Disk
Mar 4 08:20:10 localhost kernel: usb 1-3: Manufacturer: USB
Mar 4 08:20:10 localhost kernel: usb 1-3: SerialNumber: 611041FD6E02003C
Mar 4 08:20:10 localhost kernel: usb 1-3: configuration #1 chosen from 1 choice
Mar 4 08:20:10 localhost kernel: scsi19 : SCSI emulation for USB Mass Storage devices
Mar 4 08:20:15 localhost kernel: scsi 19:0:0:0: Direct-Access JetFlash TS512MJF2B 2.00 PQ: 0 ANSI: 2
Mar 4 08:20:15 localhost kernel: sd 19:0:0:0: Attached scsi generic sg3 type 0
Mar 4 08:20:16 localhost kernel: ready
Mar 4 08:20:16 localhost kernel: sd 19:0:0:0: [sdc] 1022720 512-byte logical blocks: (523 MB/499 MiB)
Mar 4 08:20:16 localhost kernel: sd 19:0:0:0: [sdc] Write Protect is off
Mar 4 08:20:16 localhost kernel: sd 19:0:0:0: [sdc] Assuming drive cache: write through
Mar 4 08:20:16 localhost kernel: sd 19:0:0:0: [sdc] Assuming drive cache: write through
Mar 4 08:20:16 localhost kernel: sdc: sdc1
Mar 4 08:20:16 localhost kernel: sd 19:0:0:0: [sdc] Assuming drive cache: write through
Mar 4 08:20:16 localhost kernel: sd 19:0:0:0: [sdc] Attached SCSI removable disk
Mar 4 08:22:00 localhost kernel: usb 1-3: USB disconnect, address 19


Please tell me how to identify that these two devices have been connected to the same port.

Thanks,
 
Old 05-22-2012, 11:21 AM   #5
nwazsohail
LQ Newbie
 
Registered: Apr 2012
Posts: 5

Rep: Reputation: Disabled
use following command

cdrecrod --scanbus
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are On
Refbacks are 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
Printing Problem with Epson Stylus Color 440 connected to usb port entm Linux - Hardware 1 07-16-2007 06:16 AM
cannot find usb port of my connected printer nocturna_gr Debian 1 08-10-2006 07:29 AM
Installing Linux on External hard drive connected by USB port omidiora Linux - Newbie 1 04-29-2006 09:51 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


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

Main Menu
 
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
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration