LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 01-14-2015, 02:22 PM   #1
JonasWepel
LQ Newbie
 
Registered: Jan 2015
Posts: 3

Rep: Reputation: Disabled
Minicom Script, Hex, Expect


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).
 
Old 01-14-2015, 06:15 PM   #2
ferrari
LQ Guru
 
Registered: Sep 2003
Location: Auckland, NZ
Distribution: openSUSE Leap
Posts: 5,819

Rep: Reputation: 1144Reputation: 1144Reputation: 1144Reputation: 1144Reputation: 1144Reputation: 1144Reputation: 1144Reputation: 1144Reputation: 1144
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)
 
Old 01-17-2015, 03:30 PM   #3
JonasWepel
LQ Newbie
 
Registered: Jan 2015
Posts: 3

Original Poster
Rep: Reputation: Disabled
Ignore send for now

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?
 
Old 01-17-2015, 04:14 PM   #4
ferrari
LQ Guru
 
Registered: Sep 2003
Location: Auckland, NZ
Distribution: openSUSE Leap
Posts: 5,819

Rep: Reputation: 1144Reputation: 1144Reputation: 1144Reputation: 1144Reputation: 1144Reputation: 1144Reputation: 1144Reputation: 1144Reputation: 1144
Maybe minicom is getting in the way. Anyway, I wonder if the following might be useful to you

http://en.wikibooks.org/wiki/Serial_...l_Command_Line
 
Old 01-17-2015, 10:54 PM   #5
veerain
Senior Member
 
Registered: Mar 2005
Location: Earth bound to Helios
Distribution: Custom
Posts: 2,524

Rep: Reputation: 319Reputation: 319Reputation: 319Reputation: 319
Useful link.

I also had this problem but I instead went for python, pyserial and wrote a python script.
 
Old 01-19-2015, 07:03 PM   #6
JonasWepel
LQ Newbie
 
Registered: Jan 2015
Posts: 3

Original Poster
Rep: Reputation: Disabled
Thanks for the feedback, all. Veerian, any chance I could take a look at your Python script?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't get expect to spawn minicom homer_3 Linux - General 1 03-13-2014 01:03 PM
Expect script: how do i send function key F12 in an expect script alix123 Programming 4 09-01-2013 09:06 PM
[root@fugo trace]# sh expect.sh expect.sh: line 9: expect: command not found sivaloga Linux - Kernel 1 08-22-2013 04:29 AM
SUSE 11.2 minicom and expect not sending backspaces Lantzvillian Linux - Server 1 07-01-2011 07:44 PM
[SOLVED] /usr/bin/expect : Script to check server load using both expect and bash Soji Antony Programming 1 07-27-2010 11:27 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 09:50 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration