串口读写会导致mipi异常

用户您好,请详细描述您所遇到的问题:

  1. 系统软件版本: (通过 cat /etc/version 获得)
  2. 问题涉及的技术领域: (硬件、操作系统、驱动、其他)
  3. 问题描述:(尽可能详细的描述在进行什么功能的开发或者测试,发现了什么问题,问题现象,并且提供预期的结果)
  4. 复现概率:(必现、高、中、低,并描述大致的概率数值) 已进行的排查措施、分析及结果:
    1. 硬件问题先排查供电和时钟
    2. 驱动问题先排查外设的供电、复位和时钟
    3. 功能异常,先排查一下是不是运行的代码和demo存在差异,修改不多的情况下直接用对比软件先对比
  5. 提供必要的问题日志:
  6. 软件上是否有做自定义修改:

串口读写会导致mipi异常

环境:古月居x3派小车(视觉版,导航版均有问题)

版本:[BPU_PLAT]BPU Platform Version(1.3.1)!

[HBRT] set log level as 0. version = 3.14.5

[DNN] Runtime version = 1.9.7_(3.14.5 HBRT)

是否可复现:100%可复现

校验验证:将串口线拔掉或者将写串口代码屏蔽后,mipi不会异常

复现步骤:

1、开启一个定时器,每200毫米向串口写一条信息,我写的是两边轮子的转速;

2、开启系统自带的 python3 /app/ai_inference/03_mipi_camera_sample/mipi_camera.py 测试pkg

异常信息:

potted plant is in the picture with confidence:0.5851, bbox:[  79  787  531 1080]
potted plant is in the picture with confidence:0.6110, bbox:[  79  789  524 1079]
person is in the picture with confidence:0.7406, bbox:[ 977  498 1868 1079]
person is in the picture with confidence:0.6900, bbox:[ 977  496 1889 1080]
potted plant is in the picture with confidence:0.6208, bbox:[  79  791  524 1080]
person is in the picture with confidence:0.7341, bbox:[ 967  498 1868 1079]
potted plant is in the picture with confidence:0.6017, bbox:[  79  787  524 1080]
person is in the picture with confidence:0.6947, bbox:[ 967  498 1878 1080]
potted plant is in the picture with confidence:0.6240, bbox:[  86  792  531 1078]
person is in the picture with confidence:0.6841, bbox:[ 967  490 1868 1080]
potted plant is in the picture with confidence:0.5883, bbox:[  83  791  529 1080]
person is in the picture with confidence:0.6722, bbox:[ 977  496 1889 1080]
potted plant is in the picture with confidence:0.5759, bbox:[  83  791  529 1080]
person is in the picture with confidence:0.6752, bbox:[ 967  502 1878 1080]
[ERROR]["vps"][vps/hb_vps_api.c:2438] [2383.679993]HB_VPS_GetChnFrame[2438]: G0 VPS error get chn3 frame timeout

[ERROR]["vio_bufmgr"][utils/hb_vio_buffer_mgr.c:2011] [2383.680073]buf_mgr_print_qcount[2011]: Mgr(3)state:Total(5)Avail(2)Process(3)Done(0)Repro(0)User(0).

HB_VPS_GetChnFrame Failed. ret = -268696588
Traceback (most recent call last):
  File "mipi_camera.py", line 345, in <module>
    img = np.frombuffer(img, dtype=np.uint8)
TypeError: a bytes-like object is required, not 'NoneType'
【INFO】: Offload model "fcos_512x512_nv12" Successfully.
root@ubuntu:/app/ai_inference/03_mipi_camera_sample#

定时写串口:

{
    auto timer_callback =
      [this]() -> void{
            //写串口定时器
            UpdateSerialParamsOut();
            //正式项目函数
            //UpdateMoveParamsOut();
      };
    update_params_out_timer_ = this->create_wall_timer(std::chrono::milliseconds(200), timer_callback, nullptr);
}

/// 
///正常写串口测试
///会导致mipi异常
///
void ParamsSubscriber::UpdateSerialParamsOut(){
 
 RobotParamsOut robot_params_out;
 robot_params_out.x = (float)(rand()%10)/(10.f); //一个0-0.99的随机数
 robot_params_out.y = 0.01 ;
 robot_params_out.action = RobotAction::ACTION_GO;
 std::cout << "Serial test : " << TTY_S_NAME << "UpdateSerialParamsOut...x =" <<robot_params_out.x << std::endl;
 EPetStatusMachine::Instance()->ProcessParamsOut(&robot_params_out);
}


