loginek0
Posts: 16
Joined: Fri Mar 13, 2015 7:11 am

FT232RL It does not work correctly if it is connected before

Sun Jul 19, 2015 9:48 am

I have a problem with the converter FTDI. If it is connected to the USB port and run the Raspberry Pi - converter work, but returns incorrect data (although the speed and the parameters are set well). When I connect the converter by hand into the USB port while the system Raspbian - converter returns the correct data. I tried to use a script usbreset.cc. The script work, but still receives incorrect data converter. The following logs:

Code: Select all

./usbreset /dev/bus/usb/001/004
[   86.151482] ftdi_sio ttyUSB0: FTDI USB Serial Device converter now disconnected from ttyUSB0
[   86.151905] ftdi_sio 1-1.2:1.0: device disconnected
[   86.244947] usb 1-1.2: reset full-speed USB device number 4 using dwc_otg
[   86.357852] ftdi_sio 1-1.2:1.0: FTDI USB Serial Device converter detected
[   86.358348] usb 1-1.2: Detected FT232RL
[   86.362605] usb 1-1.2: FTDI USB Serial Device converter now attached to ttyUSB0
After the converter is still not working. Without the once again and hook up the converter logs:

Code: Select all

[  101.066847] usb 1-1.2: USB disconnect, device number 4
[  101.071725] ftdi_sio ttyUSB0: FTDI USB Serial Device converter now disconnected from ttyUSB0
[  101.072142] ftdi_sio 1-1.2:1.0: device disconnected

[  104.884837] usb 1-1.2: new full-speed USB device number 6 using dwc_otg
[  105.012303] usb 1-1.2: New USB device found, idVendor=0403, idProduct=6001
[  105.012530] usb 1-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[  105.012973] usb 1-1.2: Product: USB <-> Serial Cable
[  105.013137] usb 1-1.2: Manufacturer: FTDI
[  105.013263] usb 1-1.2: SerialNumber: FTYXA500
[  105.029980] ftdi_sio 1-1.2:1.0: FTDI USB Serial Device converter detected
[  105.030438] usb 1-1.2: Detected FT232RL
[  105.031860] usb 1-1.2: FTDI USB Serial Device converter now attached to ttyUSB0
And now the converter is working properly. How can I fix this error? I do not want every time you connect the device again ...

User avatar
scruss
Posts: 3217
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

Re: FT232RL It does not work correctly if it is connected be

Sun Jul 19, 2015 2:10 pm

Both logs show that the device was connected as /dev/ttyUSB0. So there's likely something wrong with the configuration. Don't worry; Serial ports are a bit nasty under Linux (and, historically, under Unix too). USB can also be a bit nasty too, so you've got all the nastiness of both, combined … yay!

1) What group does the USB serial port belong to? On my Raspberry Pi 2:

Code: Select all

$ ls -l /dev/ttyU*
crw-rw---T 1 root dialout 188, 0 Dec 31  1969 /dev/ttyUSB0
crw-rw---T 1 root dialout 188, 1 Dec 31  1969 /dev/ttyUSB1
This shows that anyone in the ‘dialout' group can read and write to the serial port(s). You can check this with:

Code: Select all

$ groups
pi adm dialout cdrom sudo audio video plugdev games users netdev input spi gpio
2) What is your code doing? Sometimes you have to read some spurious data from the serial port before the real stuff shows up.

3) Sometimes, you just have to do a full clear of all of the settings on the port:

Code: Select all

stty -F /dev/ttyUSB0 0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0
Hope these help.
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.
Pronouns: he/him

loginek0
Posts: 16
Joined: Fri Mar 13, 2015 7:11 am

Re: FT232RL It does not work correctly if it is connected be

Sun Jul 19, 2015 9:36 pm

Thanks a lot for your answer!
scruss wrote:1) What group does the USB serial port belong to?

Code: Select all

ls -l /dev/ttyU*
crw-rw---T 1 root dialout 188, 0 Jan  1  1970 /dev/ttyUSB0

groups
root
scruss wrote:2) What is your code doing? Sometimes you have to read some spurious data from the serial port before the real stuff shows up.
My converter is designed to receive bits from the remote control (IR receiver). If I connect the converter before the start of the Raspberry Pi - converter receives bad data (only: 0b11111100, 0b11111101, 0b11111110, 0b11111111) - and should receive 0b00010 example - and receives such data if it is already connected when you start up the system Raspbian.
scruss wrote:3) Sometimes, you just have to do a full clear of all of the settings on the port:
Unfortunately, this code does not work:

Code: Select all

stty -F /dev/ttyUSB0 0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0
stty: /dev/ttyUSB0: unable to perform all requested operations
Overall, I receive data using the library "Serial" in python. As I have already mentioned - the correct data are received only when I connect the converter FTDI after booting the system. If it is plugged in before - unfortunately it did not work properly. I do not want every time you connect it.

Maybe there is still some way to repair this error?

User avatar
scruss
Posts: 3217
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

Re: FT232RL It does not work correctly if it is connected be

Mon Jul 20, 2015 1:48 am

  1. Are you running this as root? It's seldom a good idea to routinely run code as root.
  2. Maybe you need to explicitly set the baud rate, byte size and stop bits in your code.
  3. That's the expected output. The command can't reset everything about the port, so gives the warning.
A few more ideas:

* does "python -m serial.tools.list_ports" list the ttyUSB0 port? If it does, the port is known to the system, so you just need to get the config right.

* At the start of your program, can you read and discard any bytes already in the serial buffer? That way, while you might miss the first remote press, you know that there shouldn't be garbage in the buffer.

* what happens when you read the input from miniterm?
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.
Pronouns: he/him

Return to “Interfacing (DSI, CSI, I2C, etc.)”