Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Sending commands to serial port - question

252 views
Skip to first unread message

Tom

unread,
Nov 2, 2011, 11:17:19 AM11/2/11
to
Hello,

I'm new to Kermit...this is my first very simple script.

I am running Ubuntu and trying to make a script to automate a way to
send commands to a serial device.

I need to toggle the device with ^S004AUX0 (off) and ^S004AUX1 (on).

I'm able to connect like so:

#!/usr/bin/kermit +

set modem type Serial ; There is no modem
set line /dev/ttyUSB0 ; Specify device name
set carrier-watch off ; If DTR and CD are not cross-
connected
set speed 9600 ; Or other desired speed
set flow xon/xoff ; If you can't use RTS/CTS
set parity none ; (or "mark" or "space", if
necessary)
set stop-bits 1 ; (rarely necessary)
connect ; this is where I get lost on the
automation and have to enter manual.

From here I can type ^S004AUX0 and toggle the device off (or on), but
would like to automate this part. It's probably pretty simple for
anyone who's used kermit more than a day:)

Can this be automated in the kermit script? If so...can someone show
an example?

Thanks in advance!

Tom

unread,
Nov 2, 2011, 11:25:38 AM11/2/11
to
Also...how would one exit the script after running. Thanks.

Bill Pechter

unread,
Nov 2, 2011, 1:38:49 PM11/2/11
to
In article <b2118d91-abe7-4967...@h34g2000yqd.googlegroups.com>,
You may need to set flow to something other than xon/xoff. ^S is xoff.
So... when you send ^S (I assume it's control-s) and not Caret-S you
stop the data flow.

Bill



--
--
Digital had it then. Don't you wish you could buy it now!
pechter-at-pechter.dyndns.org

Christian Corti

unread,
Nov 2, 2011, 1:15:38 PM11/2/11
to
Tom <tdenh...@gmail.com> wrote:
> I am running Ubuntu and trying to make a script to automate a way to
> send commands to a serial device.

> I need to toggle the device with ^S004AUX0 (off) and ^S004AUX1 (on).

> I'm able to connect like so:

> #!/usr/bin/kermit +

> set modem type Serial ; There is no modem
> set line /dev/ttyUSB0 ; Specify device name
> set carrier-watch off ; If DTR and CD are not cross-
> connected
> set speed 9600 ; Or other desired speed
> set flow xon/xoff ; If you can't use RTS/CTS
> set parity none ; (or "mark" or "space", if
> necessary)
> set stop-bits 1 ; (rarely necessary)
> connect ; this is where I get lost on the
> automation and have to enter manual.

Hm, I'd use a totally different approach:

# stty -F /dev/ttyUSB0 ixon 9600 -parenb (only needed once after boot)
# echo -n "^S004AUX0" >/dev/ttyUSB0
or
# echo -n "^S004AUX1" >/dev/ttyUSB0

You can ommit the -n parameter if a CR after the command won't hurt.

Christian

Robert Bonomi

unread,
Nov 3, 2011, 5:28:04 AM11/3/11
to
Trivially.

the secret is "do -not- use 'connect'".

At the kermit prompt, type "help output".

> If so...can someone show
>an example?

kermit> output ^S004AUX0

Note: if '^S' is [CTRL-S], aka [XOFF], aka [DC3], you probably want
'set flow-control none' -- if that control-s is echoed back to the
port on the PC, kermit's xon/xoff flow-control support wills *STOP*
sending any further characters to the device until an XON/[CTRL-Q]/
[DC1] character is received from the other device.


0 new messages