添加测试命令 test_input test_output 测试输入输出通道
This commit is contained in:
@@ -11,6 +11,8 @@
|
||||
#include "process.h"
|
||||
#include "tran_for_coder2ch.h"
|
||||
#include "coder_judge.h"
|
||||
#include "commend.h"
|
||||
#include "mystring.h"
|
||||
|
||||
|
||||
/*
|
||||
@@ -613,3 +615,55 @@ transmit_export(ym_checker,0x90,process_pccmd)
|
||||
|
||||
|
||||
|
||||
|
||||
// 定义输入输出通道测试
|
||||
|
||||
static int test_input(list_def *argv)
|
||||
{
|
||||
gpioin_def *in=0;
|
||||
list_def *states=list_temp(list_creat_int());
|
||||
char gpioin_name[]="gpioin0";
|
||||
// 这里默认驱动已经打开
|
||||
for(int i=0;i<10;i++)
|
||||
{
|
||||
gpioin_name[6]='0'+i;
|
||||
in=dev_get(gpioin_name);
|
||||
if(in){
|
||||
list_append_int(states,in->state(in));
|
||||
}
|
||||
}
|
||||
cmd_print("input state:%s.",str_temp(list_string(states)));
|
||||
return 0;
|
||||
}
|
||||
|
||||
commend_export(test_input,test_input,"print the input state.")
|
||||
|
||||
|
||||
|
||||
|
||||
static int test_output(list_def *argv)
|
||||
{
|
||||
gpioout_def *out=0;
|
||||
char gpioout_name[]="gpioout0";
|
||||
int power=0;
|
||||
if(list_length(argv)<2){
|
||||
cmd_print("param num too less.");
|
||||
cmd_print("param: on/off.");
|
||||
return -1;
|
||||
}
|
||||
power=(strcmp(list_get_str(argv,1),"on")==0)?1:0;
|
||||
// 这里默认驱动已经打开
|
||||
for(int i=0;i<OUTPUT_CHANNEL_NUM;i++)
|
||||
{
|
||||
gpioout_name[7]='0'+i;
|
||||
out=dev_get(gpioout_name);
|
||||
if(out){
|
||||
out->set(out,power);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
commend_export(test_output,test_output,"ctrl out state,param: on/off")
|
||||
|
||||
|
||||
|
@@ -73,7 +73,7 @@ static int tran_init(void)
|
||||
tran_def *tran= tran_creat(t);
|
||||
tran->slave_online=0xfffff;
|
||||
app_variable("tran",tran,0);
|
||||
later_execute(tran_scan_slave,tran,500);
|
||||
later_execute(tran_scan_slave,tran,2000);
|
||||
return 0;
|
||||
}
|
||||
app_init_export(tran_init);
|
||||
|
Reference in New Issue
Block a user