- From: David MacMahon <davidm_at_astro.berkeley.edu>
- Date: Wed, 19 Jul 2006 13:51:52 -0700
The attached patch adds a "-p" option to common.c that programs can use to decide whether to output raw values or physical values. The patch also includes modifications to the cmd and inp programs to use this flag. Here is what the output looks like without -p and with -p... $ ./cmd -f /dev/comedi1 -s 0 -r 1 -g -c 16 -n 5 -N 4 2>/dev/null 50959 48145 49835 49755 50823 50961 48146 49838 49757 50821 50957 48147 49837 49749 50823 50961 48143 49833 49754 50823 $ ./cmd -f /dev/comedi1 -s 0 -r 1 -g -c 16 -n 5 -N 4 -p 2>/dev/null 2.77676 2.34615 2.60494 2.59182 2.75494 2.77661 2.34585 2.60464 2.59289 2.75433 2.77646 2.3463 2.60418 2.59197 2.75555 2.77646 2.34585 2.60388 2.59319 2.75525 $ ./inp -f /dev/comedi1 -s 0 -r 1 -g -c 16 50960 $ inp -f /dev/comedi1 -s 0 -r 1 -g -c 16 -p 2.77523 V $ inp -f /dev/comedi1 -s 0 -r 1 -g -c 16 -v measuring device=/dev/comedi1 subdevice=0 channel=16 range=1 analog reference=0 50957 $ inp -f /dev/comedi1 -s 0 -r 1 -g -c 16 -p -v measuring device=/dev/comedi1 subdevice=0 channel=16 range=1 analog reference=0 [0,65535] -> [-5,5] 2.77554 V (50957 raw units) FWIW, the patch also sets OOR behavior to OOR_NUMBER for cmd and OOR_NAN for inp... $ inp -f /dev/comedi1 -s 0 -r 4 -g -c 16 -p Out of range [-0.5,0.5] $ cmd -f /dev/comedi1 -s 0 -r 4 -g -c 16 -n 5 -N 4 -p 2>/dev/null 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5 I chose OOR_NUMBER for cmd to make it easier to import the data dump into other programs (e.g. octave). You'll also notice that I used a tab instead of a space as the delimiter in cmd's physical output (raw output remains unchanged). It lines things up more neatly, but I don't really care whether it's a space or tab. Might also want to include a '+' in the format specifier to line up + and - values better. Dave
Attachments
- text/x-patch attachment: comedilib-demophys.patch
Received on 2006-07-19Z19:51:52