Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.debian.user > #221058 > unrolled thread
| Started by | "Martin McCormick" <martin.m@suddenlink.net> |
|---|---|
| First post | 2020-04-07 15:10 +0200 |
| Last post | 2020-04-07 18:50 +0200 |
| Articles | 4 — 3 participants |
Back to article view | Back to linux.debian.user
Microcom; What's this Script Feature? "Martin McCormick" <martin.m@suddenlink.net> - 2020-04-07 15:10 +0200
Re: Microcom; What's this Script Feature? Dan Ritter <dsr@randomstring.org> - 2020-04-07 15:50 +0200
Re: Microcom; What's this Script Feature? Reco <recoverym4n@enotuniq.net> - 2020-04-07 16:10 +0200
Re: Microcom; What's this Script Feature? "Martin McCormick" <martin.m@suddenlink.net> - 2020-04-07 18:50 +0200
| From | "Martin McCormick" <martin.m@suddenlink.net> |
|---|---|
| Date | 2020-04-07 15:10 +0200 |
| Subject | Microcom; What's this Script Feature? |
| Message-ID | <zSW9j-8sG-5@gated-at.bofh.it> |
While working with Microcom, I tried the "help" feature while in command mode and it works but there doesn't seem to be much other information. Here is a screen shot of a command I sent to a serially-connected two-way radio followed by the Help screen for microcom: I put a * in front of the script command. connected to /dev/ttyUSB4 Escape character: Ctrl-\ Type the escape character to get to the prompt. VF 0162500000,0,0,0,0,0,0,00,00,000,00000000,0,0 Enter command. Try 'help' for a list of builtin commands -> help speed - set terminal speed exit - exit from command processing flow - set flow control dtr - set dtr value rts - set rts value break - send break quit - quit microcom help - show help * x - execute a script log - log to file # - comment md - Display memory (i.MX specific) mw - write memory (i.MX specific) mwb - write memory byte (i.MX specific) mwh - write memory 2 byte (i.MX specific) upload - upload image (i.MX specific) connect - sync communication to Processor (i.MX specific) sniff - sniff and dissect communication from ATK (i.MX specific) -> Everything seems to work as far as I can tell but what does a script look like? I am sure it's kind of like expect or the old kermit scripts but I haven't yet been able to send anything it liked. The system I have been hacking on sends only carriage returns in it's responses so what one gets on the screen is one long line that gets over-written but that's no mystery. The unix convention of typing the Up-Arrow and starting microcom is very handy since one does not have to type microcom -f -p/dev/ttyUSB4 -s9600 each time. Actually, I usually get away with !mic followed by Enter and it starts. Good work to everybody who created this useful little terminal program. Martin McCormick WB5AGZ since Oct of 1969
[toc] | [next] | [standalone]
| From | Dan Ritter <dsr@randomstring.org> |
|---|---|
| Date | 2020-04-07 15:50 +0200 |
| Message-ID | <zSWM2-dG-7@gated-at.bofh.it> |
| In reply to | #221058 |
Martin McCormick wrote:
> * x - execute a script
>
> Everything seems to work as far as I can tell but what
> does a script look like?
man runscript
> The unix convention of typing the Up-Arrow and starting
> microcom is very handy since one does not have to type
>
> microcom -f -p/dev/ttyUSB4 -s9600
> each time. Actually, I usually get away with !mic followed by
> Enter and it starts. Good work to everybody who created this
> useful little terminal program.
Time to learn the awesome power of Linux.
Three ways to do this:
1. shell script
Create a text file with the following two lines of code:
#!/bin/sh
exec microcom -f -p/dev/ttyUSB4 -s9600
Name it something short and memorable, like serial
Then
chmod a+rx serial
And from then on, it's a program you can run.
2. shell alias
Most shells have aliases available. In bash, you can stick them
in your .bashrc file. Add this line:
alias serial='microcom -f -p/dev/ttyUSB4 -s9600'
and then re-evaluate your .bashrc (which is done automatically
on login):
. .bashrc
Now you have a new command.
3. shell function
Most shells have functions available, too. The difference
between an alias and a function is that an alias is just a
substitution, but a function can take arguments and perform
complicated feats of logic. In this case, a function is
overkill, but it's still easy to drop in to your .bashrc.
function serial {
microcom -f -p/dev/ttyUSB4 -s9600
}
There you go.
-dsr-
[toc] | [prev] | [next] | [standalone]
| From | Reco <recoverym4n@enotuniq.net> |
|---|---|
| Date | 2020-04-07 16:10 +0200 |
| Message-ID | <zSX5n-zo-13@gated-at.bofh.it> |
| In reply to | #221058 |
Hi. On Tue, Apr 07, 2020 at 08:08:26AM -0500, Martin McCormick wrote: > Everything seems to work as far as I can tell but what > does a script look like? Judging from the source it it should open a text file on your side (i.e. "x filename") and feed its contents line by line to the other side. So whatever you'll write in the file is specific to the device you're connecting to. Reco
[toc] | [prev] | [next] | [standalone]
| From | "Martin McCormick" <martin.m@suddenlink.net> |
|---|---|
| Date | 2020-04-07 18:50 +0200 |
| Message-ID | <zSZAd-1TD-3@gated-at.bofh.it> |
| In reply to | #221065 |
I will reply to both excellent responses. Thank you.
Dan Ritter <dsr@randomstring.org> writes:
> Time to learn the awesome power of Linux.
>
> Three ways to do this:
>
> 1. shell script
>
> Create a text file with the following two lines of code:
>
> #!/bin/sh
> exec microcom -f -p/dev/ttyUSB4 -s9600
>
> Name it something short and memorable, like serial
>
> Then
>
> chmod a+rx serial
>
> And from then on, it's a program you can run.
>
> 2. shell alias
>
> Most shells have aliases available. In bash, you can stick them
> in your .bashrc file. Add this line:
>
> alias serial='microcom -f -p/dev/ttyUSB4 -s9600'
>
> and then re-evaluate your .bashrc (which is done automatically
> on login):
>
> . .bashrc
>
> Now you have a new command.
>
> 3. shell function
>
> Most shells have functions available, too. The difference
> between an alias and a function is that an alias is just a
> substitution, but a function can take arguments and perform
> complicated feats of logic. In this case, a function is
> overkill, but it's still easy to drop in to your .bashrc.
>
> function serial {
> microcom -f -p/dev/ttyUSB4 -s9600
> }
>
>
> There you go.
Reco <recoverym4n@enotuniq.net> writes:
> Hi.
>
> Judging from the source it it should open a text file on your side (i.e.
> "x filename") and feed its contents line by line to the other side.
> So whatever you'll write in the file is specific to the device you're
> connecting to.
>
> Reco
I could have done a better job of frasing my question as
I love the power of unix and use shell scripts and aliases
all the time.
What is confusing me about scripts in microcom is the
following situation:
I wanted to output device-specific commands and at least
see the responses much like the send/expect pairs in the expect
utility or the OUTPUT and INPUT commands in kermit scripts.
One starts the script while in the command mode of
microcom and it seems that your script should only contain
commands for microcom such as defining the port, speed, etc,
basically what the help screen says one can do.
It doesn't seem like you can put device-specific commands
in the script file.
I wrote a little script that exited command mode with the
exit command and then typed a command that was meant for the
device and then I typed x ./tester while in command mode.
It ran the "exit" command which put one in the terminal
window. You could type things then and each thing you type went
right to the device. I then removed the exit command and left a
command for the device.
It interpreted that command as being meant for microcom
so did not do anything but respond that it did not understand the
command.
microcom does work with expect but can't see the Carriage
Returns at the end of the lines returned by the device. If you
know how the response should end, expect does see the ASCII
characters and moves on. Otherwise, one must allow a reasonable
time such as 1 second for the timeout.
I was hoping there was some way to duplicate expect or
kermit with just the microcom app but this is not a show stopper
at all. At least there is still a serial terminal that can talk
to devices whose only connection to the outside world is a RS-232
cable.
Again, thanks for everybody's help.
Martin McCormick
[toc] | [prev] | [standalone]
Back to top | Article view | linux.debian.user
csiph-web