///
///写串口
///
void EPetProtocolProcess::WriteCommand(const RobotParamsOut robot_params_out){
    DataFrame cmdFrame;
 float leftSpeed = 0.0, rightSpeed = 0.0;

 float x_linear = robot_params_out.x; 
 float y_angular = robot_params_out.y;

    //差分轮运动学模型求解
 if(x_linear ==0){
        leftSpeed  = -y_angular / 2.0;
        rightSpeed = y_angular  / 2.0;    
    }else{
        leftSpeed  = x_linear - y_angular * ORIGINBOT_WHEEL_TRACK / 2.0;
        rightSpeed = x_linear + y_angular * ORIGINBOT_WHEEL_TRACK / 2.0;
    }

 if(SPEED_DIRECTION_REVERT){
        leftSpeed = -leftSpeed;
        rightSpeed = -rightSpeed;
    }
 
 if(DEBUG_OPEN){
 RCLCPP_INFO(rclcpp::get_logger("ePet protocol process"),"WriteCommand...leftSpeed = '%f' rightSpeed = '%f'", leftSpeed * 100, rightSpeed * 100);
    }
 if (leftSpeed < 0)
 cmdFrame.data[0] = 0x00; //速度为负;
 else
 cmdFrame.data[0] = 0xff; //速度为正
 cmdFrame.data[1] = int(abs(leftSpeed) * 1000) & 0xff;         //速度值从m/s变为mm/s
 cmdFrame.data[2] = (int(abs(leftSpeed) * 1000) >> 8) & 0xff;

 if (rightSpeed < 0)
 cmdFrame.data[3] = 0x00; 
 else
 cmdFrame.data[3] = 0xff;
 cmdFrame.data[4] = int(abs(rightSpeed) * 1000) & 0xff;        //速度值从m/s变为mm/s
 cmdFrame.data[5] = (int(abs(rightSpeed) * 1000) >> 8) & 0xff;

 cmdFrame.check = (cmdFrame.data[0] + cmdFrame.data[1] + cmdFrame.data[2] + 
 cmdFrame.data[3] + cmdFrame.data[4] + cmdFrame.data[5]) & 0xff;

    // 封装速度命令的数据帧
 cmdFrame.header = 0x55;
 cmdFrame.id     = 0x01;
 cmdFrame.length = 0x06;
 cmdFrame.tail   = 0xbb;
 try
    {
       serial_.write(&cmdFrame.header, sizeof(cmdFrame)); //向串口发数据
    }
    catch (serial::IOException &e)
    {
       RCLCPP_INFO(rclcpp::get_logger("ePet params process"), "Unable to send data through serial port"); //如果发送数据失败,打印错误信息
    }

    // 考虑平稳停车的计数值
    if((fabs(x_linear) > 0.0001) || (fabs(y_angular) > 0.0001)){
        //auto_stop_count_ = 0;
    }

 if(DEBUG_CLOSE){
     RCLCPP_INFO(rclcpp::get_logger("ePet protocol process"),"Send to controller frame raw data: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x \n", cmdFrame.header, cmdFrame.id, cmdFrame.length, cmdFrame.data[0], cmdFrame.data[1], cmdFrame.data[2], cmdFrame.data[3], cmdFrame.data[4], cmdFrame.data[5], cmdFrame.check, cmdFrame.tail);
    }
}

写串口打印日志_20230314101159.png

mipi摄像头FPC排线受到电机影响

补充:

当转速小于50时,几乎不会复现mipi异常问题;

当转速超过80时,很容易复现;

当转速超过120时,秒现。

