radiokk6
Posts: 18
Joined: Sun Jul 09, 2017 1:09 am

/dev/ttyUSB0 baud rate changes when ssh serial connection attempted

Wed Oct 04, 2017 4:38 am

Hi,

I"m using Raspbian Stetch. I've already done the apt-get update and upgrade thing.

I'm attempting to do a serial connection from my W10 machine to my raspberry pi using USBtoSerial connection from the W10 to Raspberry Pi. I"m using a Rpi3B.

agetty is already setup as a service. Also, I'm manually setting the baud rate of /dev/ttyUSB0 to 115200 with stty -F /dev/ttyUSB0 115200. When I run stty with the -a option, I do see that the baud rate is 115200. But, the moment I attempt to start a 115200 conection from my W10 PC, the /dev/ttyUSB0 baud rate gets changed, somehow, to 9600. So, no login prompt appears on SSH on the W10 machine. I do not believe this is a ssh issue. I get the exact same unwanted change on the /dev/ttyUSB0 when I use TeraTerm.

Any ideas what is causing this change and how to stop it from happening?

tia,radiokk6

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

Re: /dev/ttyUSB0 baud rate changes when ssh serial connection attempted

Wed Oct 04, 2017 3:42 pm

radiokk6 wrote: Hi,
I"m using Raspbian Stetch. I've already done the apt-get update and upgrade thing.
I'm attempting to do a serial connection from my W10 machine to my raspberry pi using USBtoSerial connection from the W10 to Raspberry Pi. I"m using a Rpi3B.
agetty is already setup as a service. Also, I'm manually setting the baud rate of /dev/ttyUSB0 to 115200 with stty -F /dev/ttyUSB0 115200. When I run stty with the -a option, I do see that the baud rate is 115200. But, the moment I attempt to start a 115200 conection from my W10 PC, the /dev/ttyUSB0 baud rate gets changed, somehow, to 9600. So, no login prompt appears on SSH on the W10 machine. I do not believe this is a ssh issue. I get the exact same unwanted change on the /dev/ttyUSB0 when I use TeraTerm.
Any ideas what is causing this change and how to stop it from happening?
tia,radiokk6
Presumably /dev/ttyUSB0 is W10 end of the connection - if so
1) What type of USB-to-TTL Serial Adapter** are you using (and is it operating with 3.3V levels at the Pi end)?
2) How did you enable the serial connection at the Pi end (ie. did you use raspi-config**** or a "manual method")?
Trev.
** FWIW, I've tried/tested most of these: http://www.cpmspectrepi.uk/raspberry_pi ... pters.html
**** The method changed post release of the P3B/Jessie (ie.pre-Stretch):
http://www.cpmspectrepi.uk/raspberry_pi ... _Model_P3B
Still running Raspbian Jessie or Stretch on some older Pi's (an A, B1, 2xB2, B+, P2B, 3xP0, P0W, 2xP3A+, P3B+, P3B, B+, and a A+) but Buster on the P4B's. See: https://www.cpmspectrepi.uk/raspberry_pi/raspiidx.htm

radiokk6
Posts: 18
Joined: Sun Jul 09, 2017 1:09 am

Re: /dev/ttyUSB0 baud rate changes when ssh serial connection attempted

Thu Oct 05, 2017 4:44 am

/dev/ttyUSB0 is actually on the RPi3B side.

This is my setup

W10->W10 USB port->FT231X--------------------FT231X----USB port on Rpi3B-----------Rpi3B

1. TX and RX are properly connected. TX of PC goes to RX of RPi3B. RX of PC goes to TX of RPi3B.
2. This setup looks weird because my actual application has something in the middle of the 2 FT231X devices. I'm using this setup to debug my 115200 issue.
3. Chip is the FTDI FT231X. I'm using the drivers already present on the Raspbian Stretch release.

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

Re: /dev/ttyUSB0 baud rate changes when ssh serial connection attempted

