Sending binary files via minicom

Minicom is the defacto standard serial communication program for Linux, modeled after the old DOS program Telix.  While Minicom isn’t as advanced as Telix, it does offer quite a bit of functionality that satisfies most common needs.  Unfortunately, it doesn’t include a binary upload option.

While not commonly used, once in a while, you just need it.  Fortunately, Minicom does allow you to define your own file transfer utilities.  So here’s a simple little script you can use that will give you a “binary upload” option in Minicom.  To make things a little prettier, I used a little utility called ‘pv’ so that you can get a progress bar while it transfers your file.

If you don’t already have it, you should be able to find it easily within your Linux distribution:

On RPM-based systems, just type:

sudo yum install pv

On Debian-based systems, type:

sudo apt-get install pv

Now create this script, and place it in your ~/bin/ directory as (for example) bin-xfr.


#!/bin/sh
INFILE=/dev/null
OUTFILE=/dev/null

while [ $# -gt 0 ]; do
 case "$1" in
 -i)
 shift
 INFILE="$1"
 ;;
 -o)
 shift
 OUTFILE="$1"
 ;;
 -h|--help)
 echo "$0 -i infile -o outfile"
 ;;
 *)
 INFILE="$1"
 esac
 shift
done
cat << EOF
binary-xfer utility for minicom
Sending file ${INFILE} to ${OUTFILE}
EOF

/usr/bin/pv --force -i 0.25 -B 128  ${INFILE}  2>&1 > ${OUTFILE}
# Use the line below if you don't have pv!

# /bin/cat ${INFILE} > ${OUTFILE}
cat << EOF

File transfer complete
EOF
sleep 1

Now go over to minicom and go to the configuration menu (via ESC-O), then “File transfer protocols”. You can add a section there called “binary”, point it at your file, and specify:

  • Name: Binary
  • Program: /home/MYUSERNAME/bin/bin-xfer -o %l
  • Name: Y
  • U/D:  U
  • FullScr: Y
  • IO-Red: N
  • Multi:N

Then leave the menu and save your options.  Next time you send a file (via ESC-S), you should see “Binary” listed as an option.

 

One thought on “Sending binary files via minicom

  1. Seventeen years Almost legal I still remember back in the day, loadnig an early RedHat distro on an 8086. I never got the reputation, but it seems OSS keeps following me. Introducing the idea of commodity hardware’ to an SGI/Solaris shop was an interesting evolution. Though watching the last of the brightly colored cases leave the server room was a little painful. It’s interesting to see the evolution once you can make a business case for transition. Though it is kind of sad when one of the engineers starts schooling the IT department.

Leave a Reply

Your email address will not be published. Required fields are marked *


*