GAURAV KUMAR

Friday, July 26, 2013

Communicate with an unknown usb serial device in linux

Hi all,
Recently I was trying to work with a 2D barcode scanner which was told to work as serial data device. When I inserted it in my linux system, there was nothing like a serial port or something in my "/dev" list. When I searched with the model number, I found nothing relevant to make it work. Usually it is suspected that the driver is not present in the system. I was really frustrated at that time since there was no lead and it had to be done soon. The material came with no driver. When I saw the syslog, it showed some path related to the device inserted. There I found information about the manufacturer and googled it which led me to a website where I found windows7 driver of this device. It felt like I was halfway there. I quickly downloaded the driver, installed and run it. And yes, I was able to view serial data after scanning 2D barcodes. But this wasn't it. It had to work on a linux system too.

As I tried to know more about the problem, I learned that there is a way. Writing a udev rule to control the usb device sounded like a cool thing to do. But the thing is, I had never written a udev rule and I was anxious to make the device work. So I kept searching around a bit and found something that said an unknown usb serial device can be recognized by the system if we load the kernel device driver with the product id and vendor id of the device. Finding product id and vendor id was easy. It is printed by "lsusb" command. So I gave it a try.

modprobe usbserial vendor=0x1eab product=0x0d02

I saw "dmesg" and there it was. the device was recognized as a serial device and found as /dev/ttyUSB0 .

Lesson: An unknown serial usb device doesn't need any extra driver but the usual usbserial driver can be used to register it in the linux kernel.

No comments:

Post a Comment