2000-02-02 05:14:23 +00:00
|
|
|
/*
|
2000-10-19 06:28:27 +00:00
|
|
|
* A little output demo
|
|
|
|
* 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
|
2000-02-02 05:14:23 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <comedilib.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <unistd.h>
|
2003-01-01 23:07:02 +00:00
|
|
|
#include <stdlib.h>
|
2000-02-02 05:14:23 +00:00
|
|
|
#include <errno.h>
|
|
|
|
#include <getopt.h>
|
|
|
|
#include <ctype.h>
|
2000-10-19 06:28:27 +00:00
|
|
|
#include "examples.h"
|
2000-02-02 05:14:23 +00:00
|
|
|
|
|
|
|
comedi_t *device;
|
|
|
|
|
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
lsampl_t data;
|
|
|
|
int ret;
|
2007-01-03 21:14:53 +00:00
|
|
|
struct parsed_options options;
|
2000-02-02 05:14:23 +00:00
|
|
|
|
2007-01-03 21:14:53 +00:00
|
|
|
init_parsed_options(&options);
|
|
|
|
parse_options(&options, argc, argv);
|
2000-02-02 05:14:23 +00:00
|
|
|
|
2007-01-03 21:14:53 +00:00
|
|
|
device = comedi_open(options.filename);
|
2000-02-02 05:14:23 +00:00
|
|
|
if(!device){
|
2007-01-03 21:14:53 +00:00
|
|
|
comedi_perror(options.filename);
|
|
|
|
exit(-1);
|
2000-02-02 05:14:23 +00:00
|
|
|
}
|
|
|
|
|
2007-01-03 21:14:53 +00:00
|
|
|
data = options.value;
|
|
|
|
if(options.verbose){
|
2000-02-02 05:14:23 +00:00
|
|
|
printf("writing %d to device=%s subdevice=%d channel=%d range=%d analog reference=%d\n",
|
2007-01-03 21:14:53 +00:00
|
|
|
data, options.filename, options.subdevice, options.channel, options.range, options.aref);
|
2000-02-02 05:14:23 +00:00
|
|
|
}
|
|
|
|
|
2007-01-03 21:14:53 +00:00
|
|
|
ret = comedi_data_write(device, options.subdevice, options.channel, options.range, options.aref, data);
|
|
|
|
if(ret < 0){
|
|
|
|
comedi_perror(options.filename);
|
|
|
|
exit(-1);
|
2000-02-02 05:14:23 +00:00
|
|
|
}
|
|
|
|
|
2007-01-03 21:14:53 +00:00
|
|
|
printf("%d\n", data);
|
2000-02-02 05:14:23 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|