Navigatrix.net - A Voyager's Companion http://navigatrix.net/ |
|
How to put baudrate permanent on 57600 http://navigatrix.net/viewtopic.php?f=4&t=722 |
Page 1 of 1 |
Author: | rein [ 29 Oct 2014, 06:29 ] |
Post subject: | How to put baudrate permanent on 57600 |
Hello, I use a miniplex with two serial outputs. When I put the baudrate on 4800 on the mux and in opencpn it works under w7 and ubuntu. When I change to 57600 on the mux I can change under W7 and it works ok. When I start ubuntu I can change opencpn to 57600 but no input. When in terminal mode do : sudo stty -F /dev/ttyS1 57600 it works ok. But when I restart I have to initialize again. How can I make this 57600 permanent. Rein |
Author: | Moe [ 29 Oct 2014, 07:11 ] |
Post subject: | Re: How to put baudrate permanent on 57600 |
In Navigatrix Code: sudo medit /usr/local/bin/opencpnais Insert the line you wanted (sudo stty -F /dev/ttyS1 57600) in the loop afterCode: #!/bin/sh Save and Exit. Next add stty to your sudoers file to make it automagic.AIS=/tmp/aisfifo cd / if ( ! pidof opencpn ); then alsactl store -f ~/.config/alsa_std alsactl restore -f ~/.config/alsa_ais sudo stty -F /dev/ttyS1 57600 If you're on a LiveCD it would be Code: sudo -s andCode: echo -n ", /bin/stty">>/etc/sudoers.d/00navigatrix At the moment I think it would be the same for a hard drive install. At the moment I don't have time to revert the machine because I've completely disable passwords and authentication on this machine and I have no backups, and I'd hate to lead you astray with bad advice and behaviour. If it doesn't I'll find a clean copy and we can go through editing sudoers. |
Author: | rein [ 30 Oct 2014, 09:42 ] |
Post subject: | Re: How to put baudrate permanent on 57600 |
Hello Moe, I added the sentence as you said. #!/bin/sh AIS=/tmp/aisfifo cd / if ( ! pidof opencpn ); then alsactl store -f ~/.config/alsa_std alsactl restore -f ~/.config/alsa_ais sudo stty -F /dev/ttyS1 57600 mkfifo $AIS pidof gnuais || sudo gnuais -c /etc/gnuais.conf -f >/dev/null 2>&1 sed -i "s/^Locale=.*$/Locale=${LANGUAGE%%:*}/" ~/.opencpn/opencpn.conf /usr/bin/opencpn $@ >/dev/null 2>&1 #/usr/bin/opencpn --verbose sudo killall gnuais rm $AIS alsactl store -f ~/.config/alsa_ais alsactl restore -f ~/.config/alsa_std fi I entered they other two commands. Restarted the computer, but it was not working. Tried to change baudrate by hand and got the following messag : rein@rein-desktop:~$ sudo stty -F /dev/ttyS1 57600 >>> /etc/sudoers.d/00navigatrix: syntax error near line 2 <<< sudo: parse error in /etc/sudoers.d/00navigatrix near line 2 sudo: no valid sudoers sources found, quitting sudo: unable to initialize policy plugin rein@rein-desktop:~$ Tried to see what was in 00navigatrix but I couldn open it ! I am not so familiar with linux. What went wrong ? Rein |
Author: | Moe [ 30 Oct 2014, 10:25 ] |
Post subject: | Re: How to put baudrate permanent on 57600 |
Code: sudo medit /etc/sudoers.d/00navigatrix the file is all one line and looks like Code: %adm ALL=(ALL) NOPASSWD: /usr/local/bin/comports, /usr/local/bin/nxlive, /usr/local/bin/adblock, /usr/local/bin/kiwix-serve, /usr/bin/gnuais, /sbin/hdparm, /usr/bin/killall, /sbin/iwconfig, /sbin/modprobe, /bin/mount, /bin/umount, /usr/bin/wvdial, /bin/stty You're adding ", /bin/stty" on the end so when you launch OpenCPN the serial command you provided and placed in the script (opencpnais) can set the speed of the serial port without requiring a password.
|
Author: | rein [ 30 Oct 2014, 11:17 ] |
Post subject: | Re: How to put baudrate permanent on 57600 |
Hello Moe, I don't understand. I type sudo ... and get the following answer. rein@rein-desktop:~$ sudo medit /etc/sudoers.d/00navigatrix >>> /etc/sudoers.d/00navigatrix: syntax error near line 2 <<< sudo: parse error in /etc/sudoers.d/00navigatrix near line 2 sudo: no valid sudoers sources found, quitting sudo: unable to initialize policy plugin rein@rein-desktop:~$ When I go to the /etc/sudoers.d/00navigatrix I need a password ? I get a message ....... syntax error near line 2 How and what have I to correct in line 2 ? rein |
Author: | Moe [ 30 Oct 2014, 13:06 ] |
Post subject: | Re: How to put baudrate permanent on 57600 |
Some how there is extra data in the file /etc/sudoers.d/00navigatrix The way to fix it is to replace it with a properly formatted file, but as you've noticed you can't open the file because this is one of the files that decides if you should have SUper powers, and it's buggered. You'll need to boot from a LiveCD (USB), locate the file ((IT WILL BE ON YOUR HARD DRIVE AND NOT THE USB)). Replace the file with the on that is in the LiveCD. Copy the file /etc/sudoers.d/00navigatrix and overwrite the file /media/183742373_some_long_name_possibly/etc/sudoers.d/00navigatrix Reboot That will get you back on track. If you're not on a hard drive installation simply boot into the menu, select "Options" and remake your persistence file. |
Author: | rein [ 03 Nov 2014, 08:36 ] |
Post subject: | Re: How to put baudrate permanent on 57600 |
I am not so familiar with linux. I did not change opencpnais, but the other things I did. When I did sudo medit /etc/sudoers.d/00navigatrix there is the message syntax error near line 2 My idea is that there is a mistake already in opencpnais, but I don't know what ? |
Author: | Moe [ 03 Nov 2014, 09:51 ] |
Post subject: | Re: How to put baudrate permanent on 57600 |
Sorry, I made a dreadful mess of the echo command, I'll be back. |
Author: | Moe [ 03 Nov 2014, 10:37 ] |
Post subject: | Re: How to put baudrate permanent on 57600 |
root@glenda:~# echo ", /bin/stty" >> /etc/sudoers.d/00navigatrix I'm sorry about the mistake, there is no -n in the command. Another way to do the same thing is to Code: sudo medit /usr/local/bin/opencpnais Replace with this textCode: #!/bin/sh Save and Exit.AIS=/tmp/aisfifo cd / if ( ! pidof opencpn ); then alsactl store -f ~/.config/alsa_std alsactl restore -f ~/.config/alsa_ais sudo stty -F /dev/ttyS1 57600 mkfifo $AIS pidof gnuais || sudo gnuais -c /etc/gnuais.conf -f >/dev/null 2>&1 sed -i "s/^Locale=.*$/Locale=${LANGUAGE%%:*}/" ~/.opencpn/opencpn.conf /usr/bin/opencpn $@ >/dev/null 2>&1 #/usr/bin/opencpn --verbose sudo killall gnuais rm $AIS alsactl store -f ~/.config/alsa_ais alsactl restore -f ~/.config/alsa_std fi Another, Code: sudo medit /etc/sudoers.d/00navigatrix Replace all the text withCode: %adm ALL=(ALL) NOPASSWD: /usr/local/bin/comports, /usr/local/bin/nxlive, /usr/local/bin/adblock, /usr/local/bin/kiwix-serve, /usr/bin/gnuais, /sbin/hdparm, /usr/bin/killall, /sbin/iwconfig, /sbin/modprobe, /bin/mount, /bin/umount, /usr/bin/wvdial, /bin/stty Save and TEST the sudo command in another terminal to see that you didn't get any extra characters in the file. (It is all one line --without <newline> characters.)If you did, revert the second file to what it was and try again. |
Author: | rein [ 04 Nov 2014, 09:34 ] |
Post subject: | Re: How to put baudrate permanent on 57600 |
Hello Moe, - did a new installation on my hdu. - made the changes you said, but still it is not working. This is the result what I get, when I check the file it is the same as you said. rein2@rein2-desktop:~$ sudo medit /usr/local/bin/opencpnais [sudo] password for rein2: (medit:2482): GLib-GObject-WARNING **: Attempt to add property MooEditConfig::lang after class was initialised (medit:2482): GLib-GObject-WARNING **: Attempt to add property MooEditConfig::indent after class was initialised (medit:2482): GLib-GObject-WARNING **: Attempt to add property MooEditConfig::strip after class was initialised (medit:2482): GLib-GObject-WARNING **: Attempt to add property MooEditConfig::add-newline after class was initialised (medit:2482): GLib-GObject-WARNING **: Attempt to add property MooEditConfig::wrap-mode after class was initialised (medit:2482): GLib-GObject-WARNING **: Attempt to add property MooEditConfig::show-line-numbers after class was initialised (medit:2482): GLib-GObject-WARNING **: Attempt to add property MooEditConfig::tab-width after class was initialised (medit:2482): GLib-GObject-WARNING **: Attempt to add property MooEditConfig::word-chars after class was initialised (medit:2482): GLib-GObject-WARNING **: Attempt to add property MooEditConfig::indent-use-tabs after class was initialised (medit:2482): GLib-GObject-WARNING **: Attempt to add property MooEditConfig::indent-width after class was initialised |
Author: | Moe [ 04 Nov 2014, 10:14 ] |
Post subject: | Re: How to put baudrate permanent on 57600 |
It worked. At least the sudo part worked <<<wasn't fouled up. The 'errors' you're seeing happen, they just do, and they do not signify anything important. Everything in that text file /usr/local/bin/opencpnais is executed when you launch OpenCPN via Menu> Navigation> OpenCPN. If you launch OpenCPN via another method, the script is not used and the TTY change you suggested will not happen. What happens when you enter Code: sudo stty -F /dev/ttyS1 57600 in a fresh (just opened) terminal?Are you asked for a password? If the sudoers file was changed you will not be asked for a password to change the TTY speed in a 'new' terminal. |
Author: | rein [ 04 Nov 2014, 11:37 ] |
Post subject: | Re: How to put baudrate permanent on 57600 |
When I start opencpn from the menu, I get input on ttyS0 (4800bd) but not on ttyS1 (57600bd). When in terminal mode I type : sudo stty -F /dev/ttyS1 57600 then I get also input on S1 and I don't have to type a password. |
Author: | rein [ 05 Nov 2014, 05:37 ] |
Post subject: | Re: How to put baudrate permanent on 57600 |
I still have the problem that I have to set the baudrate by hand. Everytime when I restart opencpn I want s0 on 4800 bd and S1 on 57600bd. When I change the baudrate in opencpn, nothing happens. What is the solution ? |
Author: | Moe [ 05 Nov 2014, 08:18 ] |
Post subject: | Re: How to put baudrate permanent on 57600 |
I need to tap the brain trust... |
Author: | Moe [ 14 Nov 2014, 06:06 ] |
Post subject: | Re: How to put baudrate permanent on 57600 |
Try this. Open your autostart file. Code: medit `/.config/autostart.sh There isn't anything special about this file. It's just sitting there taking up a name and space. Lets put it to work.autostart.sh wrote: #!/bin/bash Add your commands that you claim work to the bottom of the file# # This files gets started after # the boot sequence finished. # #opencpnais& Code: #!/bin/bash Save and exit.# # This files gets started after # the boot sequence finished. # #opencpnais& sudo stty -F /dev/ttyS0 4800 & sudo stty -F /dev/ttyS1 57600 & This file needs to be marked execuatable Code: chmod a+x ~/.config/autostart.sh Now comes the magic part.There is hardworking background application called cron which takes care of time (chronological) events. Enter Code: crontab -e The first time you will need to select an editor. #2 (nano) is a good choice.A little (nano) text editor opens. It is very basic. Don't freak out. All of the commands are listed at the botton of the terminal. The chronology table looks like Quote: # Edit this file to introduce tasks to be run by cron. It's _empty_ except for the comments (#). Add on a new line at the bottom of the file.# # Each task to run has to be defined through a single line # indicating with different fields when the task will be run # and what command to run for the task # # To define the time you can provide concrete values for # minute (m), hour (h), day of month (dom), month (mon), # and day of week (dow) or use '*' in these fields (for 'any').# # Notice that tasks will be started based on the cron's system # daemon's notion of time and timezones. # # Output of the crontab jobs (including errors) is sent through # email to the user the crontab file belongs to (unless redirected). # # For example, you can run a backup of all your user accounts # at 5 a.m every week with: # 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/ # # For more information see the manual pages of crontab(5) and cron(8) # # m h dom mon dow command Code: @reboot ~/.config/autostart.sh This says, 'on every reboot, launch the following....',<ctrl><x>to Save and Exit.You will be asked to varify this is what you want to do. Reboot. It happens auto-magically. Don't trust that it is being executed? Add Code: touch ~/Desktop/YES_IT_IS_REALLY_WORKING to the bottom of ~/.config/autostart.sh and everytime you reboot, a file with the name YES_IT_IS_REALLY_WORKING will appear on your desktop.Try it. Still not working? the sudo command should still be active from the last go-round. Check the stty commands. |
Page 1 of 1 | All times are UTC - 5 hours |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |