Why does “cat ttyUSB0” not produce output

catdevicesfilesinputusb

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

Best Answer

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.)

Related Question