User avatar
Onira
Posts: 233
Joined: Tue Oct 02, 2012 6:24 pm
Location: Poland

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

Wed Oct 30, 2013 7:43 pm

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?
Last edited by Onira on Thu Oct 31, 2013 9:31 am, edited 1 time in total.
Cogito ergo sum

User avatar
FTrevorGowen
Forum Moderator
Forum Moderator
Posts: 5132
Joined: Mon Mar 04, 2013 6:12 pm
Location: Bristol, U.K.
Contact: Website

Re: USB UART - how to make it working?

Wed Oct 30, 2013 8:05 pm

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
Still running Raspbian Jessie or Stretch on some older Pi's (an A, B1, B2, B+, P2B, 3xP0, P0W, 2xP3A+, P3B+, P3B, B+, A+ and a B2) but Buster on the P4B's. See: https://www.cpmspectrepi.uk/raspberry_pi/raspiidx.htm

User avatar
Onira
Posts: 233
Joined: Tue Oct 02, 2012 6:24 pm
Location: Poland

Re: USB UART - how to make it working?

Wed Oct 30, 2013 8:15 pm

without those changes it doesn't work too
and this USB-Serial is on the verified peripherals list
Cogito ergo sum

karlkiste
Posts: 184
Joined: Tue Jan 22, 2013 8:50 am
Location: berlin, germany

Re: USB UART - how to make it working?

Wed Oct 30, 2013 8:18 pm

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?

User avatar
Onira
Posts: 233
Joined: Tue Oct 02, 2012 6:24 pm
Location: Poland

Re: USB UART - how to make it working?

Wed Oct 30, 2013 8:36 pm

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
Cogito ergo sum

jdb
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 2131
Joined: Thu Jul 11, 2013 2:37 pm

Re: USB UART - how to make it working?

Wed Oct 30, 2013 8:38 pm

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.
Rockets are loud.
https://astro-pi.org

karlkiste
Posts: 184
Joined: Tue Jan 22, 2013 8:50 am
Location: berlin, germany

Re: USB UART - how to make it working?

Wed Oct 30, 2013 8:52 pm

And, before the loopback test, run

stty -F /dev/ttyUSB0 -crtscts

to make sure no handshake inhibits data transmission.

User avatar
Onira
Posts: 233
Joined: Tue Oct 02, 2012 6:24 pm
Location: Poland

Re: USB UART - how to make it working?

Wed Oct 30, 2013 8:54 pm

Code: Select all

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

karlkiste
Posts: 184
Joined: Tue Jan 22, 2013 8:50 am
Location: berlin, germany

Re: USB UART - how to make it working?

Wed Oct 30, 2013 9:03 pm

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.

SnowLeopard
Posts: 106
Joined: Sun Aug 18, 2013 6:10 am

Re: USB UART - how to make it working?

Wed Oct 30, 2013 9:47 pm

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

User avatar
Onira
Posts: 233
Joined: Tue Oct 02, 2012 6:24 pm
Location: Poland

Re: USB UART - how to make it working?

Thu Oct 31, 2013 6:14 am

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
$ 
Cogito ergo sum

User avatar
Onira
Posts: 233
Joined: Tue Oct 02, 2012 6:24 pm
Location: Poland

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

Mon Nov 04, 2013 7:26 am

Although those testings don't work, I got the Serial connection working
and I can log into my RPi :D
Cogito ergo sum

Return to “Troubleshooting”