#!/bin/bash # not maemo specific. # # usage: u1233 READ? # This script takes commands like SYST:BATT? or FETC? as parameter # and fetches the result from KeySight U1233A via U1173A USB/IR adapter (ttyUSB0) dev=/dev/ttyUSB0 timeout=0.5 #why exec? cruft for this simple version, needed to keep filehandle open when we add loops etc exec 4>$dev 5<$dev stty 1:0:cbd:0:3:1c:7f:15:4:5:1:0:11:13:1a:0:12:f:17:16:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0 <&5 #prolly cruft, and didn't help flush the buffer when some other process keeps the file handle open (exec >/dev/bla) read -t 0 void <&5 docmd() { (read -t $timeout result <&5 echo $result)& echo "$@" >&4 wait } while docmd "$@"; do :;done