Hi, I have a problem with sample program 3

Hi, I have a problem with sample program 3

I followed the tutorial and named this program as my3.c

#include <stdio.h>
#include <comedilib.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <sys/time.h>
#include <unistd.h>
#include "examples.h"

/*
* This example does 3 instructions in one system call. It does
* a gettimeofday() call, then reads N_SAMPLES samples from an
* analog input, and the another gettimeofday() call.
*/

#define MAX_SAMPLES 128

comedi_t *device;

int main(int argc, char *argv[])
{
int ret,i;
comedi_insn insn[3];
comedi_insnlist il;
struct timeval t1,t2;
lsampl_t data[MAX_SAMPLES];

parse_options(argc,argv);


device=comedi_open(filename);
if(!device){
comedi_perror(filename);
exit(0);
}

if(verbose){
printf("measuring device=%s subdevice=%d channel=%d range=%d analog
reference=%d\n",
filename,subdevice,channel,range,aref);
}

/* Set up a the "instruction list", which is just a pointer
* to the array of instructions and the number of instructions.
*/
il.n_insns=3;
il.insns=insn;

/* Instruction 0: perform a gettimeofday() */
insn[0].insn=INSN_GTOD;
insn[0].n=2;
insn[0].data=(void *)&t1;

/* Instruction 1: do 10 analog input reads */
insn[1].insn=INSN_READ;
insn[1].n=n_scan;
insn[1].data=data;
insn[1].subdev=subdevice;
insn[1].chanspec=CR_PACK(channel,range,aref);

/* Instruction 2: perform a gettimeofday() */
insn[2].insn=INSN_GTOD;
insn[2].n=2;
insn[2].data=(void *)&t2;

ret=comedi_do_insnlist(device,&il);
if(ret<0){
comedi_perror(filename);
exit(0);
}

printf("initial time: %ld.%06ld\n",t1.tv_sec,t1.tv_usec);
for(i=0;i<n_scan;i++){
printf("%d\n",data[i]);
}
printf("final time: %ld.%06ld\n",t2.tv_sec,t2.tv_usec);

printf("difference (us): %ld\n",(t2.tv_sec-t1.tv_sec)*1000000+
(t2.tv_usec-t1.tv_usec));

return 0;
}

But when compiling with "cc my3.c -lcomedi -lm -o my3",

it returns the error:

my3.c: In function 'main':
my3.c:28: warning: passing argument 1 of 'parse_options' makes pointer from
integer without a cast
my3.c:28: warning: passing argument 2 of 'parse_options' makes integer from
pointer without a cast
my3.c:28: error: too few arguments to function 'parse_options'
my3.c:31: error: 'filename' undeclared (first use in this function)
my3.c:31: error: (Each undeclared identifier is reported only once
my3.c:31: error: for each function it appears in.)
my3.c:34: warning: incompatible implicit declaration of built-in function
'exit'my3.c:37: error: 'verbose' undeclared (first use in this function)
my3.c:39: error: 'subdevice' undeclared (first use in this function)
my3.c:39: error: 'channel' undeclared (first use in this function)
my3.c:39: error: 'range' undeclared (first use in this function)
my3.c:39: error: 'aref' undeclared (first use in this function)
my3.c:55: error: 'n_scan' undeclared (first use in this function)
my3.c:68: warning: incompatible implicit declaration of built-in function
'exit'

Does any one have a idea about this?

Thanks a lot!

Kelvin

Received on 2007-01-10Z23:57:46