LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Hardware (http://www.linuxquestions.org/questions/linux-hardware-18/)
-   -   How to find bus/path address for a USB device (http://www.linuxquestions.org/questions/linux-hardware-18/how-to-find-bus-path-address-for-a-usb-device-4175453753/)

Mikko Lehtinen 03-12-2013 07:15 AM

How to find bus/path address for a USB device
 
Hello!

I'm reposting this on a different forum and with a better subject line. (I received no answers on the Desktop forum, which wasn't the best place for this question.)

I'm a happy user of Slackware 14 and Thinkpad X200.

I recently purchaced a Thinkpad USB Keyboard with Trackpoint. I'm used to a much more sensitive trackpoint. The trackpoint on the external keyboard is much trickier to configure than the one on X200.

This thread explains how to do it. The first poster has written a tiny Python script for changing sensitivity.

The problem is, before running the script you need to unbind the usb device like this, and after the script to bind it again.

Code:

echo XXX > /sys/bus/usb/drivers/usbhid/unbind
python2 trackpoint-script.py
echo XXX > /sys/bus/usb/drivers/usbhid/bind

You're supposed to replace XXX with the device's bus/path name, such as 2-1.6.4:1.1. (As explained later in the thread.)

Even with the help offered in the thread, I just don't get it. How do I find out my device's bus/path name?

With the command lsusb my device identifies like this
Code:

Bus 001 Device 004: ID 17ef:6009 Lenovo ThinkPad Keyboard with TrackPoint

(Luckily it's the newer version of the keyboard, so the script is supposed to work well with it.)

david1941 03-12-2013 07:53 AM

Here's the way I find my ancient scanner:
Code:

#!/bin/bash
# Scans and prints image to printer.
# Leaves pdf file of scanned image in ./scanned.pdf
# D. R. Forrest 5/19/04
# revised 6/26/05 to leave .jpg file intact
#        7/19/05 cheanged jpg to pdf
#        10/1/07 revised for FC7
#        1/18/13 revised for Centos 6
#        4/6/08  added bw option for bw printer

[ "--help" = "$1" ] && echo -e "Usage: scan [bw|no|--help] (Defaults to color print)" && exit

# Determine scanning device - Epson Perfection 640U attached (we hope)
DEVBUS=$(/usr/bin/lsusb |grep Epson|cut -d " " -f2)
DEVDEV=$(/usr/bin/lsusb |grep Epson|cut -d " " -f4)
DEVDEV=$(echo $DEVDEV |sed s/://)
SANE_DEFAULT_DEVICE="epson:libusb:$DEVBUS:$DEVDEV"
[ -z "$DEVDEV" ] && SANE_DEFAULT_DEVICE=""
# The above discovers the usb device.  If power has cycled on the scanner,
# the usb port changes, therefore using the environment doesn't always work.

[ -n $SANE_DEFAULT_DEVICE ] || (echo "Cannot find the scanner!" && exit 1)

PRINTDEST=$(grep -v '^#' /etc/printcap | cut -d "|" -f1)  # Default is system printer
[ "bw" = "$1" ] && PRINTDEST=$PRINTER  # Alternate b/w printer
[ "no" = "$1" ] && PRINTDEST=""

echo ".....scanning on $SANE_DEFAULT_DEVICE - please wait"

scanimage -d $SANE_DEFAULT_DEVICE -v --mode Color --format  tiff  > /home/drf/scanned.tif
echo -e "\nConverting to printable Postscript......."
convert -page letter+0+0 /home/drf/scanned.tif /home/drf/scanned.ps 2>/dev/null
echo
[ -n "$PRINTDEST" ] && echo "Scanned page sent to printer ($PRINTDEST)"
echo "To print copies enter: lpr /home/drf/scanned.pdf"
[ -n "$PRINTDEST" ] && lpr -P $PRINTDEST /home/drf/scanned.ps
ps2pdf /home/drf/scanned.ps /home/drf/scanned.pdf
rm scanned.ps
echo
echo "Saved image files are: /home/drf/scanned.[pdf|tif]"
exit 0

This still works in Centos 6.3

TobiSGD 03-12-2013 10:21 AM

Quote:

Originally Posted by Mikko Lehtinen (Post 4909865)
Hello!

I'm reposting this on a different forum and with a better subject line. (I received no answers on the Desktop forum, which wasn't the best place for this question.)

If you want a thread to be moved or a title to be modified please ask a moderator to do that for you, using the report button. Do not repost yourself on a different forum, this is violating the LQ Rules and generally frowned upon.

Mikko Lehtinen 03-13-2013 05:13 AM

Thanks, david1941! Looking at that script inspired me to find out the answer. And the script just might help me with another problem, getting my Epson Perfection V30 to work with Slackware...

I googled up a very helpful article on lwn.net about manual driver binding and unbinding. This is how I found the bus address:

Code:

#tree /sys/bus/usb/drivers/usbhid
/sys/bus/usb/drivers/usbhid
├── 1-5.3:1.0 -> ../../../../devices/pci0000:00/0000:00:1a.7/usb1/1-5/1-5.3/1-5.3:1.0
├── 1-5.3:1.1 -> ../../../../devices/pci0000:00/0000:00:1a.7/usb1/1-5/1-5.3/1-5.3:1.1
├── bind
├── module -> ../../../../module/usbhid
├── new_id
├── remove_id
├── uevent
└── unbind

The right choice was 1-5.3:1.1

Quote:

Originally Posted by TobiSGD (Post 4909987)
If you want a thread to be moved or a title to be modified please ask a moderator to do that for you, using the report button. Do not repost yourself on a different forum, this is violating the LQ Rules and generally frowned upon.

Thanks for the info. I had no idea that Report button could be used for that. "Report" sounds scary, I only associated it with reporting spam or inappropriate behavior.

aolney 06-23-2013 10:56 AM

follow up
 
Confirmed working, some notes

1. Get usb device name (the 2nd id, as above, e.g. 1-5.3:1.1)

sudo apt-get install tree
tree /sys/bus/usb/drivers/usbhid

2. Create script with that name substituted for these XXX

echo XXX > /sys/bus/usb/drivers/usbhid/unbind
python2 trackpoint-script.py
echo XXX > /sys/bus/usb/drivers/usbhid/bind

3. Install python libraries

sudo apt-get install libusb-1.0-0
See pyusb installation instructions at github com walac pyusb

4. Create the 2nd script, trackpoint-script.py

#pyusb imports
import usb.core
import usb.util

data = [0x4, 0x6a, 0x3, 0xfc, 0x38]
dev = usb.core.find(idVendor=0x17ef, idProduct=0x6009)
dev.ctrl_transfer(0x21, 0x9, 0x304, 0x1, data)

This is fantastic on my setup, many thanks.

Linux monkamu 3.2.0-48-generic #74-Ubuntu SMP Thu Jun 6 19:43:26 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

hovnatan 12-29-2013 02:17 PM

Hi aolney,

I also have the Thinkpad USB keyboard. My OS is Ubuntu 13.10. I tried the steps in your note but it didn't work. Although everything went without errors -- the sensitivity didn't change. Can you please help me?

Thanks!

aolney 12-30-2013 11:35 AM

I can try, but you're going to need to give me more details.

Let's try this: show me the command you are entering and the output to the screen for each step.

BTW I switched to Debian Sid sometime after this, so I no longer have the same system as before.

hovnatan 12-30-2013 10:55 PM

Thanks! Here is the procedure I followed:
output of tree:
Code:

$ tree /sys/bus/usb/drivers/usbhid
/sys/bus/usb/drivers/usbhid
├── 3-2:1.0 -> ../../../../devices/pci0000:00/0000:00:14.0/usb3/3-2/3-2:1.0
├── 3-2:1.1 -> ../../../../devices/pci0000:00/0000:00:14.0/usb3/3-2/3-2:1.1
├── bind
├── module -> ../../../../module/usbhid
├── new_id
├── remove_id
├── uevent
└── unbind

then I do
Code:

echo 3-2:1.1 > /sys/bus/usb/drivers/usbhid/unbind
python2 trackpoint.py
echo 3-2:1.1 > /sys/bus/usb/drivers/usbhid/unbind

where trackpoint.py is the exact code you provided. There are no errors or any other output from the scripts.

aolney 12-31-2013 11:27 AM

And it goes without saying that you installed the python libraries...

I seem to recall that it was necessary to execute these as sudo, so I'd try that first.

Suppose you put this:

echo 3-2:1.1 > /sys/bus/usb/drivers/usbhid/unbind
python2 trackpoint.py
echo 3-2:1.1 > /sys/bus/usb/drivers/usbhid/unbind

Into a new script (make sure you chmod 755), say called usbtrack.sh

The do "sudo usbtrack.sh"

Some other thoughts:

Through the years, I've used/tried many different methods to make this work. Right now, I'm using Debian sid, and it "just works." Unfortunately since I've tried so many things in the past, it's hard to tell what the last Ubuntu method worked for me.

That being said, you might want to try

https://github.com/bseibold/tpkbdctl

As that is highly placed in my backup script folder from my last Ubuntu install.

Also, for changing the speed of the built in trackpoint (not the external), you can try this

#!/bin/sh

T=`find /sys/devices/platform/i8042 -name name | xargs grep -Fl TrackPoint`
SERIO_DIR="${T%/*/*/name}"

sudo sh -c "echo -n 200 > $SERIO_DIR/speed"
sudo sh -c "echo -n 200 > $SERIO_DIR/sensitivity"

Finally, a fail-safe for the external trackpoint is this, but it is not what I would call high quality:

#!/bin/sh
xinput set-prop "pointer:Lite-On Technology Corp. ThinkPad USB Keyboard with TrackPoint" "Device Accel Velocity Scaling" 20
xinput set-prop "pointer:Lite-On Technology Corp. ThinkPad USB Keyboard with TrackPoint" "Device Accel Adaptive Deceleration" 2
xinput set-prop "pointer:Lite-On Technology Corp. ThinkPad USB Keyboard with TrackPoint" "Device Accel Profile" 3

You can spend hours tweaking xinput and still not be very happy with it, so I recommend it only if nothing else works.

So to sum up, try to run the scripts again as sudo, and if that doesn't work, take a look at tpkbdctl.

Sorry that my memory for this isn't better.

hovnatan 01-03-2014 03:41 AM

tpkbdctl didn't work :( The xinput script actually completely turned off the trackpoint. So I guess I might try to install debian-sid one of these days. Thanks!

aolney 01-03-2014 11:50 AM

I'm sorry I haven't been able to help you more with this.

Some last thoughts -- are we talking about the same keyboard?

This is mine:

http://support.lenovo.com/en_US/prod...cID=MIGR-73183

The model for mine is 55Y9053. You'll note this is slightly different from the link above.

It shows up like this if I run "xinput -list":

aolney@monkamu:~$ xinput -list
⎡ Virtual core pointer id=2 [master pointer (3)]
⎜ ↳ Virtual core XTEST pointer id=4 [slave pointer (2)]
⎜ ↳ TPPS/2 IBM TrackPoint id=11 [slave pointer (2)]
⎜ ↳ Lite-On Technology Corp. ThinkPad USB Keyboard with TrackPoint id=15 [slave pointer (2)]
⎣ Virtual core keyboard id=3 [master keyboard (2)]
↳ Virtual core XTEST keyboard id=5 [slave keyboard (3)]
↳ Power Button id=6 [slave keyboard (3)]
↳ Video Bus id=7 [slave keyboard (3)]
↳ Sleep Button id=8 [slave keyboard (3)]
↳ Integrated Camera id=9 [slave keyboard (3)]
↳ AT Translated Set 2 keyboard id=10 [slave keyboard (3)]
↳ ThinkPad Extra Buttons id=12 [slave keyboard (3)]
↳ ACPI Virtual Keyboard Device id=13 [slave keyboard (3)]
↳ Lite-On Technology Corp. ThinkPad USB Keyboard with TrackPoint id=14 [slave keyboard (3)]
aolney@monkamu:~$

Another thought -- I believe tpkbdctl worked great for me with Ubuntu 12.04, and I think I went straight from that to Debian sid (where it just works).

I took a quick look, and it seems the reason it "just works" is b/c the guy who wrote it is also in charge of this driver officially. So on my Debian sid it is installed here:

/etc/default/tpkbdctl

This is an actual file that you can edit to give the sensitivity parameter. If you tried to download it from github and it didn't work, I wonder if it's because your version of Ubuntu is sufficiently advanced that it actually has the driver built in, but the setting is stupid. Try looking for /etc/default/tpkbdctl and changing the sensitivity to the max. This is what mine looks like:

# Change this to adjust the sensitivity, valid range 1-255
TPKBDCTL_SENS="255"

TPKBDCTL_OPTIONS="-s ${TPKBDCTL_SENS}"

Also -- try plugging in your keyboard *after* your machine has booted. Sometimes this is needed for the proper driver to load (have no idea why).

Good luck :)


All times are GMT -5. The time now is 12:42 AM.