I have a RS485 serial device (Quatech SSU2-300) that when plugged into a USB (2.0) port appears to be recognized correctly. dmesg yields:
cp210x 3-1:1.0: cp210x converter detected usb 3-1: reset full speed USB device using uhci_hcd and address 8 usb 3-1: cp210x converter now attached to ttyUSB0
A "C" language program attempting to use this port hangs at the open call.
This same program with the same device worked on a Centos 5.5 install on the same computer.
uname -r : 2.6.34.7-56.fc13.x86_64
The USB device works in Windows XP so I don't think there is a defect there.
Any thoughts will be appreciated. THX
On 09/29/2010 08:55 AM, Roger K. Wells wrote:
I have a RS485 serial device (Quatech SSU2-300) that when plugged into a USB (2.0) port appears to be recognized correctly. dmesg yields:
cp210x 3-1:1.0: cp210x converter detected usb 3-1: reset full speed USB device using uhci_hcd and address 8 usb 3-1: cp210x converter now attached to ttyUSB0
A "C" language program attempting to use this port hangs at the open call.
This same program with the same device worked on a Centos 5.5 install on the same computer.
uname -r : 2.6.34.7-56.fc13.x86_64
The USB device works in Windows XP so I don't think there is a defect there.
Any thoughts will be appreciated.
Check the permissions on /dev/ttyUSB0 and make sure the user you're running the C program as has permissions. You might also have a look to see if there's an SELinux denial associated with the attempt. It's not uncommon for udev and/or packagekit and/or SELinux to set up incorrect permissions or not have a context rule--especially on a device few people have around to test with (and I doubt a lot of us have a USB<-->RS485 adapter). :-)
If you have the source to the program you could change the open call to a non-blocking open and print out the resulting error code:
#include <string.h> #include <errno.h>
extern int errno; if ((fdc = open("/dev/ttyUSB0", O_RW | O_NONBLOCK)) < 0) printf("Can't open ttyUSB0: %s\n", strerror(errno));
You get the idea. ---------------------------------------------------------------------- - Rick Stevens, Systems Engineer, C2 Hosting ricks@nerd.com - - AIM/Skype: therps2 ICQ: 22643734 Yahoo: origrps2 - - - - Cuteness can be overcome through sufficient bastardry - - --Mark 'Kamikaze' Hughes - ----------------------------------------------------------------------
On Wed, 29 Sep 2010 11:55:21 -0400 "Roger K. Wells" ROGER.K.WELLS@saic.com wrote:
I have a RS485 serial device (Quatech SSU2-300) that when plugged into a USB (2.0) port appears to be recognized correctly. dmesg yields:
cp210x 3-1:1.0: cp210x converter detected usb 3-1: reset full speed USB device using uhci_hcd and address 8 usb 3-1: cp210x converter now attached to ttyUSB0
A "C" language program attempting to use this port hangs at the open call.
This same program with the same device worked on a Centos 5.5 install on the same computer.
uname -r : 2.6.34.7-56.fc13.x86_64
The USB device works in Windows XP so I don't think there is a defect there.
Modern kernels properly handle carrier detect and wait so open it with O_NDELAY if you don't want to wait for the carrier line to be asserted and/or set the CLOCAL termios bits if you are not using the carrier and flow control.
Alan Cox alan@lxorguk.ukuu.org.uk writes:
On Wed, 29 Sep 2010 11:55:21 -0400 "Roger K. Wells" ROGER.K.WELLS@saic.com wrote:
I have a RS485 serial device (Quatech SSU2-300) that when plugged into a USB (2.0) port appears to be recognized correctly. dmesg yields:
cp210x 3-1:1.0: cp210x converter detected usb 3-1: reset full speed USB device using uhci_hcd and address 8 usb 3-1: cp210x converter now attached to ttyUSB0
A "C" language program attempting to use this port hangs at the open call.
This same program with the same device worked on a Centos 5.5 install on the same computer.
uname -r : 2.6.34.7-56.fc13.x86_64
The USB device works in Windows XP so I don't think there is a defect there.
Modern kernels properly handle carrier detect and wait so open it with O_NDELAY if you don't want to wait for the carrier line to be asserted and/or set the CLOCAL termios bits if you are not using the carrier and flow control.
One of my pet peeves is people that wire up 3-wire rs-232 (ground, tx, rx) and then wonder why they can't open the port. Carrier detect is a very useful line for detecting if the rs-232 plug fell out of the computer. People should get in the habit of at least looping RTS->CTS, DTR->{DSR,DCD}.
-wolfgang