Linux Format forums Forum Index Linux Format forums
Help, discussion, magazine feedback and more
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to set correct ttyUSB0 speed on system boot-up

 
Post new topic   Reply to topic    Linux Format forums Forum Index -> Hardware
View previous topic :: View next topic  
Author Message
encoras



Joined: Fri Jan 24, 2014 9:18 am
Posts: 2
Location: Lithuania

PostPosted: Fri Jan 24, 2014 11:30 am    Post subject: How to set correct ttyUSB0 speed on system boot-up Reply with quote

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
Back to top
View user's profile Send private message
encoras



Joined: Fri Jan 24, 2014 9:18 am
Posts: 2
Location: Lithuania

PostPosted: Tue Jan 28, 2014 11:23 am    Post subject: The problem has been solved. Reply with quote

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!
Back to top
View user's profile Send private message
View previous topic :: View next topic  
Display posts from previous:   
Post new topic   Reply to topic    Linux Format forums Forum Index -> Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Linux Format forums topic RSS feed 


Powered by phpBB © 2001, 2005 phpBB Group


Copyright 2011 Future Publishing, all rights reserved.


Web hosting by UKFast