#!/bin/bash # usage: rigol-snapshot # e.g.: rigol-snapshot pics/test.jpg # fetches a bmp formatted screenshot picture from Rigol DS1000 series, via ethernet # TODO: proper handling of broken connection to Rigol, check netcat / read return code : ${RIGOL_IP:=192.168.4.52} # adapt to your local situation, I used fixed DHCP IP for rigol in my router echo ':disp:data?' | netcat -w 1 $RIGOL_IP 5555\ | (shopt -s extglob; sleep 0.1 read -N 1 -t 0.1 magichash; read -N 1 -t 0.1 lenofnum; read -N $lenofnum -t 0.1 numofbytes; #echo -e "1.magic: $magichash; 2.len_hdr: $lenofnum: \"${numofbytes}\"=bytes-netto-data\nreading..." >&2 head -c ${numofbytes##*(0)} ; # seems either this cleanup of remaining bytes, or the above sleep 0.1, is needed to avoid every ~2nd run fail echo -e "cleanup: \n`od -x`" >&2 )\ | convert bmp:- $1 rc=$? echo "returncode: $rc" >&2 exit $rc #legacy #echo ':disp:data?' | netcat 192.168.4.52 5555 | dd bs=1M iflag=skip_bytes skip=11 of=$1 #echo ':disp:data?' | netcat 192.168.4.52 5555 | dd bs=1M iflag=skip_bytes skip=11 | convert bmp:- $1 #echo ':disp:data?' | netcat 192.168.4.52 5555 | head -c -3 | dd bs=1M iflag=skip_bytes skip=11 | convert bmp:- $1