制定任务执行命令
This commit is contained in:
@@ -18,3 +18,5 @@
|
||||
广播命令已接收的回复不再触发回调
|
||||
检测命令0x0c只能使用单播方式,广播方式因为不能即时回复停止信号,回复会出错
|
||||
添加电阻测试命令,添加自检命令
|
||||
2023.12.19
|
||||
制定任务执行命令
|
||||
|
@@ -43,6 +43,7 @@ SOURCES += \
|
||||
prot/prot_pc.cpp \
|
||||
prot/prot_slave.cpp \
|
||||
prot_cmd/cmd_cmdline.cpp \
|
||||
prot_cmd/cmd_coder.cpp \
|
||||
prot_cmd/cmd_m4.cpp \
|
||||
prot_cmd/cmd_pc.cpp \
|
||||
prot_cmd/cmd_slave.cpp
|
||||
@@ -71,6 +72,7 @@ HEADERS += \
|
||||
prot/prot_pc.h \
|
||||
prot/prot_slave.h \
|
||||
prot_cmd/cmd_cmdline.h \
|
||||
prot_cmd/cmd_coder.h \
|
||||
prot_cmd/cmd_m4.h \
|
||||
prot_cmd/cmd_pc.h \
|
||||
prot_cmd/cmd_slave.h
|
||||
|
@@ -6,7 +6,7 @@
|
||||
|
||||
|
||||
|
||||
#define BUILD_DATE "2023-12-13 17:50:37"
|
||||
#define BUILD_DATE "2023-12-19 18:08:48"
|
||||
|
||||
|
||||
|
||||
|
@@ -248,6 +248,12 @@ elec_task_judge,
|
||||
elec_task_judge,
|
||||
elec_task_judge,
|
||||
elec_task_judge,
|
||||
elec_task_judge,
|
||||
elec_task_judge,
|
||||
elec_task_judge,
|
||||
elec_task_judge,
|
||||
elec_task_judge,
|
||||
elec_task_judge,
|
||||
0,
|
||||
};
|
||||
|
||||
@@ -344,6 +350,11 @@ elec_task_judge, //35 检测过程中注码
|
||||
elec_task_judge, //36 验证注码
|
||||
elec_task_judge, //37 模块在线检测
|
||||
elec_task_judge, //38 升级
|
||||
elec_task_judge,
|
||||
elec_task_judge,
|
||||
elec_task_judge,
|
||||
elec_task_judge,
|
||||
elec_task_judge,
|
||||
0,
|
||||
};
|
||||
|
||||
|
@@ -32,7 +32,7 @@ typedef struct _elec_judge_def{
|
||||
void elec_judge(const scheme_def *s,int task_num,uint8_t *exe_ack,
|
||||
uint8_t *exe_flag,uint8_t *data,uint8_t *marerr,uint8_t *suberr);
|
||||
|
||||
|
||||
int elec_extract_chip(int id);
|
||||
|
||||
|
||||
#endif
|
||||
|
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"build_date": "2023-12-13 17:50:37",
|
||||
"build_date": "2023-12-19 18:08:48",
|
||||
"hard_version": "MHPZ2_V1.00",
|
||||
"private": [
|
||||
"info.json",
|
||||
|
124
prot_cmd/cmd_coder.cpp
Normal file
124
prot_cmd/cmd_coder.cpp
Normal file
@@ -0,0 +1,124 @@
|
||||
#include "cmd_coder.h"
|
||||
|
||||
|
||||
|
||||
static const char *g_ew_task_table[]={
|
||||
"电源准备",
|
||||
"延时等待",
|
||||
"桥丝电阻测试",
|
||||
"上电充能",
|
||||
"设置总线电压",
|
||||
"获取总线电流",
|
||||
"使能MTP",
|
||||
"扫描UID",
|
||||
"写配置参数",
|
||||
"检测配置",
|
||||
"验证配置",
|
||||
"模拟注码",
|
||||
"验证模拟注码",
|
||||
"芯片自检",
|
||||
"状态检测",
|
||||
"充电",
|
||||
"放电",
|
||||
"写延时",
|
||||
"读延时",
|
||||
"时钟校准",
|
||||
"设置通信地址",
|
||||
"状态巡检",
|
||||
"起爆使能",
|
||||
"起爆检测",
|
||||
"缓存数据写入MTP",
|
||||
"验证缓存数据",
|
||||
"关总线",
|
||||
"升级",
|
||||
"充能统计",
|
||||
"计算异常",
|
||||
"重新执行任务",
|
||||
"写入三码数据",
|
||||
"验证三码数据",
|
||||
"配置三码数据到小板",
|
||||
"任务插槽",
|
||||
nullptr,
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static const char *g_jq_task_table[]={
|
||||
"电源准备",
|
||||
"上电充能",
|
||||
"设置总线电压",
|
||||
"获取总线电流",
|
||||
"扫描UID",
|
||||
"密码验证",
|
||||
"读取芯片代码",
|
||||
"OTP检测",
|
||||
"工厂测试检测",
|
||||
"读取状态",
|
||||
"写工厂信息",
|
||||
"充能统计",
|
||||
"充电电压检测",
|
||||
"延时等待",
|
||||
"设置延时",
|
||||
"读取延时",
|
||||
"时钟校准",
|
||||
"放电",
|
||||
"复位",
|
||||
"起爆使能",
|
||||
"起爆充能",
|
||||
"使能通讯末电流采集",
|
||||
"获取通讯末电流",
|
||||
"写OTP",
|
||||
"读OTP",
|
||||
"清除起爆计数",
|
||||
"关总线",
|
||||
"将缓存区数据写入OTP",
|
||||
"三码写入错误",
|
||||
"三码验证错误",
|
||||
"测量电容压差",
|
||||
"测量桥丝阻值",
|
||||
"使能OTP写",
|
||||
"写模块版本",
|
||||
"读取版本号",
|
||||
"写缓存数据",
|
||||
"验证缓存数据",
|
||||
"读取延时值和OTP数据相比",
|
||||
"切换总线极性",
|
||||
"计算异常",
|
||||
"重新执行任务",
|
||||
"配置三码数据到小板",
|
||||
"任务插槽",
|
||||
nullptr,
|
||||
};
|
||||
|
||||
|
||||
// 根据字符找到任务id,失败返回-1
|
||||
int coder_find_task_id(const char *str)
|
||||
{
|
||||
int chip=elec_extract_chip(check_plan()->get_plan_id());
|
||||
const char **table=nullptr;
|
||||
if(chip==0){
|
||||
table=g_jq_task_table;
|
||||
}else if(chip==2){
|
||||
table=g_ew_task_table;
|
||||
}
|
||||
if(table==nullptr){
|
||||
return -1;
|
||||
}
|
||||
for(int i=0;i<100;i++){
|
||||
if(qstrcmp(str,table[i])==0){
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
91
prot_cmd/cmd_coder.h
Normal file
91
prot_cmd/cmd_coder.h
Normal file
@@ -0,0 +1,91 @@
|
||||
#ifndef CMD_CODER_H
|
||||
#define CMD_CODER_H
|
||||
|
||||
#include <QObject>
|
||||
#include "prot_cmd/cmd_pc.h"
|
||||
#include "base/check_cfg.h"
|
||||
#include "elec/elec_judge.h"
|
||||
|
||||
|
||||
/*
|
||||
|
||||
执行任务命令格式
|
||||
[0...1]=总字节数,[2]=当前包数(0开始),[3]=当前包字节数
|
||||
[4...n]=数据
|
||||
|
||||
数据域格式
|
||||
[0]=小板地址,[1]=数据长度,[2...n]=数据
|
||||
|
||||
单个任务数据格式
|
||||
[0]=插槽序号,[1]=任务id,[2]=参数个数(u16)
|
||||
[3]=返回值个数(u16),[4]=异常代码,[5]=任务序号
|
||||
[6...n]=参数
|
||||
|
||||
|
||||
|
||||
返回数据域格式
|
||||
[0]=任务序号,[1]=返回数据长度(u16)
|
||||
[2...n]=参数
|
||||
|
||||
|
||||
*/
|
||||
|
||||
int coder_find_task_id(const char *str);
|
||||
|
||||
|
||||
// 赋码仪检测命令
|
||||
class cmd_coder_check : public selfdev_runtask
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
cmd_coder_check():selfdev_runtask(){
|
||||
}
|
||||
// pc指令转从机
|
||||
myarray cmd_pc_to_slave(myarray data){
|
||||
|
||||
}
|
||||
// pc指令生成从机列表
|
||||
QList<int> cmd_pc_to_addrs(myarray data){
|
||||
QList<int> addr_list;
|
||||
addrs=data[0]|(data[1]<<8)|(data[2]<<16);
|
||||
for(int i=0;i<20;i++){
|
||||
if((addrs&(1<<i))!=0){
|
||||
addr_list.append(i+1);
|
||||
}
|
||||
}
|
||||
return addr_list;
|
||||
}
|
||||
// 从机发起命令
|
||||
int cmd_slave(){
|
||||
return 0x20;
|
||||
}
|
||||
// pc收到回复,返回0不回复
|
||||
int cmd_pc_recv(){
|
||||
return 0x10;
|
||||
}
|
||||
// 生成接收回复到pc
|
||||
myarray cmd_pc_recv_to_pc(){
|
||||
myarray r;
|
||||
r.append(uint8_t(addrs&0xff));
|
||||
r.append(uint8_t((addrs>>8)&0xff));
|
||||
r.append(uint8_t((addrs>>16)&0xff));
|
||||
r.append(uint8_t(0));
|
||||
return r;
|
||||
}
|
||||
// pc回复命令,返回0不回复
|
||||
int cmd_pc_ret(){
|
||||
return 0x90;
|
||||
}
|
||||
// 从机返回转pc
|
||||
myarray ret_slave_to_pc(QList<myarray> data){
|
||||
|
||||
}
|
||||
protected:
|
||||
int addrs;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // CMD_CODER_H
|
@@ -821,18 +821,22 @@ int selfdev_runtask::dolater(int cmd, myarray data)
|
||||
qDebug("set_rescv.");
|
||||
emit send_data_signal(cmd,myarray(1,0));
|
||||
HandleBoardCast *b=new slave_cmd();
|
||||
bool ack=slave->set_boardcast_handle(cfg_->calc_slave_addrs(),b);
|
||||
addrs=cmd_pc_to_addrs(data);
|
||||
bool ack=slave->set_boardcast_handle(addrs,b);
|
||||
if(ack==false){
|
||||
qWarning("handle is busy.");
|
||||
busy=0;
|
||||
}else{
|
||||
connect(b,&HandleBoardCast::end_signal,this,&selfdev_runtask::slave_end_slot);
|
||||
// 广播设置校准值,需使用新增命令
|
||||
b->cmd=0x13;
|
||||
b->start(data);
|
||||
b->cmd=cmd_slave();
|
||||
b->start(cmd_pc_to_slave(data));
|
||||
if(cmd_pc_recv()!=0){
|
||||
emit send_data_signal(cmd_pc_recv(),cmd_pc_recv_to_pc());
|
||||
}
|
||||
}
|
||||
slave_acked.clear();
|
||||
for(int i=0;i<cfg_->slave_num;i++){
|
||||
for(int i=0;i<addrs.size();i++){
|
||||
slave_acked.append(myarray());
|
||||
}
|
||||
slave_acked_num=0;
|
||||
@@ -846,17 +850,18 @@ void selfdev_runtask::timeout()
|
||||
|
||||
void selfdev_runtask::slave_end_slot(int addr,int ack, slave_data data)
|
||||
{
|
||||
qDebug("selfdev set_rescv end.");
|
||||
myarray r;
|
||||
r.append(char(0));
|
||||
emit send_data_signal(0x50,r);
|
||||
qDebug("selfdev runtask end.");
|
||||
for(int i=0;i<data.size();i++){
|
||||
slave_ret slave=data.at(i);
|
||||
slave_acked.replace(slave.addr-1,slave.data);
|
||||
slave_acked_num++;
|
||||
}
|
||||
if(cmd_pc_ret()!=0){
|
||||
emit send_data_signal(cmd_pc_ret(),ret_slave_to_pc(slave_acked));
|
||||
}
|
||||
busy=0;
|
||||
}
|
||||
|
||||
static HandlePc *get_selfdev_runtask(){
|
||||
return new selfdev_runtask();
|
||||
}
|
||||
protpc_export(0x50, get_selfdev_runtask);
|
||||
|
||||
|
||||
|
||||
|
@@ -266,11 +266,26 @@ public:
|
||||
}
|
||||
int dolater(int cmd, myarray data);
|
||||
void timeout();
|
||||
// pc指令转从机
|
||||
virtual myarray cmd_pc_to_slave(myarray data)=0;
|
||||
// pc指令生成从机列表
|
||||
virtual QList<int> cmd_pc_to_addrs(myarray data)=0;
|
||||
// 从机发起命令
|
||||
virtual int cmd_slave()=0;
|
||||
// pc收到回复,返回0不回复
|
||||
virtual int cmd_pc_recv()=0;
|
||||
// 生成接收回复到pc
|
||||
virtual myarray cmd_pc_recv_to_pc()=0;
|
||||
// pc回复命令,返回0不回复
|
||||
virtual int cmd_pc_ret()=0;
|
||||
// 从机返回转pc
|
||||
virtual myarray ret_slave_to_pc(QList<myarray> data)=0;
|
||||
public slots:
|
||||
void slave_end_slot(int addr,int ack, slave_data data);
|
||||
protected:
|
||||
QList<myarray> slave_acked;
|
||||
int slave_acked_num;
|
||||
QList<int> addrs;
|
||||
signals:
|
||||
void send_to_m4_signal(myarray data);
|
||||
};
|
||||
@@ -279,4 +294,9 @@ signals:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
@@ -475,14 +475,42 @@ int slave_bootinfo::dolater(int cmd, myarray data)
|
||||
|
||||
int slave_cmd::start(myarray data)
|
||||
{
|
||||
int timeout=5000;
|
||||
int timeout;
|
||||
busy=1;
|
||||
timeout=check_plan()->get_check_time_out()*1000;
|
||||
qDebug("addr %d start ,timeout=%d",addr,timeout);
|
||||
send_data(cmd,data,3);
|
||||
this->data=data;
|
||||
send_pack_num=0;
|
||||
send_bytes=0;
|
||||
send_next();
|
||||
timeout_start(timeout);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// 发送下一包,返回true完成
|
||||
bool slave_cmd::send_next()
|
||||
{
|
||||
int pack_size=236;
|
||||
int data_size=data.size();
|
||||
if(send_bytes<data_size){
|
||||
if(pack_size>data_size-send_bytes){
|
||||
pack_size=data_size-send_bytes;
|
||||
}
|
||||
myarray d;
|
||||
d.append(uint8_t(data_size&0xff));
|
||||
d.append(uint8_t((data_size>>8)&0xff));
|
||||
d.append(uint8_t((send_pack_num)&0xff));
|
||||
d.append(uint8_t(pack_size&0xff));
|
||||
d.append(data.mid(send_bytes,pack_size));
|
||||
send_data(cmd,d,3);
|
||||
send_bytes+=pack_size;
|
||||
send_pack_num++;
|
||||
return false;
|
||||
}else{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void slave_cmd::timeout()
|
||||
{
|
||||
timeout_stop();
|
||||
@@ -496,10 +524,12 @@ int slave_cmd::dolater(int cmd, myarray data)
|
||||
this->addr_response=0;
|
||||
timeout_stop_retry();
|
||||
if(cmd==this->cmd){
|
||||
qDebug("cmd end success.");
|
||||
busy=0;
|
||||
end(0,ret_data);
|
||||
timeout_stop();
|
||||
if(send_next()==true){
|
||||
qDebug("cmd end success.");
|
||||
busy=0;
|
||||
end(0,ret_data);
|
||||
timeout_stop();
|
||||
}
|
||||
}else{
|
||||
qWarning("cmd:%02x err.",cmd);
|
||||
}
|
||||
|
@@ -150,10 +150,18 @@ public:
|
||||
class slave_cmd:public HandleBoardCast
|
||||
{
|
||||
public:
|
||||
slave_cmd():HandleBoardCast(){}
|
||||
slave_cmd():HandleBoardCast(){
|
||||
send_bytes=0;
|
||||
send_pack_num=0;
|
||||
}
|
||||
int start(myarray data);
|
||||
int dolater(int cmd, myarray data);
|
||||
void timeout();
|
||||
bool send_next();
|
||||
protected:
|
||||
int send_bytes;
|
||||
int send_pack_num;
|
||||
myarray data;
|
||||
};
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user