#define N_SAMPLES 10000
-#define BUFSZ N_SAMPLES*sizeof(sampl_t)
-
#define MAPLEN 20480
sigjmp_buf jump_env;
unsigned char *map;
unsigned int flags;
int i;
+ unsigned sample_size;
flags = comedi_get_subdevice_flags(device,subdevice);
printf("not applicable\n");
return 0;
}
+ if(flags & SDF_LSAMPL) sample_size = sizeof(lsampl_t);
+ else sample_size = sizeof(sampl_t);
if(comedi_get_cmd_generic_timed(device, subdevice, &cmd, 1, 1)<0){
printf("E: comedi_get_cmd_generic_timed failed\n");
return 0;
}
- buf=malloc(BUFSZ);
+ buf=malloc(sample_size * N_SAMPLES);
map=mmap(NULL,MAPLEN,PROT_READ,MAP_SHARED,comedi_fileno(device),0);
if(!map){
go=1;
b=buf;
while(go){
- ret = read(comedi_fileno(device),b,BUFSZ);
+ ret = read(comedi_fileno(device), b, N_SAMPLES * sample_size);
if(ret<0){
if(errno==EAGAIN){
usleep(10000);