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 connected an infrared receiver to a USB port ... (the last line of dmesg tells device file)

$ dmesg
[10496.596063] usb 7-2: new full-speed USB device number 2 using uhci_hcd
[10496.751112] usb 7-2: New USB device found, idVendor=0df7, idProduct=0620
[10496.751117] usb 7-2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[10496.751120] usb 7-2: Product: USB-Serial Controller
[10496.751124] usb 7-2: Manufacturer: Prolific Technology Inc.
[10496.787441] usbcore: registered new interface driver usbserial
[10496.787467] usbcore: registered new interface driver usbserial_generic
[10496.787483] usbserial: USB Serial support registered for generic
[10496.795104] usbcore: registered new interface driver pl2303
[10496.795129] usbserial: USB Serial support registered for pl2303
[10496.795160] pl2303 7-2:1.0: pl2303 converter detected
[10496.807238] usb 7-2: pl2303 converter now attached to ttyUSB0

Then I went on to try it ...

$ sudo cat /dev/ttyUSB0

but no output, simply hangs. Even though, as I press any button on my remote control, the infrared receiver device's LED flashes, so that does seem to work.

Why could that be?


notes:

  • the above command quits when I remove device from USB port and prints "cat: ttyUSB0: No such device", and dmesg prints 3 lines:

     [13707.264086] usb 7-2: USB disconnect, device number 2 
     [13707.264894] pl2303 ttyUSB0: pl2303 converter now disconnected from ttyUSB0
     [13707.264915] pl2303 7-2:1.0: device disconnected)
    
  • with the device files for keyboard this works, eg:

     $ sudo cat /dev/input/by-id/usb-USB_USB_Keykoard-event-kbd 
    

    produces many weird characters on the console as I press any key the keyboard

  • same happens on other USB ports too
share|improve this question
1  
try stty raw -echo < /dev/ttyUSB0; cat -vte /dev/ttyUSB0 instead. –  Stéphane Chazelas Mar 23 at 8:29
    
@ Stephane Chazelas : similarly nothing happens –  nlognfan Mar 23 at 9:13
    
mythtv.org/wiki/LIRC –  slm Mar 23 at 15:11
    
If you're not getting any output then I'd suspect its a driver issue or that the hardware wasn't being correctly detected/identified. This might prove helpful too: help.ubuntu.com/community/Lirc_USB-UIRT –  slm Mar 23 at 16:54
    
Please note that using infrared transceivers with USB-to-serial-bridges usually won't work. –  groxxda Jul 4 at 22:34

4 Answers 4

I think for serial devices you have to set the baud rate before they do anything. I'm not sure how to do that from the command line in order to get cat to work, but you could use a terminal emulator which takes care of it.

Try minicom or screen (i.e. screen /dev/ttyUSB0 115200 - replace 115200 with the baud rate of your IR receiver.)

share|improve this answer

Disregard the answer about need to initiate USB connection - it's already been initiated when you plugged in the device.

If you just want to check if it's working, use dd if=/dev/ttyUSB0. If you want to actually read those characters, you need serial terminal. Use minicom (CLI, need manual), picocom (might figure it out on your own), cutecom (nice graphical interface, easy) or screen (CLI, but really easy). You'll need to know the baudrate.. 90% it's either 115200 or 9600, might as well be 57600, 38400 or 19200.

By the way, what kind of receiver are you using? Could you give us a link to a product page or description?

share|improve this answer

This may not help, but here's a similar problem I've had in the past. When I cat the device file for my mouse directly (i.e., using cat /dev/input/by-id/usb-<mymouse>) I get output similar to what you get with your keyboard (i.e., gibberish). However, some mouse motions, like left click, don't generate any printable characters, so the terminal shows nothing.

Of course, the mouse is still doing something, we just can't see it by cat'ing the device file. Fortunately the kernel has a neat feature called usbmon that is helpful for eavesdropping on the raw binary output of usb devices. Using that, we can see exactly what's happening when we perform (say) a left-click, whereas doing the same thing via /dev often shows nothing.

Again, this may not help, but here's how to use usbmon:

  1. Make sure your kernel has usbmon enabled. The output of:
    zcat /proc/config.gz | grep USB_MON
    should have either =m or =y in it.

  2. If it was =m, then load the module with sudo modprobe usbmon

  3. To make sure all the usb sockets are showing up in the right place, run:
    ls /sys/kernel/debug/usb/usbmon
    You should see something like:
    0s 0u 1s 1t 1u 2s 2t 2u 3s 3t 3u 4s 4t 4u

The different numbers refer to different USB ports, and the ones with a 0 in front give the aggregated output of all USB ports. So for example, running cat /sys/kernel/debug/usb/usbmon/0u shows exactly what the device is doing, even in cases where cat'ing the file in /dev showed nothing.

Whether this solves your problem or not, it may be helpful in the future, since it's often a more helpful way to eavesdrop on USB devices than /dev.

Good luck :)

share|improve this answer

I seem to recall that USB is a protocol that requires the computer to initiate the communication. It's not allowed to speak on its own. So the driver actually talks into the raw device and then captures the output. However, that's only a hunch, I'll also wait for another answer to confirm my suspitions.

share|improve this answer
    
But this is a question about a serial port. The fact that the serial port is connected with USB is neither here nor there. –  Celada Jul 5 at 1:48

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.