additional tests, fixes, move some functions to ../lib
This commit is contained in:
parent
229b4cd58c
commit
698938d995
11 changed files with 255 additions and 361 deletions
|
@ -2,12 +2,12 @@
|
|||
|
||||
|
||||
CFLAGS =-I ../include -I . -O2 -Wall -Wstrict-prototypes
|
||||
LDFLAGS=-L../lib/ -lcomedi
|
||||
LDFLAGS=-L../lib/ -lcomedi -static
|
||||
|
||||
|
||||
TARG=comedi_test
|
||||
OBJS=main.o mode0_read.o insn_read.o info.o cmd_1.o insn_read_time.o \
|
||||
cmd_2.o mmap.o select.o cmd_3.o bufconfig.o
|
||||
cmd_2.o mmap.o select.o cmd_3.o bufconfig.o lib.o
|
||||
|
||||
all: $(TARG)
|
||||
|
||||
|
|
|
@ -12,25 +12,59 @@
|
|||
#include <string.h>
|
||||
#include "comedi_test.h"
|
||||
|
||||
int test_bufconfig_without_cmd(void);
|
||||
int test_bufconfig_with_cmd(void);
|
||||
|
||||
int test_bufconfig(void)
|
||||
{
|
||||
int flags;
|
||||
|
||||
flags = comedi_get_subdevice_flags(device,subdevice);
|
||||
|
||||
if(flags&SDF_CMD){
|
||||
return test_bufconfig_with_cmd();
|
||||
}else{
|
||||
return test_bufconfig_without_cmd();
|
||||
}
|
||||
}
|
||||
|
||||
int test_bufconfig_without_cmd(void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = comedi_get_buffer_size(device,subdevice);
|
||||
if(ret<0){
|
||||
if(errno==ENODEV){
|
||||
printf("got ENODEV, good\n");
|
||||
}else{
|
||||
printf("E: comedi_get_buffer_size: %s\n",
|
||||
strerror(errno));
|
||||
}
|
||||
}else if(ret==0){
|
||||
printf("buffer length is 0, good\n");
|
||||
}else{
|
||||
printf("E: comedi_get_buffer_size returned %d\n",ret);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int test_bufconfig_with_cmd(void)
|
||||
{
|
||||
int ret;
|
||||
int len;
|
||||
int maxlen;
|
||||
|
||||
printf("joe\n");
|
||||
|
||||
ret = comedi_get_buffer_size(device,subdevice);
|
||||
if(ret<0){
|
||||
perror("comedi_get_buffer_size");
|
||||
printf("E: comedi_get_buffer_size: %s\n",strerror(errno));
|
||||
}else{
|
||||
printf("buffer size %d\n",ret);
|
||||
}
|
||||
|
||||
maxlen = comedi_get_max_buffer_size(device,subdevice);
|
||||
if(maxlen<0){
|
||||
perror("comedi_get_max_buffer_size");
|
||||
printf("E: comedi_get_max_buffer_size: %s\n",strerror(errno));
|
||||
}else{
|
||||
printf("max buffer size %d\n",maxlen);
|
||||
}
|
||||
|
@ -39,34 +73,47 @@ int test_bufconfig(void)
|
|||
printf("setting buffer size to %d\n",len);
|
||||
ret = comedi_set_buffer_size(device,subdevice,len);
|
||||
if(ret<0){
|
||||
perror("comedi_set_buffer_size");
|
||||
printf("E: comedi_set_buffer_size: %s\n",strerror(errno));
|
||||
}else{
|
||||
printf("buffer size set to %d\n",ret);
|
||||
}
|
||||
|
||||
ret = comedi_get_buffer_size(device,subdevice);
|
||||
if(ret<0){
|
||||
perror("comedi_get_buffer_size");
|
||||
printf("E: comedi_get_buffer_size: %s\n",strerror(errno));
|
||||
}else{
|
||||
printf("buffer size now at %d\n",ret);
|
||||
if(ret != len){
|
||||
printf("E: buffer size didn't get set: %d (expected %d)\n",
|
||||
ret,len);
|
||||
}
|
||||
}
|
||||
|
||||
len=maxlen+4096;
|
||||
printf("setting buffer size past limit, %d\n",len);
|
||||
ret = comedi_set_buffer_size(device,subdevice,len);
|
||||
if(ret<0){
|
||||
perror("comedi_set_buffer_size");
|
||||
if(errno==EPERM){
|
||||
printf("got EPERM, good\n");
|
||||
}else{
|
||||
printf("E: wrong error comedi_set_buffer_size: %s",
|
||||
strerror(errno));
|
||||
}
|
||||
}else{
|
||||
printf("buffer size now at %d\n",ret);
|
||||
printf("E: comedi_set_buffer_size: didn't get error\n");
|
||||
}
|
||||
|
||||
len=maxlen;
|
||||
printf("setting buffer size to max, %d\n",len);
|
||||
ret = comedi_set_buffer_size(device,subdevice,len);
|
||||
if(ret<0){
|
||||
perror("comedi_set_buffer_size");
|
||||
printf("E: comedi_set_buffer_size: %s\n",strerror(errno));
|
||||
}else{
|
||||
printf("buffer size now at %d\n",ret);
|
||||
if(ret != len){
|
||||
printf("E: buffer size didn't get set: %d (expected %d)\n",
|
||||
ret,len);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
161
testing/cmd_1.c
161
testing/cmd_1.c
|
@ -12,11 +12,35 @@
|
|||
#include <string.h>
|
||||
#include "comedi_test.h"
|
||||
|
||||
int comedi_get_cmd_src_mask(comedi_t *it,unsigned int s,comedi_cmd *cmd);
|
||||
int comedi_get_cmd_fast_1chan(comedi_t *it,unsigned int s,comedi_cmd *cmd);
|
||||
void probe_max_1chan(comedi_t *it,int s);
|
||||
char *tobinary(char *s,int bits,int n);
|
||||
char *cmd_src(int src,char *buf);
|
||||
int count_bits(unsigned int bits);
|
||||
|
||||
int test_cmd_no_cmd(void)
|
||||
{
|
||||
int ret;
|
||||
comedi_cmd cmd;
|
||||
|
||||
if(comedi_get_subdevice_flags(device,subdevice)&SDF_CMD){
|
||||
printf("not applicable\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
ret = comedi_get_cmd_src_mask(device,subdevice,&cmd);
|
||||
if(ret<0){
|
||||
if(errno == EIO){
|
||||
printf("got EIO, good\n");
|
||||
}else{
|
||||
printf("E: comedi_get_cmd_src_mask: %s\n",
|
||||
strerror(errno));
|
||||
}
|
||||
}else{
|
||||
printf("E: comedi_get_cmd_src_mask returned %d\n",ret);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int test_cmd_probe_src_mask(void)
|
||||
{
|
||||
|
@ -24,11 +48,16 @@ int test_cmd_probe_src_mask(void)
|
|||
char buf[100];
|
||||
int ret;
|
||||
|
||||
if(!(comedi_get_subdevice_flags(device,subdevice)&SDF_CMD)){
|
||||
printf("not applicable\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
printf("rev 1\n");
|
||||
|
||||
ret = comedi_get_cmd_src_mask(device,subdevice,&cmd);
|
||||
if(ret<0){
|
||||
printf("not supported\n");
|
||||
printf("E: comedi_get_cmd_src_mask failed\n");
|
||||
return 0;
|
||||
}
|
||||
printf("command source mask:\n");
|
||||
|
@ -46,8 +75,13 @@ int test_cmd_probe_fast_1chan(void)
|
|||
comedi_cmd cmd;
|
||||
char buf[100];
|
||||
|
||||
if(!(comedi_get_subdevice_flags(device,subdevice)&SDF_CMD)){
|
||||
printf("not applicable\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
printf("command fast 1chan:\n");
|
||||
if(comedi_get_cmd_fast_1chan(device,subdevice,&cmd)<0){
|
||||
if(comedi_get_cmd_generic_timed(device,subdevice,&cmd)<0){
|
||||
printf(" not supported\n");
|
||||
return 0;
|
||||
}
|
||||
|
@ -76,7 +110,12 @@ int test_cmd_read_fast_1chan(void)
|
|||
int total=0;
|
||||
int ret;
|
||||
|
||||
if(comedi_get_cmd_fast_1chan(device,subdevice,&cmd)<0){
|
||||
if(!(comedi_get_subdevice_flags(device,subdevice)&SDF_CMD)){
|
||||
printf("not applicable\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(comedi_get_cmd_generic_timed(device,subdevice,&cmd)<0){
|
||||
printf(" not supported\n");
|
||||
return 0;
|
||||
}
|
||||
|
@ -111,6 +150,52 @@ int test_cmd_read_fast_1chan(void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int test_cmd_logic_bug(void)
|
||||
{
|
||||
comedi_cmd cmd;
|
||||
int ret;
|
||||
|
||||
if(!(comedi_get_subdevice_flags(device,subdevice)&SDF_CMD)){
|
||||
printf("not applicable\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
printf("rev 1\n");
|
||||
|
||||
ret = comedi_get_cmd_src_mask(device,subdevice,&cmd);
|
||||
if(ret<0){
|
||||
printf("E: comedi_get_cmd_src_mask failed\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(count_bits(cmd.start_src)>1)cmd.start_src=0;
|
||||
if(count_bits(cmd.scan_begin_src)>1)cmd.scan_begin_src=0;
|
||||
if(count_bits(cmd.convert_src)>1)cmd.convert_src=0;
|
||||
if(count_bits(cmd.scan_end_src)>1)cmd.scan_end_src=0;
|
||||
if(count_bits(cmd.stop_src)>1)cmd.stop_src=0;
|
||||
|
||||
ret = comedi_command_test(device,&cmd);
|
||||
if(ret!=1){
|
||||
printf("E: command_test returned %d, expected 1, (allowed src==0)\n",ret);
|
||||
}else{
|
||||
printf("command_test returned %d, good\n",ret);
|
||||
}
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int count_bits(unsigned int bits)
|
||||
{
|
||||
int ret=0;
|
||||
while(bits){
|
||||
if(bits&1)ret++;
|
||||
bits>>=1;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
char *tobinary(char *s,int bits,int n)
|
||||
{
|
||||
int bit=1<<n;
|
||||
|
@ -146,69 +231,3 @@ char *cmd_src(int src,char *buf)
|
|||
}
|
||||
|
||||
|
||||
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;
|
||||
|
||||
ret = comedi_get_cmd_src_mask(it,s,cmd);
|
||||
if(ret<0)return ret;
|
||||
|
||||
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 -1;
|
||||
}
|
||||
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 -1;
|
||||
}
|
||||
|
||||
ret=comedi_command_test(it,cmd);
|
||||
if(ret==3){
|
||||
printf("ret==3\n");
|
||||
/* good */
|
||||
ret=comedi_command_test(it,cmd);
|
||||
}
|
||||
if(ret==4 || ret==0){
|
||||
return 0;
|
||||
}
|
||||
printf("W: comedi_command_test() returned %d\n",ret);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,8 +12,6 @@
|
|||
#include <string.h>
|
||||
#include "comedi_test.h"
|
||||
|
||||
static int comedi_get_cmd_src_mask(comedi_t *it,unsigned int s,comedi_cmd *cmd);
|
||||
static int comedi_get_cmd_fast_1chan(comedi_t *it,unsigned int s,comedi_cmd *cmd);
|
||||
static int get_chunks_per_length(int length);
|
||||
|
||||
#define BUFSZ 10000
|
||||
|
@ -22,6 +20,11 @@ int test_cmd_fifo_depth_check(void)
|
|||
{
|
||||
int len;
|
||||
|
||||
if(!(comedi_get_subdevice_flags(device,subdevice)&SDF_CMD)){
|
||||
printf("not applicable\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
for(len=64;len<65536;len<<=1){
|
||||
printf("%d, %d\n",len,get_chunks_per_length(len));
|
||||
}
|
||||
|
@ -39,7 +42,7 @@ static int get_chunks_per_length(int length)
|
|||
int ret;
|
||||
int chunks=0;
|
||||
|
||||
if(comedi_get_cmd_fast_1chan(device,subdevice,&cmd)<0){
|
||||
if(comedi_get_cmd_generic_timed(device,subdevice,&cmd)<0){
|
||||
printf(" not supported\n");
|
||||
return 0;
|
||||
}
|
||||
|
@ -73,67 +76,3 @@ static int get_chunks_per_length(int length)
|
|||
return chunks;
|
||||
}
|
||||
|
||||
static 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);
|
||||
}
|
||||
|
||||
|
||||
static int comedi_get_cmd_fast_1chan(comedi_t *it,unsigned int s,comedi_cmd *cmd)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = comedi_get_cmd_src_mask(it,s,cmd);
|
||||
if(ret<0)return ret;
|
||||
|
||||
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 -1;
|
||||
}
|
||||
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 -1;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,8 +12,6 @@
|
|||
#include <string.h>
|
||||
#include "comedi_test.h"
|
||||
|
||||
static int comedi_get_cmd_src_mask(comedi_t *it,unsigned int s,comedi_cmd *cmd);
|
||||
static int comedi_get_cmd_fast_1chan(comedi_t *it,unsigned int s,comedi_cmd *cmd);
|
||||
static int do_continuous(int multiplier);
|
||||
|
||||
#define BUFSZ 10000
|
||||
|
@ -22,6 +20,11 @@ int test_cmd_continuous(void)
|
|||
{
|
||||
int mult;
|
||||
|
||||
if(!(comedi_get_subdevice_flags(device,subdevice)&SDF_CMD)){
|
||||
printf("not applicable\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* as if doing _one_ infinite loop wasn't slow enough,
|
||||
* we loop through with higher and higher multipliers,
|
||||
* in case the test fails because of latency problems */
|
||||
|
@ -45,11 +48,12 @@ static int do_continuous(int multiplier)
|
|||
unsigned long total_secs = 0;
|
||||
struct timeval tv,start_tv;
|
||||
|
||||
if(comedi_get_cmd_fast_1chan(device,subdevice,&cmd)<0){
|
||||
if(comedi_get_cmd_generic_timed(device,subdevice,&cmd)<0){
|
||||
printf(" not supported\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
cmd.flags = TRIG_RT;
|
||||
cmd.chanlist = chanlist;
|
||||
cmd.scan_end_arg = 1;
|
||||
cmd.stop_src = TRIG_NONE;
|
||||
|
@ -107,71 +111,16 @@ static int do_continuous(int multiplier)
|
|||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
double t;
|
||||
|
||||
t=tv.tv_sec+1e-6*tv.tv_usec;
|
||||
printf("end: %0.3f %d (%g) %d (%g)\n",
|
||||
t,
|
||||
chunks,chunks/t,
|
||||
total,total/t);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static 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);
|
||||
}
|
||||
|
||||
|
||||
static int comedi_get_cmd_fast_1chan(comedi_t *it,unsigned int s,comedi_cmd *cmd)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = comedi_get_cmd_src_mask(it,s,cmd);
|
||||
if(ret<0)return ret;
|
||||
|
||||
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 -1;
|
||||
}
|
||||
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 -1;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -9,5 +9,7 @@ extern int subdevice;
|
|||
|
||||
extern int verbose;
|
||||
|
||||
extern unsigned int capabilities;
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -16,12 +16,14 @@
|
|||
int test_insn_read(void)
|
||||
{
|
||||
comedi_insn it;
|
||||
lsampl_t data;
|
||||
int save_errno;
|
||||
lsampl_t data = 0xffffffff;
|
||||
int ret;
|
||||
int type;
|
||||
|
||||
printf("rev 1\n");
|
||||
|
||||
type = comedi_get_subdevice_type(device,subdevice);
|
||||
|
||||
memset(&it,0,sizeof(it));
|
||||
it.subdev = subdevice;
|
||||
it.insn = INSN_READ;
|
||||
|
@ -30,11 +32,27 @@ int test_insn_read(void)
|
|||
it.data = &data;
|
||||
|
||||
ret = comedi_do_insn(device,&it);
|
||||
save_errno = errno;
|
||||
|
||||
printf("comedi_do_insn: %d\n",ret);
|
||||
if(ret<0){
|
||||
printf("W: comedi_do_insn: errno=%d %s\n",save_errno,strerror(save_errno));
|
||||
if(type==COMEDI_SUBD_UNUSED){
|
||||
if(ret<0){
|
||||
if(errno==EIO){
|
||||
printf("comedi_do_insn: EIO, good\n");
|
||||
}else{
|
||||
printf("E: comedi_do_insn: %s\n",
|
||||
strerror(errno));
|
||||
}
|
||||
}else{
|
||||
printf("E: comedi_do_insn: returned %d, expected error\n",
|
||||
ret);
|
||||
}
|
||||
}else{
|
||||
if(ret<0){
|
||||
printf("E: comedi_do_insn: %s\n",strerror(errno));
|
||||
}else if(ret==1){
|
||||
printf("comedi_do_insn returned 1, good\n");
|
||||
}else{
|
||||
printf("E: comedi_do_insn returned %d\n",ret);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -24,6 +24,11 @@ int test_insn_read_time(void)
|
|||
|
||||
printf("rev 1\n");
|
||||
|
||||
if(comedi_get_subdevice_type(device,subdevice)==COMEDI_SUBD_UNUSED){
|
||||
printf("not applicable\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
memset(&il,0,sizeof(il));
|
||||
memset(insn,0,sizeof(insn));
|
||||
|
||||
|
|
|
@ -27,9 +27,11 @@ int test_info(void);
|
|||
int test_mode0_read(void);
|
||||
int test_insn_read(void);
|
||||
int test_insn_read_time(void);
|
||||
int test_cmd_no_cmd(void);
|
||||
int test_cmd_probe_src_mask(void);
|
||||
int test_cmd_probe_fast_1chan(void);
|
||||
int test_cmd_read_fast_1chan(void);
|
||||
int test_cmd_logic_bug(void);
|
||||
int test_cmd_fifo_depth_check(void);
|
||||
int test_mmap(void);
|
||||
int test_read_select(void);
|
||||
|
@ -49,9 +51,11 @@ struct test_struct tests[]={
|
|||
{ "mode0_read", test_mode0_read, TEST_STD },
|
||||
{ "insn_read", test_insn_read, TEST_STD },
|
||||
{ "insn_read_time", test_insn_read_time, TEST_STD },
|
||||
{ "cmd_no_cmd", test_cmd_no_cmd, TEST_STD },
|
||||
{ "cmd_probe_src_mask", test_cmd_probe_src_mask, TEST_STD },
|
||||
{ "cmd_probe_fast_1chan", test_cmd_probe_fast_1chan, TEST_STD },
|
||||
{ "cmd_read_fast_1chan", test_cmd_read_fast_1chan, TEST_STD },
|
||||
{ "cmd_logic_bug", test_cmd_logic_bug, TEST_STD },
|
||||
{ "cmd_fifo_depth_check", test_cmd_fifo_depth_check, TEST_STD },
|
||||
{ "mmap", test_mmap, TEST_STD },
|
||||
{ "read_select", test_read_select, TEST_STD },
|
||||
|
@ -64,6 +68,9 @@ int only_subdevice;
|
|||
int verbose;
|
||||
char *only_test;
|
||||
|
||||
static void get_capabilities(unsigned int subd);
|
||||
static void print_device_info(void);
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int c;
|
||||
|
@ -96,11 +103,15 @@ int main(int argc, char *argv[])
|
|||
device = comedi_open(filename);
|
||||
if(!device){
|
||||
printf("E: comedi_open(\"%s\"): %s\n",filename,strerror(errno));
|
||||
exit(0);
|
||||
}
|
||||
|
||||
print_device_info();
|
||||
|
||||
for(;subdevice<comedi_get_n_subdevices(device);subdevice++){
|
||||
printf("I:\n");
|
||||
printf("I: subdevice %d\n",subdevice);
|
||||
get_capabilities(subdevice);
|
||||
if(only_test){
|
||||
for(i=0;i<n_tests;i++){
|
||||
if(!strcmp(tests[i].name,only_test)){
|
||||
|
@ -122,5 +133,31 @@ int main(int argc, char *argv[])
|
|||
return 0;
|
||||
}
|
||||
|
||||
unsigned int capabilities;
|
||||
|
||||
static void get_capabilities(unsigned int subd)
|
||||
{
|
||||
int type;
|
||||
int flags;
|
||||
|
||||
capabilities = 0;
|
||||
|
||||
type = comedi_get_subdevice_type(device,subd);
|
||||
|
||||
flags = comedi_get_subdevice_flags(device,subd);
|
||||
|
||||
}
|
||||
|
||||
static void print_device_info(void)
|
||||
{
|
||||
int vers = comedi_get_version_code(device);
|
||||
|
||||
printf("I: Comedi version: %d.%d.%d\n",(vers>>16)&0xff,
|
||||
(vers>>8)&0xff,vers&0xff);
|
||||
printf("I: Comedilib version: unknown =)\n");
|
||||
printf("I: driver name: %s\n",comedi_get_driver_name(device));
|
||||
printf("I: device name: %s\n",comedi_get_board_name(device));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -20,8 +20,6 @@
|
|||
/* XXX this should come from elsewhere */
|
||||
#define PAGE_SIZE 4096
|
||||
|
||||
static int comedi_get_cmd_fast_1chan(comedi_t *it,unsigned int s,comedi_cmd *cmd);
|
||||
|
||||
#define N_SAMPLES 10000
|
||||
|
||||
#define BUFSZ N_SAMPLES*sizeof(sampl_t)
|
||||
|
@ -66,15 +64,20 @@ int test_mmap(void)
|
|||
void *b, *adr;
|
||||
sampl_t *map;
|
||||
|
||||
if(!(comedi_get_subdevice_flags(device,subdevice)&SDF_CMD)){
|
||||
printf("not applicable\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(comedi_get_cmd_generic_timed(device,subdevice,&cmd)<0){
|
||||
printf("E: comedi_get_cmd_generic_timed failed\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
setup_segfaulter();
|
||||
|
||||
buf=malloc(BUFSZ);
|
||||
|
||||
if(comedi_get_cmd_fast_1chan(device,subdevice,&cmd)<0){
|
||||
printf(" not supported\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
map=mmap(NULL,MAPLEN,PROT_READ,MAP_SHARED,comedi_fileno(device),0);
|
||||
if(!map){
|
||||
printf("E: mmap() failed\n");
|
||||
|
@ -140,67 +143,3 @@ int test_mmap(void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static 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);
|
||||
}
|
||||
|
||||
|
||||
static int comedi_get_cmd_fast_1chan(comedi_t *it,unsigned int s,comedi_cmd *cmd)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = comedi_get_cmd_src_mask(it,s,cmd);
|
||||
if(ret<0)return ret;
|
||||
|
||||
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 -1;
|
||||
}
|
||||
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 -1;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,8 +12,6 @@
|
|||
#include <string.h>
|
||||
#include "comedi_test.h"
|
||||
|
||||
static int comedi_get_cmd_src_mask(comedi_t *it,unsigned int s,comedi_cmd *cmd);
|
||||
static int comedi_get_cmd_fast_1chan(comedi_t *it,unsigned int s,comedi_cmd *cmd);
|
||||
|
||||
#define BUFSZ 10000
|
||||
|
||||
|
@ -30,8 +28,13 @@ int test_read_select(void)
|
|||
fd_set rdset;
|
||||
struct timeval timeout;
|
||||
|
||||
if(comedi_get_cmd_fast_1chan(device,subdevice,&cmd)<0){
|
||||
printf(" not supported\n");
|
||||
if(!(comedi_get_subdevice_flags(device,subdevice)&SDF_CMD)){
|
||||
printf("not applicable\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(comedi_get_cmd_generic_timed(device,subdevice,&cmd)<0){
|
||||
printf("E: comedi_get_cmd_generic_timed failed\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -78,67 +81,3 @@ int test_read_select(void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static 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);
|
||||
}
|
||||
|
||||
|
||||
static int comedi_get_cmd_fast_1chan(comedi_t *it,unsigned int s,comedi_cmd *cmd)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = comedi_get_cmd_src_mask(it,s,cmd);
|
||||
if(ret<0)return ret;
|
||||
|
||||
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 -1;
|
||||
}
|
||||
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 -1;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue