How to set correct ttyUSB0 speed on system boot-up

For discussing Linux compatible (or not) devices

Moderators: ChrisThornett, LXF moderators

How to set correct ttyUSB0 speed on system boot-up

Postby encoras » Fri Jan 24, 2014 11:30 am

I am newbie in Linux and odroid programmining, but I hope to finalize my project on robot control over Ogroid x2.
I have written a rc.local scrip to start a robot on Odroid boot up; which is working correctly from a USER’s (odroid, root) space by running “rc.local start”.
Unfortunattely on systems boot-up it does not changes USB0 speed and communication is incorect!
The script and the results are below the text.
How to solve this problem? Any ideas?
My Linux: Ubuntu 13.10 (GNU/Linux 3.0.75-odroidx2 armv7l)

Regards

The rc.local scrip:
exec 2>/amber/rc.local.log
exec 1>&2
set -x

modprobe usbserial
/bin/chmod 666 /dev/ttyUSB0
/bin/stty -a -F /dev/ttyUSB0
/bin/stty -F /dev/ttyUSB0 38400 raw pass8
/bin/stty -a -F /dev/ttyUSB0
ls -l /dev/ttyU*
stty < /dev/ttyUSB0
echo "D,0,0" > /dev/ttyUSB0
sleep 2
echo "D,0,-100" > /dev/ttyUSB0
stty < /dev/ttyUSB0

///////////////////////////////////////////////////////////
/////////////////// RESULT from odroid user login /////////////
//////////////////////////////////////////////////////////
+ modprobe usbserial
+ /bin/chmod 666 /dev/ttyUSB0
+ /bin/stty -a -F /dev/ttyUSB0
speed 9600 baud; rows 0; columns 0; line = 0; <<<<<<<<<<<<<<<<<<<< Initial speed
+ /bin/stty -F /dev/ttyUSB0 38400 raw pass8
+ /bin/stty -a -F /dev/ttyUSB0
speed 38400 baud; rows 0; columns 0; line = 0;
+ ls -l /dev/ttyUSB0
crw-rw-rw- 1 root dialout 188, 0 1? 24 09:27 /dev/ttyUSB0
+ stty
speed 38400 baud; line = 0;
+ echo D,0,0
+ sleep 2
+ echo D,0,-100

+ stty
speed 38400 baud; line = 0;
+ exit 0


############################
### RESULT
### On odroid Linux BOOT –Up
############################

+ modprobe usbserial
+ /bin/chmod 666 /dev/ttyUSB0
+ /bin/stty -a -F /dev/ttyUSB0
speed 9600 baud; rows 0; columns 0; line = 0; <<<<<<<<<<<<<<<<<<<< Initial speed
+ /bin/stty -F /dev/ttyUSB0 38400 raw pass8
+ /bin/stty -a -F /dev/ttyUSB0
speed 38400 baud; rows 0; columns 0; line = 0; <<<<<<<<<<<<<<<<<<<< New speed
+ ls -l /dev/ttyUSB0
crw-rw-rw- 1 root dialout 188, 0 Jan 24 09:47 /dev/ttyUSB0
+ stty
speed 38400 baud; line = 0;
+ echo D,0,0
+ sleep 2
+ echo D,0,-100
+ stty


speed 115200 baud; line = 0; <<<<< The final speed is incorrect and my robot is not communicated through USB0 at speed 38400 !!!!!! Why?
+ exit 0
encoras
 
Posts: 2
Joined: Fri Jan 24, 2014 9:18 am
Location: Lithuania

The problem has been solved.

Postby encoras » Tue Jan 28, 2014 11:23 am

The problem has been solved.
Somebody in Linux likes joking.
The
/bin/stty -F /dev/ttyUSB0 38400 raw pass8
/bin/stty -a -F /dev/ttyUSB0

is NOT the same as
/bin/stty -F /dev/ttyUSB0 38400 raw pass8
sleep 20
/bin/stty -a -F /dev/ttyUSB0


The first one gives answer 38400 the second one – 115200.
Therefore in order to obtain required 38400, I had to set the initial speed 9600!!!
It works, but don’t know why… The GOD of Linux has the answer.
Thanks for support!
encoras
 
Posts: 2
Joined: Fri Jan 24, 2014 9:18 am
Location: Lithuania


Return to Hardware

Who is online

Users browsing this forum: No registered users and 0 guests