添加tran命令透传小板命令
添加slave_info命令测试小板通信状态 添加cfginfo命令显示配置文件信息 按键处于按下状态才响应检测命令
This commit is contained in:
@@ -80,6 +80,7 @@ can_host::can_host(int bitrate)
|
||||
this->bitrate = bitrate;
|
||||
this->can_ = nullptr;
|
||||
timer_ = nullptr;
|
||||
recv_cb_fun=nullptr;
|
||||
}
|
||||
|
||||
can_host::~can_host()
|
||||
@@ -166,8 +167,7 @@ void can_host::freams_sent_cb(qint64 count)
|
||||
void can_host::recv_data_cb()
|
||||
{
|
||||
YeCanID_un frame_id;
|
||||
while (can_->framesAvailable())
|
||||
{
|
||||
while (can_->framesAvailable()){
|
||||
const QCanBusFrame frame = can_->readFrame();
|
||||
frame_id.Exide = frame.frameId();
|
||||
if (frame_id.Exide == 0x000000)
|
||||
@@ -178,49 +178,47 @@ void can_host::recv_data_cb()
|
||||
uint8_t seg_flag = frame_id.yecanid.SegFlag;
|
||||
int seg_num = frame_id.yecanid.SegNum;
|
||||
can_slave &slave = get_slave_by_addr(slave_addr);
|
||||
if (seg_flag == 0x00)
|
||||
{
|
||||
if (seg_flag == 0x00){
|
||||
// 不分段
|
||||
slave.clear();
|
||||
slave.append(payload);
|
||||
qDebug()<<"can recv from:"<<slave_addr<<slave.get_data().toHex(' ');
|
||||
if (dst_addr == 0){
|
||||
if (irq_fun)
|
||||
{
|
||||
if (irq_fun){
|
||||
irq_fun(myarray(slave.get_data()));
|
||||
}
|
||||
if(recv_cb_fun){
|
||||
recv_cb_fun(slave_addr,myarray(slave.get_data()));
|
||||
}
|
||||
emit recv_data_signal(slave_addr,slave.get_data());
|
||||
}
|
||||
}
|
||||
else if (seg_flag == 0x01)
|
||||
{
|
||||
else if (seg_flag == 0x01){
|
||||
// 首段
|
||||
slave.clear();
|
||||
slave.append(payload);
|
||||
}
|
||||
else if (seg_flag == 0x02)
|
||||
{
|
||||
else if (seg_flag == 0x02){
|
||||
// 中段
|
||||
slave.append(payload);
|
||||
}
|
||||
else if (seg_flag == 0x03)
|
||||
{
|
||||
else if (seg_flag == 0x03){
|
||||
// 尾段
|
||||
slave.append(payload);
|
||||
if (slave.get_pack_num() - 1 == seg_num)
|
||||
{
|
||||
if (slave.get_pack_num() - 1 == seg_num){
|
||||
qDebug()<<"can recv from:"<<slave_addr<<slave.get_data().toHex(' ');
|
||||
if (dst_addr == 0){
|
||||
if (irq_fun)
|
||||
{
|
||||
if (irq_fun){
|
||||
irq_fun(myarray(slave.get_data()));
|
||||
}
|
||||
if(recv_cb_fun){
|
||||
recv_cb_fun(slave_addr,myarray(slave.get_data()));
|
||||
}
|
||||
emit recv_data_signal(slave_addr,slave.get_data());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "can data from: " << QString::number(slave_addr, 10) << "recv error";
|
||||
else{
|
||||
qDebug() << "can data from: " << slave_addr << "recv error";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user