i'm looking for some commandline program which I can use to send and receive data to/from serial port. I would like to automate my testing process - start test script which will send file to ttyPC, receive output to file and then compare results. First I tried with cat with two processes :

# output
echo "Output"
cat /dev/ttyPC > ./out/out${fileNumber}.txt &

echo "Input"
cat ./in/in${fileNumber}.txt > /dev/ttyPC

But this is not stable. Sometimes it's sending data constantly or have problem "file previously opened" or second tty opening closes first cat.

Then I tried with minicom (script.txt is sending data) minicom -D /dev/ttyPC -b 115200 -8 -C log1.txt -S script.txt but i cannot set parity from commandline.

Is there something better?

  • You could use cu
    – wurtel
    Commented Feb 13, 2019 at 10:57

3 Answers 3


minicom takes its settings primarily from a configuration file. The defaults are in /etc/minicom/minirc.dfl, but you can have other configurations saved as /etc/minicom/minirc.<configuration name>, or in your home directory as ~/.minirc.<configuration name>.

You can set up one or more prepared configuration files with /dev/ttyPC as the default port and with the speed and parity settings according to your needs. For example, run minicom -s ttyPC as root, go to Serial port setup menu, adjust things (including parity) to suit your needs, then select Save setup as ttyPC and then exit Minicom. Now you should have a /etc/minicom/minirc.ttyPC file. You can use its settings, even as a non-root user, by starting Minicom like minicom ttyPC. If you need multiple sets of configuration settings, repeat as necessary using a different configuration name.

Any command-line options can be used to override settings in the configuration file. So you could simply have multiple configuration files with all the possible parity settings, and override the rest using command line options.

The minicom configuration file is just text: if you need to fully automate the set-up of your test environment, your script could include the contents of the configuration file and write the configuration file before starting to use minicom.

  • I tried your solution. Created configuration file and then run command minicom -D /dev/ttyPC -C log1.txt < in/in1.txt. Looks OK, but minicom closes when STDIN stream ends. It's a problem for me because i want to wait on complet transfer from ttyPC.
    – s.paszko
    Commented Feb 13, 2019 at 9:39

I've written python script to solve my problem. This script takes serial port device, input file and output file as an arguments and then sent input file content to serial port and reads simultanously (Amount of bytes equal to input file size) to output file. If everything is readen or 5s of no data happend then script closes port and exits.


usage: serialCat [-h] -i INPUTFILE -o OUTPUTFILE -d DEVICE [-B BAUDRATE]
                 [-P PARITY]

optional arguments:
  -h, --help            show this help message and exit
                        input file
                        output file
  -d DEVICE, --device DEVICE
                        tty Device
  -B BAUDRATE, --baudrate BAUDRATE
  -P PARITY, --parity PARITY

You need to set the serial port by stty command

  • An example of doing this would be nice to see.
    – Kusalananda
    Commented Oct 7, 2019 at 5:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .