Automated testing with minicom--using the bash script to manipulate minicom

Source: Internet
Author: User
In Linux
Minicom is a very good use of the serial Debugging tools, manual operation is very simple, when the automated testing, there is a bit of trouble; The following is a minicom automated test, that is, a bash script operation Minicom
1 First is through the Minicom connection target serial port,
Manual setup is simple,
In/etc
There is a minicom configuration file "MINIRC.DFL", which reads the configuration from the minicom when it is started, in the form of:
Pu Port/dev/ttys3
PU baudrate 115200
PU Bits 8
Pu parity N
PU StopBits 1
Pu rtscts No
Pu Xonxoff No
So, we can modify the MINI.DFL file by script, and then start minicom
After 2, we will solve the problem of input data in minicom
This uses Minicom's own script runscript, and the bottom is a simple runscript script
Expect {
"OK" break
}
Send "ATI"
Exit
The basic meaning of a script is to send an ATI string when minicom receives the OK string
So we can load the RunScript script when we start minicom again.
by command: Minicom-s <runscript name>
3 This will basically be able to use the Bash script operation Minicom
Below is a bash script that uses minicom to automate the serial port test:

#!/bin/bash

sudo echo "Pu port/dev/ttyhs2" >/ETC/MINIRC.DFL

echo "Expect {
\ "Ok\" break
}
Send \ "At_ogps=2\"
Exit
"> Run

Minicom-s Run &

Kill-9 $ (ps-ef|grep Minicom|gawk ' $!~/grep/{print $} ' |tr-s ')
RM Run
The content of the script is to connect/DEV/TTYHS2 with minicom, send at_ogps=2 when OK is received,

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.