'Dave B' g8kbvdave-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org [linuxham]
2014-10-22 13:55:34 UTC
Hi...
Working with Lubuntu 12.04
So I can "pre-set" something (a KISS capable TNC on a serial port) in a shell
script used to start another program, before that program starts.
After some googling, I found a page at:-
http://stackoverflow.com/questions/8877269
(and other sites with similar info)
Cross referencing what is said there and the other sites with the contens of 'man
stty', would these work reliably in bash scripts?
#!/bin/bash
# kisson.sh To enter KISS mode.
# 9600bd, 8bits, one stop bit, no parity
stty -F /dev/ttyUSB102 speed 9600 cs8 -cstopb -parity
echo -en '\x13' > /dev/ttyUSB102
echo -en 'KISS ON\x13' > /dev/ttyUSB102
echo -en 'RESTART\x13' > /dev/ttyUSB102
(ttyUSB102, is udev'd to point to whatever the OS assigned to the actual
hardware device as it found it. Works well.)
Also...
#!/bin/bash
# kissoff.sh To exit KISS mode.
# 9600bd, 8bits, one stop bit, no parity
stty -F /dev/ttyUSB102 speed 9600 cs8 -cstopb -parity
# 0xc0, 0xff, 0xc0
echo -en '\x192\x255\x192' > /dev/ttyUSB102
I've not had the chance to try this, yet (my sacrificial 'nix box just committed
suicide, hard disk or RAM issues I think. It was not exactly the newest PC on the
floor. Memtest86 shows OK, running Spinrite now, no obvious issues yet.)
What I've not been able to figure out yet, is how to put a short wait (delay) after
each of the echo commands to the port. (Needed I find, to allow the TNC to
chew on things and sort its knickers out after being told to do something!)
I do know that sending it in one hit 'KISSON\rRESTART\r' (\r == cr byte) sends
it into abject raptures, needing a power off/on cycle to get it out of the mess.
This procedure (psudo code)...
Send a single \r, (empty line)
Wait/give time for the tnc to send its default 'cmd:' prompt
Send KISS ON\r
Wait/give time for the tnc to send its default 'cmd:' prompt
Send RESTART\r
Works 100% of the time. I've proven that with Procom+ under DOS! and even
a GWBASIC program! But that's all on DOS, and I'm wanting to do this under
Linux.
I see crN listed in stty's help text, but no clue where to use that function (a delay
of N 'somethings' after a cr byte, nor are the units of the delay specified.)
Any (sensible) suggestions? :)
I've got another hour or two, before I may get the old 'nix box back. Else even
longer before I get to sit in front of another with a real port, not a VM. Or
reload the OS on the old box again.
73.
Dave G0WBX.
------------------------------------
Posted by: "Dave B" <g8kbvdave-gM/Ye1E23mwN+***@public.gmane.org>
------------------------------------
Working with Lubuntu 12.04
So I can "pre-set" something (a KISS capable TNC on a serial port) in a shell
script used to start another program, before that program starts.
After some googling, I found a page at:-
http://stackoverflow.com/questions/8877269
(and other sites with similar info)
Cross referencing what is said there and the other sites with the contens of 'man
stty', would these work reliably in bash scripts?
#!/bin/bash
# kisson.sh To enter KISS mode.
# 9600bd, 8bits, one stop bit, no parity
stty -F /dev/ttyUSB102 speed 9600 cs8 -cstopb -parity
echo -en '\x13' > /dev/ttyUSB102
echo -en 'KISS ON\x13' > /dev/ttyUSB102
echo -en 'RESTART\x13' > /dev/ttyUSB102
(ttyUSB102, is udev'd to point to whatever the OS assigned to the actual
hardware device as it found it. Works well.)
Also...
#!/bin/bash
# kissoff.sh To exit KISS mode.
# 9600bd, 8bits, one stop bit, no parity
stty -F /dev/ttyUSB102 speed 9600 cs8 -cstopb -parity
# 0xc0, 0xff, 0xc0
echo -en '\x192\x255\x192' > /dev/ttyUSB102
I've not had the chance to try this, yet (my sacrificial 'nix box just committed
suicide, hard disk or RAM issues I think. It was not exactly the newest PC on the
floor. Memtest86 shows OK, running Spinrite now, no obvious issues yet.)
What I've not been able to figure out yet, is how to put a short wait (delay) after
each of the echo commands to the port. (Needed I find, to allow the TNC to
chew on things and sort its knickers out after being told to do something!)
I do know that sending it in one hit 'KISSON\rRESTART\r' (\r == cr byte) sends
it into abject raptures, needing a power off/on cycle to get it out of the mess.
This procedure (psudo code)...
Send a single \r, (empty line)
Wait/give time for the tnc to send its default 'cmd:' prompt
Send KISS ON\r
Wait/give time for the tnc to send its default 'cmd:' prompt
Send RESTART\r
Works 100% of the time. I've proven that with Procom+ under DOS! and even
a GWBASIC program! But that's all on DOS, and I'm wanting to do this under
Linux.
I see crN listed in stty's help text, but no clue where to use that function (a delay
of N 'somethings' after a cr byte, nor are the units of the delay specified.)
Any (sensible) suggestions? :)
I've got another hour or two, before I may get the old 'nix box back. Else even
longer before I get to sit in front of another with a real port, not a VM. Or
reload the OS on the old box again.
73.
Dave G0WBX.
------------------------------------
Posted by: "Dave B" <g8kbvdave-gM/Ye1E23mwN+***@public.gmane.org>
------------------------------------