Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I want to list usb ports in linux and then send a message to the printer connected to it. That message is sensed by the printer to open the cash drawer. I know I can use echo - e and a port name, but my difficulty is finding the port name. How can I list the available ports or the ports that are currently used?

share|improve this question
add comment

1 Answer

up vote 9 down vote accepted

The lsusb command will yield the list of recognised usb devices. Here is an example:

$ lsusb
Bus 002 Device 003: ID 1c7a:0801 LighTuning Technology Inc. 
Bus 002 Device 002: ID 8087:0020 Intel Corp. Integrated Rate Matching Hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 004: ID 04ca:f01c Lite-On Technology Corp. 
Bus 001 Device 003: ID 064e:a219 Suyin Corp. 
Bus 001 Device 002: ID 8087:0020 Intel Corp. Integrated Rate Matching Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

You can note that the information provided include the bus path as well as the vendorId/deviceId. I'm not sure what "the ports that are currently used" actually means.

Edit
To write a message to the device on bus 1 device 2 you must access the device

$ ls -l /dev/bus/usb/001/002
crw-rw-r-- 1 root root 189, 1 2011-06-04 03:11 /dev/bus/usb/001/002

share|improve this answer
    
yes i can see this but now if i have to write a message to the port what do i do ? –  Deepak Jun 4 '11 at 2:06
    
@Deepak, I edited the answer to address that aspect ;-) –  Alain Pannetier Jun 4 '11 at 2:18
1  
and i used echo -e /dev/bus/usb/001/001 > "message" but nothing happens –  Deepak Jun 5 '11 at 7:02
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.