Thu Oct 05, 2017 1:44 pm

radiokk6 wrote: /dev/ttyUSB0 is actually on the RPi3B side.
This is my setup
W10->W10 USB port->FT231X--------------------FT231X----USB port on Rpi3B-----------Rpi3B
1. TX and RX are properly connected. TX of PC goes to RX of RPi3B. RX of PC goes to TX of RPi3B.
2. This setup looks weird because my actual application has something in the middle of the 2 FT231X devices. I'm using this setup to debug my 115200 issue.
3. Chip is the FTDI FT231X. I'm using the drivers already present on the Raspbian Stretch release.
That is an unusual (uncommon) setup!** What happens if you break the "middle connection" and replace it with loopback connections on each half? That way you can check which end the (apparent) baudrate is changing. Can you tell us more about the "something in the middle of the 2 FT231X devices"? Also do your FT231X (FTDI devices?) have (and use) additional "handshake connections"? How do you measure (or infer) that the baudrate has changed?
Trev.
** The nearest setup I have had to it is this:
http://www.cpmspectrepi.uk/raspberry_pi ... Cable.html
But that is based on "back-to-back" USB-to-ethernet devices rather than USB-to-serial.

Edit: Afterthought - are you trying to setup something similar to what was called an "A.R.C. (Addressable RS232C?)" interface?
Briefly described here: http://www.cpmspectrepi.uk/rs232/rs232.htm
Still running Raspbian Jessie or Stretch on some older Pi's (an A, B1, 2xB2, B+, P2B, 3xP0, P0W, 2xP3A+, P3B+, P3B, B+, and a A+) but Buster on the P4B's. See: https://www.cpmspectrepi.uk/raspberry_pi/raspiidx.htm

radiokk6
Posts: 18
Joined: Sun Jul 09, 2017 1:09 am

Re: /dev/ttyUSB0 baud rate changes when ssh serial connection attempted

Thu Oct 05, 2017 4:15 pm

The change of baud rate is happening on RPi3B side. This is the sequence of events:

1. Power up the RPi3B
2. On the RPi3B, runnthis command to setup the baud rate on /dev/ttyUSB0: sudo stty -F /dev/ttyUSB0 115200
3. Monitor the baud rate of /dev/ttyUSB0 by running this command;

watch -n 1 'sudo stty -a -F /dev/ttyUSB0'

4. Initiate serial connection at 115200 from W10 PC: com port on PC already set to 115200 and terminal program set to 115200 8n1 and no flow control.

5. When teminal opens and attempts to connect, after sending 3 to 5 characters, the item un step 3 shows the baudrate has changed back to 9600

I will try the loopback you suggested. The thing inthe middle is actually a zigbee wireless module. the zigbee wireless module does connect at 115200 using the manufacturers tool. I took out the zigbee to rule iut the zigbee;without the zigbee, baud rate is changing back to 9600

regards,be

radiokk6
Posts: 18
Joined: Sun Jul 09, 2017 1:09 am

Re: /dev/ttyUSB0 baud rate changes when ssh serial connection attempted

Thu Oct 05, 2017 4:15 pm

The change of baud rate is happening on RPi3B side. This is the sequence of events:

1. Power up the RPi3B
2. On the RPi3B, runnthis command to setup the baud rate on /dev/ttyUSB0: sudo stty -F /dev/ttyUSB0 115200
3. Monitor the baud rate of /dev/ttyUSB0 by running this command;

watch -n 1 'sudo stty -a -F /dev/ttyUSB0'

4. Initiate serial connection at 115200 from W10 PC: com port on PC already set to 115200 and terminal program set to 115200 8n1 and no flow control.

5. When teminal opens and attempts to connect, after sending 3 to 5 characters, the item un step 3 shows the baudrate has changed back to 9600

