异常判定在出错时才打印,检测时通信异常蜂鸣器响一声

取消一些通信日志打印
This commit is contained in:
ranchuan
2024-01-06 09:59:58 +08:00
parent 307eb513ef
commit b76c04d072
11 changed files with 29 additions and 16 deletions

View File

@@ -52,4 +52,7 @@
2024.01.04
添加自动测试命令 auto_test
V2.03 批检仪检测指令使用小板的错误码
2024.1.5
异常判定在出错时才打印,检测时通信异常蜂鸣器响一声
取消一些通信日志打印

View File

@@ -6,7 +6,7 @@
#define BUILD_DATE "2024-01-04 14:43:54"
#define BUILD_DATE "2024-01-05 17:19:53"

View File

@@ -120,15 +120,21 @@ static void elec_task_judge(elec_judge_def *e,int index,uint8_t *data)
TASK_FLAG_CHECK(index);
const scheme_task_def *task=&e->scheme->task[index];
uint16_t temp;
qDebug("task index=%d.",index);
int print_index=0;
if(EXE_ACK_CHECK(index)){
elec_add_errcode(e,task->err);
qDebug("task index=%d.",index);
print_index=1;
qDebug("task execute err:%d.",task->err);
}
for(int i=0;i<task->item_num;i++){
temp=data[i*2]|(data[i*2+1]<<8);
if(temp<task->range[i].min||temp>task->range[i].max){
elec_add_errcode(e,task->range[i].err);
if(print_index==0){
qDebug("task index=%d.",index);
print_index=1;
}
qDebug("task ret_index:%d vaule=%d,err:%d",i,temp,task->range[i].err);
}
}
@@ -144,7 +150,9 @@ static void elec_current(elec_judge_def *e,int index,uint8_t *data)
uint16_t temp,temp2;
uint16_t short_c=e->short_circuited;
uint16_t open_c=e->open_circuited;
int print_index=0;
qDebug("task index=%d.",index);
print_index=1;
if(EXE_ACK_CHECK(index)){
elec_add_errcode(e,task->err);
qDebug("task execute err:%d.",task->err);

View File

@@ -1,5 +1,5 @@
{
"build_date": "2024-01-04 14:43:54",
"build_date": "2024-01-05 17:19:53",
"hard_version": "MHPZ2_V1.00",
"private": [
"info.json",

View File

@@ -182,7 +182,7 @@ void can_host::recv_data_cb()
// 不分段
slave.clear();
slave.append(payload);
qDebug()<<"can recv from:"<<slave_addr<<slave.get_data().toHex(' ');
// qDebug()<<"can recv from:"<<slave_addr<<slave.get_data().toHex(' ');
if (dst_addr == 0){
if (irq_fun){
irq_fun(myarray(slave.get_data()));
@@ -206,7 +206,7 @@ void can_host::recv_data_cb()
// 尾段
slave.append(payload);
if (slave.get_pack_num() - 1 == seg_num){
qDebug()<<"can recv from:"<<slave_addr<<slave.get_data().toHex(' ');
// qDebug()<<"can recv from:"<<slave_addr<<slave.get_data().toHex(' ');
if (dst_addr == 0){
if (irq_fun){
irq_fun(myarray(slave.get_data()));
@@ -229,7 +229,7 @@ void can_host::recv_data_cb()
int can_host::write(int dst,myarray data)
{
qDebug()<<"can send to:"<<dst<<data.toHex(' ');
// qDebug()<<"can send to:"<<dst<<data.toHex(' ');
append(dst, 1, data);
// qDebug("can send end.");
return data.size();

View File

@@ -35,7 +35,7 @@ int if_uart::write(myarray data)
// qWarning() << "Cant send data , TcpClient socket not connect.";
return 0;
}
qDebug("uart send:%s", data.toHex(' ').data());
// qDebug("uart send:%s", data.toHex(' ').data());
int wb = serial_->write(data);
if ((!serial_->flush()) || (wb != data.size()))

View File

@@ -36,7 +36,7 @@ void prot_m4::send_data_slot(myarray data)
send_list.append(send);
if(wait==0){
wait+=2;
qDebug("send m4:%s",data.data());
// qDebug("send m4:%s",data.data());
if_->write(send_list.takeFirst());
}
}

View File

@@ -41,7 +41,7 @@ void ProtPc::init()
int pack_len=0;
while(pack_len=codec_->packCheck(recv_data),pack_len>0){
int cmd,src,dst;
qDebug("host recv:%s",recv_data.toHex(' ').data());
// qDebug("host recv:%s",recv_data.toHex(' ').data());
myarray data=codec_->decode(src,dst,cmd,recv_data);
recv_data.remove(0,pack_len);
// qDebug("host recv removed:%s",recv_data.toHex(' ').data());

View File

@@ -254,31 +254,31 @@ protected:
timeout_start_cb(ms);
}
void timeout_start_cb(int ms){
qDebug("handle_board:start timeout");
// qDebug("handle_board:start timeout");
timer_->setInterval(ms);
timer_->start();
}
void timeout_start_retry_cb(int ms){
qDebug("handle_board:start retry");
// qDebug("handle_board:start retry");
timer_retry_->setInterval(ms);
timer_retry_->start();
}
// 停止超时计时器,此方法同时停止重发计时器
void timeout_stop(){
qDebug("handle_board:stop timeout");
// qDebug("handle_board:stop timeout");
emit timeout_stop_signal();
timeout_stop_retry();
}
// 停止数据回复超时重试计时器
void timeout_stop_retry(){
qDebug("handle_board:stop retry");
// qDebug("handle_board:stop retry");
emit timeout_stop_retry_signal();
times_retry=0;
}
private:
// 重试回调
void timeout_retry(){
qDebug("in retry.");
// qDebug("in retry.");
if(times_retry>0){
times_retry--;
myarray s;

View File

@@ -39,7 +39,7 @@ void end_slot(int addr,int ack,slave_data data)
// ack 0是成功,这里转化为1是成功
command *c=command_start();
mystring strs("ack:%1,%2");
strs=strs.arg(!ack).arg("end");
strs=strs.arg(ack).arg("end");
c->send(strs.data());
}
@@ -171,7 +171,7 @@ static void mcu_cmdlines(QList<myarray> args)
qWarning("handle is busy.");
}else{
b->set_cbfun([=](int addr,int ack,slave_data data){
end_slot(addr,ack,data);
end_slot(addr,!ack,data);
},[=](int rate,mystring str){
rate_slot(rate,str);
});

View File

@@ -3,6 +3,7 @@
#include "base/check_cfg.h"
#include "QDebug"
#include "base/crc.h"
#include "base/beep.h"
@@ -547,6 +548,7 @@ void slave_cmd::timeout()
timeout_stop();
int addr_timeout=addr^addr_response;
qWarning("addr 0x%06X timeout",addr_timeout);
Beep()->set_beep(300,300,1);
end(1,ret_data);
busy=0;
}