写串口打印:[epet_process_engine-1] Serial test : ttyS3UpdateSerialParamsOut...x =1.2[epet_process_engine-1] [INFO] [1678760426.239206855] [EPetStatusMachine]: ChangedStatus...RobotStatus::MOVE_FRONT_MOVE: x=1.200000 ; y=0.000000[epet_process_engine-1] [INFO] [1678760426.239424560] [ePet protocol process]: WriteCommand...leftSpeed = '120.000008' rightSpeed = '120.000008'[epet_process_engine-1] Serial test : ttyS3UpdateSerialParamsOut...x =1.2[epet_process_engine-1] [INFO] [1678760431.235848023] [ePet protocol process]: WriteCommand...leftSpeed = '120.000008' rightSpeed = '120.000008'[epet_process_engine-1] Serial test : ttyS3UpdateSerialParamsOut...x =1.2[epet_process_engine-1] [INFO] [1678760436.233347930] [ePet protocol process]: WriteCommand...leftSpeed = '120.000008' rightSpeed = '120.000008'mipi demo打印:hair drier is in the picture with confidence:0.5084, bbox:[ 389  603  799 1080]person is in the picture with confidence:0.5529, bbox:[  17  601  806 1079]hair drier is in the picture with confidence:0.5027, bbox:[ 389  603  799 1080]person is in the picture with confidence:0.5918, bbox:[  58  601  806 1079]person is in the picture with confidence:0.5892, bbox:[   7  601  806 1079]person is in the picture with confidence:0.5593, bbox:[   7  601  806 1079]person is in the picture with confidence:0.5867, bbox:[  28  601  806 1079]person is in the picture with confidence:0.5145, bbox:[   7  601  806 1079]person is in the picture with confidence:0.5463, bbox:[  17  601  806 1079]person is in the picture with confidence:0.5106, bbox:[   7  601  806 1079][ERROR]["vio_devop"][utils/dev_ioctl.c:138] [3645.268274]dev_node_dqbuf_ispoll[138]: failed to ioctl: dq (14 - Bad address)[ERROR]["vio_devop"][utils/dev_ioctl.c:189] [3645.268321]entity_node_dqbuf_ispoll[189]: dev type(1) dq failed[ERROR]["vio_core"][commom_grp/binding_main.c:1032] [3645.268359]comm_dq_no_data[1032]: G0 IPU_MODULE module chn1 dq failed! maybe framedrop error_detail -14[ERROR]["vio_devop"][utils/dev_ioctl.c:138] [3645.268891]dev_node_dqbuf_ispoll[138]: failed to ioctl: dq (14 - Bad address)[ERROR]["vio_devop"][utils/dev_ioctl.c:189] [3645.268937]entity_node_dqbuf_ispoll[189]: dev type(2) dq failed[ERROR]["vio_core"][commom_grp/binding_main.c:1032] [3645.268954]comm_dq_no_data[1032]: G0 IPU_MODULE module chn2 dq failed! maybe framedrop error_detail -14[ERROR]["vio_devop"][utils/dev_ioctl.c:138] [3645.270387]dev_node_dqbuf_ispoll[138]: failed to ioctl: dq (14 - Bad address)[ERROR]["vio_devop"][utils/dev_ioctl.c:189] [3645.270438]entity_node_dqbuf_ispoll[189]: dev type(3) dq failed[ERROR]["vio_core"][commom_grp/binding_main.c:1032] [3645.270458]comm_dq_no_data[1032]: G0 IPU_MODULE module chn3 dq failed! maybe framedrop error_detail -14person is in the picture with confidence:0.5480, bbox:[  17  601  816 1079]person is in the picture with confidence:0.5373, bbox:[   7  600  806 1078]person is in the picture with confidence:0.5656, bbox:[   7  600  806 1078][ERROR]["vps"][vps/hb_vps_api.c:2438] [3647.373181]HB_VPS_GetChnFrame[2438]: G0 VPS error get chn3 frame timeout[ERROR]["vio_bufmgr"][utils/hb_vio_buffer_mgr.c:2011] [3647.373313]buf_mgr_print_qcount[2011]: Mgr(3)state:Total(5)Avail(2)Process(3)Done(0)Repro(0)User(0).HB_VPS_GetChnFrame Failed. ret = -268696588Traceback (most recent call last):  File "mipi_camera.py", line 345, in <module>    img = np.frombuffer(img, dtype=np.uint8)TypeError: a bytes-like object is required, not 'NoneType'【INFO】: Offload model "fcos_512x512_nv12" Successfully.root@ubuntu:/app/ai_inference/03_mipi_camera_sample#