I will try the loopback you suggested. The thing inthe middle is actually a zigbee wireless module. the zigbee wireless module does connect at 115200 using the manufacturers tool. I took out the zigbee to rule iut the zigbee;without the zigbee, baud rate is changing back to 9600

regards,be

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

Re: /dev/ttyUSB0 baud rate changes when ssh serial connection attempted

Thu Oct 05, 2017 5:07 pm

radiokk6 wrote: The change of baud rate is happening on RPi3B side. This is the sequence of events:
1. Power up the RPi3B
2. On the RPi3B, runnthis command to setup the baud rate on /dev/ttyUSB0: sudo stty -F /dev/ttyUSB0 115200
3. Monitor the baud rate of /dev/ttyUSB0 by running this command;
watch -n 1 'sudo stty -a -F /dev/ttyUSB0'
4. Initiate serial connection at 115200 from W10 PC: com port on PC already set to 115200 and terminal program set to 115200 8n1 and no flow control.
5. When teminal opens and attempts to connect, after sending 3 to 5 characters, the item un step 3 shows the baudrate has changed back to 9600
I will try the loopback you suggested. The thing inthe middle is actually a zigbee wireless module. the zigbee wireless module does connect at 115200 using the manufacturers tool. I took out the zigbee to rule iut the zigbee;without the zigbee, baud rate is changing back to 9600
regards,be
I haven't used stty for a long time. If I want to set up a serial connection from a Pi to another device I prefer to use GtkTerm** (which can save configurations for later) - it's been more reliable (for me) than some of the other methods/GUI terminals I've tried. Do you have to initiate things from the "Windows end"? Do you have bluetooth active (on the Pi) - that uses one of the PI's "internal UARTs" and associated "clocks", IIRC, and, historically, there was an issue with "normal" (not USB) serial ports (which is why it is now trickier to manually set up the terminal on the GPIO pins.) - but that may be a "red herring". Do you have to use those specific USB-to-serial devices (in case it's a driver issue)?
Trev.
** http://www.cpmspectrepi.uk/raspberry_pi ... rtRep.html
http://www.cpmspectrepi.uk/raspberry_pi ... apter.html
http://www.cpmspectrepi.uk/raspberry_pi ... 000zc.html
Still running Raspbian Jessie or Stretch on some older Pi's (an A, B1, 2xB2, B+, P2B, 3xP0, P0W, 2xP3A+, P3B+, P3B, B+, and a A+) but Buster on the P4B's. See: https://www.cpmspectrepi.uk/raspberry_pi/raspiidx.htm

radiokk6
Posts: 18
Joined: Sun Jul 09, 2017 1:09 am

Re: /dev/ttyUSB0 baud rate changes when ssh serial connection attempted

Sun Oct 08, 2017 4:49 pm

I have great news! My issue is resolved!

the issue I was having was that I was initiating a serial connection from my Windows box to my Ri3B. In my application, this is the only flow that matters since the RPi3B in my application will be someplace remote, like on a deployed weather balloon or on top of a mountain. When I would initiate the connection at any baud rate above 9600, the connection would not work. Nothing was seen on the Putty serial session on the W10 box. I was able to observe that the baud rate of /dev/ttyUSB0 was getting changed to something else other than what I had just set it.

After many days of debug, I found the real problem. The real problem was agetty. I had configured systemd in Rapsbian Stretch to launch agetty as a service whenever the F232XL USB to serial adapter was plugged in to the RPi3B. I noticed that sometimes the agetty service would be deactivated when the baud rate of /dev/ttyUSB0 was changed. I was able to determine that whenever one changes the baud rate of ttyUSB0 with stty, then the agetty service must be restarted. I achieved this by adding the ExecStartPre into my agetty service configuration file that would launch stty to change the baud rate *and* then launch agetty.

After 24 hours of testing, I'm happy to report that not only is 115200 is working! I can even maintain the connection at 302400!

regards, radiokk6

Return to “Raspberry Pi OS”