Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I'm trying to write a script to run in minicom for communicating across an RS485 connection. So far, I can see the trafic across the connection which is in the 8n1 format at 9600 baud. I'd like my script to read the incoming data and when certain data are seen, send data back across the connection. A sample of the type of script I'm trying to use is as follows:
Code:
expect {
"\x10\x03" send "\x10\x02\r"
}
I've tried a few other variations of the this script, but essentially as soon as I run my code, the minicom output goes from a clear, patterned, and readable stream, to garbled boxes and characters (Once I enter ctrl-c to end my script, the legible data stream returns). My needs are simple so I thought using expect and send would suffice, but I'm struggling with either the syntax or perhaps the limitations of the software. I'd appreciate any advice on scripting with minicom, if you have any. If you think this is impossible with minicom that would be good to know as well as I can move on to another means of accomplishing my goal (python, C).
I'm not sure that you can send hex values like that with 'send'
From
Code:
man runscript
Quote:
OVERVIEW OF KEYWORDS
send <string>
<string> is sent to the modem. It is followed by a '\r'. <string> can be:
- regular text, e.g. 'send hello'
- text enclosed in quotes, e.g. 'send "hello world"'
Within <string> the following sequences are recognized:
\n - newline
\r - carriage return
\a - bell
\b - backspace
\c - don't send the default '\r'.
\f - formfeed
\^ - the ^ character
\o - send character o (o is an octal number)
For now let's ignore the sending of hex values, as I can't get the expect command to function properly. I'm trying something similar to the following:
Code:
expect {
"\x10\x03" print "TEST\n\r"
}
exit
This still leads to garbled output from minicom as soon as I run my script. "TEST" is never pritned and the neat, legible pattern of numbers turns to random boxes and characters. Is there are better syntax for reading the incoming data stream through the expect command?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.