A small utility for reading from a tty (or any device file, or any file for that matter), until a specified pattern is matched. The stream is echoed on STDOUT. I use it to read plots from a Tektronix 2211 oscilloscope, which emits plot commands in HP-GL format on a RS232 port:
function osc {
rm -f $1.hpgl
readtty /dev/tty.usbserial ";DF;" | pv > $1.hpgl
rm -f $1.eps
cat $1.hpgl | hp2xx -q -f- -m eps -a 2 > $1.eps
}
# Usage
osc plot
# Gives plot.eps file in current directoryThe conversion from HP-GL to EPS is done using hp2xx, a Homebrew formula for which exists at jagot/hp2xx.
