From 5e8a77d52b3554e6a9989c7dfd5907df28c4e713 Mon Sep 17 00:00:00 2001 From: David Schleef Date: Sun, 3 Sep 2000 02:15:44 +0000 Subject: [PATCH] added lots of more information --- demo/info.c | 164 +++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 156 insertions(+), 8 deletions(-) diff --git a/demo/info.c b/demo/info.c index 093f3fb..e60c9e8 100644 --- a/demo/info.c +++ b/demo/info.c @@ -10,6 +10,8 @@ #include #include +void get_command_stuff(comedi_t *it,int s); + void help(void) { fprintf(stderr,"info \n"); @@ -62,22 +64,41 @@ int main(int argc,char *argv[]) printf("subdevice %d:\n",i); type=comedi_get_subdevice_type(it,i); printf(" type: %d (%s)\n",type,subdevice_types[type]); + if(type==COMEDI_SUBD_UNUSED) + continue; n_chans=comedi_get_n_channels(it,i); printf(" number of channels: %d\n",n_chans); - printf(" max data value: %d\n",comedi_get_maxdata(it,i,0)); - n_ranges=comedi_get_n_ranges(it,i,0); - printf(" number of ranges: %d\n",n_ranges); + if(!comedi_maxdata_is_chan_specific(it,i)){ + printf(" max data value: %d\n",comedi_get_maxdata(it,i,0)); + }else{ + printf(" max data value: (channel specific)\n"); + for(chan=0;chanmin,rng->max); } printf("\n"); + }else{ + for(chan=0;chanmin,rng->max); + } + printf("\n"); + } } + printf(" command:\n"); + get_command_stuff(it,i); } return 0; @@ -95,3 +116,130 @@ char *tobinary(char *s,int bits,int n) return s; } +char *cmd_src(int src,char *buf) +{ + buf[0]=0; + + if(src&TRIG_NONE)strcat(buf,"none|"); + if(src&TRIG_NOW)strcat(buf,"now|"); + if(src&TRIG_FOLLOW)strcat(buf,"follow|"); + if(src&TRIG_TIME)strcat(buf,"time|"); + if(src&TRIG_TIMER)strcat(buf,"timer|"); + if(src&TRIG_COUNT)strcat(buf,"count|"); + if(src&TRIG_EXT)strcat(buf,"ext|"); + if(src&TRIG_INT)strcat(buf,"int|"); + + if(strlen(buf)==0){ + sprintf(buf,"unknown(0x%02x)",src); + }else{ + buf[strlen(buf)-1]=0; + } + + return buf; +} + +void probe_max_1chan(comedi_t *it,int s); + +int comedi_get_cmd_src_mask(comedi_t *it,unsigned int s,comedi_cmd *cmd) +{ + memset(cmd,0,sizeof(*cmd)); + + cmd->subdev = s; + + cmd->flags = 0; + + cmd->start_src = TRIG_ANY; + cmd->scan_begin_src = TRIG_ANY; + cmd->convert_src = TRIG_ANY; + cmd->scan_end_src = TRIG_ANY; + cmd->stop_src = TRIG_ANY; + + return comedi_command_test(it,cmd); +} + + +int comedi_get_cmd_fast_1chan(comedi_t *it,unsigned int s,comedi_cmd *cmd) +{ + int ret; + + comedi_get_cmd_src_mask(it,s,cmd); + + cmd->chanlist_len = 1; + + cmd->scan_end_src = TRIG_COUNT; + cmd->scan_end_arg = 1; + + if(cmd->convert_src&TRIG_TIMER){ + if(cmd->scan_begin_src&TRIG_FOLLOW){ + cmd->convert_src = TRIG_TIMER; + cmd->scan_begin_src = TRIG_FOLLOW; + }else{ + cmd->convert_src = TRIG_TIMER; + cmd->scan_begin_src = TRIG_TIMER; + } + }else{ + printf("can't do timed?!?\n"); + return; + } + if(cmd->stop_src&TRIG_COUNT){ + cmd->stop_src=TRIG_COUNT; + cmd->stop_arg=2; + }else if(cmd->stop_src&TRIG_NONE){ + cmd->stop_src=TRIG_NONE; + cmd->stop_arg=0; + }else{ + printf("can't find a good stop_src\n"); + return; + } + + ret=comedi_command_test(it,cmd); + if(ret==3){ + /* good */ + ret=comedi_command_test(it,cmd); + } + if(ret==4 || ret==0){ + return 0; + } + return -1; +} + +void get_command_stuff(comedi_t *it,int s) +{ + comedi_cmd cmd; + char buf[100]; + + if(comedi_get_cmd_src_mask(it,s,&cmd)<0){ + printf(" not supported\n"); + }else{ + printf(" start: %s\n",cmd_src(cmd.start_src,buf)); + printf(" scan_begin: %s\n",cmd_src(cmd.scan_begin_src,buf)); + printf(" convert: %s\n",cmd_src(cmd.convert_src,buf)); + printf(" scan_end: %s\n",cmd_src(cmd.scan_end_src,buf)); + printf(" stop: %s\n",cmd_src(cmd.stop_src,buf)); + + probe_max_1chan(it,s); + } +} + +void probe_max_1chan(comedi_t *it,int s) +{ + comedi_cmd cmd; + char buf[100]; + + printf(" command fast 1chan:\n"); + if(comedi_get_cmd_fast_1chan(it,s,&cmd)<0){ + printf(" not supported\n"); + }else{ + printf(" start: %s %d\n", + cmd_src(cmd.start_src,buf),cmd.start_arg); + printf(" scan_begin: %s %d\n", + cmd_src(cmd.scan_begin_src,buf),cmd.scan_begin_arg); + printf(" convert: %s %d\n", + cmd_src(cmd.convert_src,buf),cmd.convert_arg); + printf(" scan_end: %s %d\n", + cmd_src(cmd.scan_end_src,buf),cmd.scan_end_arg); + printf(" stop: %s %d\n", + cmd_src(cmd.stop_src,buf),cmd.stop_arg); + } +} + -- 2.26.2