usb serial programming

Greg KH greg at kroah.com
Mon Jul 21 15:06:43 EDT 2014


On Mon, Jul 21, 2014 at 06:55:43PM +0000, Amadeus W.M. wrote:
> On Mon, 21 Jul 2014 11:18:28 -0700, Greg KH wrote:
> 
> > On Mon, Jul 21, 2014 at 03:19:00AM +0000, Amadeus W.M. wrote:
> >> Not sure if this is the right venue for this question, please direct me to
> >> the right place if it's not.
> >> 
> >> I have a C program that opens the serial port /dev/ttyS0 and sends commands 
> >> (as strings) back and forth to a pan-tilt-zoom camera. That works very well,
> >> but I want to use the camera with a Raspberry Pi, which of course does not 
> >> have a serial port (RS232). One option is to use a RS232 to usb adapter and 
> >> rewrite the C code for the usb port. So how do I go about that? Is
> >> usb serial port programming possible and documented anywhere? 
> > 
> > Nothing to "rewrite", just point your code at /dev/ttyUSB0 instead, and
> > away you go...
> 
> Thanks for the prompt answer!
> 
> That's what I was hoping for, and I would have tried that, but I don't
> have any /dev/ttyUSBX. I am connecting the camera to a usb to RS232 
> cable:
> 
> http://www.amazon.com/gp/product/B000BI95W0/ref=oh_aui_detailpage_o03_s00?ie=UTF8&psc=1
> 
> Does this mean my adapter is not supported by linux? Also, nothing 
> happens in /var/log/messages when I plug the cable into the usb port. 
> This is my lsusb:
> 
> 1) root:~> lsusb
> Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
> Bus 005 Device 003: ID 0c45:1050 Microdia CF Card Reader
> Bus 005 Device 002: ID 046d:c016 Logitech, Inc. Optical Wheel Mouse
> Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
> Bus 004 Device 008: ID 0764:0501 Cyber Power System, Inc. CP1500 AVR UPS
> Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
> Bus 003 Device 005: ID 04fc:0561 Sunplus Technology Co., Ltd Flexcam 100
> Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
> Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
> 
> No trace of the adapter.

What is the:
	Bus 004 Device 008: ID 0764:0501 Cyber Power System, Inc. CP1500 AVR UPS

device?

> Should /dev/ttyUSB0 pop up when I plug the adapter into the usb port,
> even before I connect anything to the serial port of the cable? 

Yes.

What happens in the kernel log when you plug the device into the system?

Try doing:
	dmesg -c
	# plug in the adapter now
	dmesg
to just see the log messages for that, and not the whole kernel boot
log.

> If the adapter is not supported, can I write a driver for it? I'll be happy to,
> with a little guidance to get me started. Any pointers?

Odds are the device id just needs to be added to an existing driver as
I do not know of any "new" usb-serial converter chips that Linux does
not already support.

thanks,

greg k-h



More information about the Kernelnewbies mailing list