comedilib/demo/apply_cal.c

58 lines
1.2 KiB
C
Raw Permalink Normal View History

2003-04-22 00:04:14 +00:00
/*
* demo for changing between different (hardware-based) calibrations
2003-04-22 00:04:14 +00:00
* Part of Comedilib
*
* Copyright (c) 1999,2000 David A. Schleef <ds@schleef.org>
*
* This file may be freely modified, distributed, and combined with
* other software, as long as proper attribution is given in the
* source code.
*/
/*
* A little output demo
*/
#include <stdio.h>
#include <comedilib.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#include <errno.h>
#include <getopt.h>
#include <ctype.h>
#include "examples.h"
comedi_t *device;
int main(int argc, char *argv[])
{
lsampl_t data;
int ret;
struct parsed_options options;
2003-04-22 00:04:14 +00:00
init_parsed_options(&options);
parse_options(&options, argc, argv);
2003-04-22 00:04:14 +00:00
device=comedi_open(options.filename);
2003-04-22 00:04:14 +00:00
if(!device){
comedi_perror(options.filename);
exit(-1);
2003-04-22 00:04:14 +00:00
}
data = options.value;
if(options.verbose){
2003-04-22 00:04:14 +00:00
printf("writing %d to device=%s subdevice=%d channel=%d range=%d analog reference=%d\n",
data, options.filename, options.subdevice, options.channel, options.range, options.aref);
2003-04-22 00:04:14 +00:00
}
ret = comedi_apply_calibration(device, options.subdevice, options.channel, options.range, options.aref, NULL);
if(ret < 0){
comedi_perror(options.filename);
2003-04-22 00:04:14 +00:00
exit(0);
}
return 0;
}