Skip to content

Instantly share code, notes, and snippets.

@jcarrano
Created June 10, 2022 16:10
Show Gist options
  • Save jcarrano/009ef1ae13d1a6a0eebc27e220303d07 to your computer and use it in GitHub Desktop.
Save jcarrano/009ef1ae13d1a6a0eebc27e220303d07 to your computer and use it in GitHub Desktop.
Agilent 5462x Oscilloscope Screen Capture via Serial
#!/bin/sh
# Get a screen capture from an Agilent 5462x series oscilloscope vis serial port
# The device must use 57600 baud and DTR flow control.
# The image is in TIFF format and is output to stdout
TTYDEV=${1:-/dev/ttyUSB0}
stty -F $TTYDEV 57600 raw -echo min 0 time 5
exec 123<>$TTYDEV
echo '*IDN?' >&123
IFS=, read MANUFACTURER MODEL OTHER <&123
if [ "$MANUFACTURER" != "AGILENT TECHNOLOGIES" ] ; then
echo 'Unknown device (IDN? probe failed)' >&2
exit 1
fi
echo "Found model $MODEL" >&2
stty -F $TTYDEV 57600 raw -echo min 0 time 20
# ':DISP:DATA? TIFF, SCR' also works
echo ':PRINT? HIR,TIFF' >&123
# magick removes the agilent logo and fits the image aspect to the screen size
tail --bytes=+11 <&123 | magick - -crop 512x316+0+33 +repage -density 98x75 -
echo "Done" >&2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment