Page 1 of 1

USB UART - how to make it working? (FT232RL)

Posted: Wed Oct 30, 2013 7:43 pm
by Onira
I bought a FTDI USB UART

Code: Select all

 $ dmesg | grep FT
[    3.603690] usb 1-1.3.2: Manufacturer: FTDI
[    3.608712] usb 1-1.3.2: SerialNumber: FTFDM2IU
[    5.449131] USB Serial support registered for FTDI USB Serial Device
[    5.455418] ftdi_sio 1-1.3.2:1.0: FTDI USB Serial Device converter detected
[    5.725517] usb 1-1.3.2: Detected FT232RL
[    6.060912] usb 1-1.3.2: FTDI USB Serial Device converter now attached to ttyUSB0
[    6.136607] ftdi_sio: v1.6.0:USB FTDI Serial Converters Driver

Code: Select all

$ lsusb
...
Bus 001 Device 007: ID 0403:6001 Future Technology Devices International, Ltd FT232 USB-Serial (UART) IC
...
and

Code: Select all

$ cat /etc/inittab
...
#T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100
and

Code: Select all

$ cat /boot/cmdline.txt
#dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait
dwc_otg.lpm_enable=0 console=ttyUSB0,115200 kgdboc=ttyUSB0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait
but when I do

Code: Select all

$ echo "test" > /dev/ttyUSB0
nothing happens

What am I doing wrong?

Re: USB UART - how to make it working?

Posted: Wed Oct 30, 2013 8:05 pm
by FTrevorGowen
I'm not 100% certain, but I think the (type of) changes you've made to /etc/inittab and /boot/cmdline.txt only apply if you wish to use the Pi's own UART. Certainly that sort of change was unnecessary for me when I used this USB-to-RS232 serial adapter device: http://www.cpmspectrepi.webspace.virgin ... apter.html . One of those is, effectively a USB UART combined with RS232 level conversion circuitry. However if you were plugging the USB end of your device into another computer and the "UART leads" to the Pi then some commenting out of entries within those files is required IIRC**. (Some, albeit brief, info. w.r.t. working devices here: http://elinux.org/RPi_VerifiedPeriphera ... 9_adapters)
Trev.

**Edit: More info. here: http://elinux.org/RPi_Serial_Connection

Re: USB UART - how to make it working?

Posted: Wed Oct 30, 2013 8:15 pm
by Onira
without those changes it doesn't work too
and this USB-Serial is on the verified peripherals list

Re: USB UART - how to make it working?

Posted: Wed Oct 30, 2013 8:18 pm
by karlkiste
Onira wrote: but when I do

Code: Select all

$ echo "test" > /dev/ttyUSB0
nothing happens
What is it that should be happening? What is the device connected to?

Re: USB UART - how to make it working?

Posted: Wed Oct 30, 2013 8:36 pm
by Onira

Code: Select all

$ echo "test" > /dev/ttyUSB0
test
this is what I am expecting
the adapter is connected to my powered USB hub (logilink, the one from verified peripherals)

any other way to test if it's working?

Code: Select all

screen /dev/ttyUSB0
hangs

Re: USB UART - how to make it working?

Posted: Wed Oct 30, 2013 8:38 pm
by jdb
ttyAMA0 is the UART on the Pi's GPIO pins. The kernel message log you posted shows that the USB device is correctly detected and is now bound to ttyUSB0.

- Is your wiring correct?
- Is your baud rate and parity correct?

If you want to perform a "loopback" test, then link txd to rxd (pin 2 to pin 3 on a DB9 connector) and do cat /dev/ttyUSB0 & echo "test" > /dev/ttyUSB0

Then do fg and hit ctrl-c.

Re: USB UART - how to make it working?

Posted: Wed Oct 30, 2013 8:52 pm
by karlkiste
And, before the loopback test, run

stty -F /dev/ttyUSB0 -crtscts

to make sure no handshake inhibits data transmission.

Re: USB UART - how to make it working?

Posted: Wed Oct 30, 2013 8:54 pm
by Onira

Code: Select all

pi@raspberrypi ~ $ echo "test" > /dev/ttyUSB0
pi@raspberrypi ~ $ test
[ctrl-c]
pi@raspberrypi ~ $
sometimes work and sometimes does not, why?

Re: USB UART - how to make it working?

Posted: Wed Oct 30, 2013 9:03 pm
by karlkiste
When I had this effect, there were several tasks running, reading the serial device. So, sometimes my task got the data, sometimes another task "stole" it.

Re: USB UART - how to make it working?

Posted: Wed Oct 30, 2013 9:47 pm
by SnowLeopard
What do you have connected to your FTDI UART? On it's own, it won't talk back or do anything.. all it does is convert USB to serial and give rx & tx that you connect to something. I have an fried arduino nano which I could still use a simple serial interface if I had a device like a serial modem to connect to it.
I have another nano attached, which is effectively seen as a usb serial port just like yours:
[ 7.014431] usb 1-1.3: FTDI USB Serial Device converter now attached to ttyUSB0
One way I've used to talk to it is with the minicom program, originally designed for use with a modem.
Since I've programmed it to take a single character as input and echo back "moving", this simple shell script works nicely:

Code: Select all

#!/bin/bash
# send-USB0.sh
# takes arg on command line and sends it to ttyUSB0 and
#  reads reply
if [ "$1" != "" ]; then
  echo $1 > /dev/ttyUSB0
  read -t 3 A < /dev/ttyUSB0
  echo $A
else
  echo "Usage: $0 <1-9>"
  echo "  sends value to ttyUSB0"
fi
The part that will interest you in particular is the read built-in bash function. (-t 3 is 3 second timeout)
You can also do in single command-line:

Code: Select all

echo test > /dev/ttyUSB0 && read -t 3 A < /dev/ttyUSB0 && echo $A

Re: USB UART - how to make it working?

Posted: Thu Oct 31, 2013 6:14 am
by Onira
for tests I use a DB-9 female plug with 2-3, 7-8 and 1-4-6 bridges

Code: Select all

$ echo test > /dev/ttyUSB0 && read -t 3 A < /dev/ttyUSB0 && echo $A
test
$
worked but after a reboot it's not working anymore...

Code: Select all

$ echo "test" > /dev/ttyUSB0 && read -t 3 A < /dev/ttyUSB0 && echo $A
$ 

Re: USB UART - how to make it working? (FT232RL)

Posted: Mon Nov 04, 2013 7:26 am
by Onira
Although those testings don't work, I got the Serial connection working
and I can log into my RPi :D