Help setup USB->Serial Loopback test in Ubunutu

Caporegime
Joined
18 Oct 2002
Posts
32,662
So I have a small robot which I can interface using a Wireless X-Bee Pro serial communication device. This is tested in windows and is fine. I simply plug in my USB->Serial->XBee device on my computer, check the windows hardware manager to find the com port, and use a VBasic program that provides are simple GUI interface for reading and sending commands or data. This works fine

So I know it all works under windows. Now i need to develop some software running in linux which will basically duplicate the functionality of the VBasic program, for debugging and testing purposes.


The USB->Serial device is a custom made device using the FTDI chip, which is supported by linux:
Code:
dmesg
...
...
[122052.522236] usb 1-2: new full speed USB device using uhci_hcd and address 13
[122052.710923] usb 1-2: configuration #1 chosen from 1 choice
[122052.713882] ftdi_sio 1-2:1.0: FTDI USB Serial Device converter detected
[122052.713927] /build/buildd/linux-2.6.24/drivers/usb/serial/ftdi_sio.c: Detected FT232RL
[122052.714080] usb 1-2: FTDI USB Serial Device converter now attached to ttyUSB1
[122216.171723] usb 1-2: USB disconnect, address 13
[122216.171957] ftdi_sio 1-2:1.0: device disconnected


So Linux is seeing the FTDI serial device.

But now I want to test it.
I have a second usb-serial->Xbee device, so have connected them both to do a loopback test, or some kind of sned and listen.

I tried using this: http://ftdi-usb-sio.sourceforge.net/
Loop-back test perl script.
Code:
perl serial_loopback.pl -s 1 -e 240 -v -r 2 -i /dev/ttyUSB0 -o /dev/ttyUSB1 -S 9600
Documentation is poor, but it seems that this isn't working. There is a counter for sent-received bytes but this never increments. However, if one of the USB is unplugged then the script gives an errror. That is promising.


I have tried using CUTECOM, by setting up 2 instances, 1 connected to each device, various baudrates. Nothing.


The robot when switched on communicates a continuous string of bytes, I don't recieve this. One thing I don't understand is that in Windows I have to specific the correct Com port, this doesn't seem to exist in Linux? (is this just setting the device ,e.g., /dev/ttyUSB0)
 
Anyone have any example C++ code for serial com?

Looking through google returns loads of unreadable rubbish. I need a simple clear and complete tutorial.

I have some code which seems to connect, but I cannot read any data.

Tim
 
Back
Top Bottom