|
|
@@ -256,6 +256,7 @@ static struct can_dev g_can_dev[CAN_BUS_NUM] __attribute__ ((aligned(4)));
|
|
|
FN_CAN_RECV_CALLBACK g_can_recv_callback;
|
|
|
|
|
|
u8 g_app_buf_tx[CAN_PRIO_MAX][CAN_FRAME_LEN_MAX]; //应用可根据优先级申请的长帧缓冲区
|
|
|
+static pthread_mutex_t printf_mutex;
|
|
|
|
|
|
extern int g_print_can;
|
|
|
extern int g_print_can_monitor;
|
|
|
@@ -544,6 +545,8 @@ int can_init(void)
|
|
|
}
|
|
|
fflush(stdout);
|
|
|
|
|
|
+ pthread_mutex_init(&printf_mutex, NULL);
|
|
|
+
|
|
|
//初始化缓冲区
|
|
|
memset(g_can_dev,0,sizeof(g_can_dev));
|
|
|
|
|
|
@@ -1253,7 +1256,10 @@ static int _can_frame_short2long(struct can_dev *dev, int prior)
|
|
|
// 打印报文
|
|
|
if(g_print_can)
|
|
|
{
|
|
|
+ // 增加can报文打印互斥锁,避免CAN0、CAN1两个接收线程打印混乱的情况
|
|
|
+ pthread_mutex_lock(&printf_mutex);
|
|
|
print_msg("RX_CAN:",pd,pd[3] + CAN_LONGFRAME_HEAD_LEN);
|
|
|
+ pthread_mutex_unlock(&printf_mutex);
|
|
|
}
|
|
|
|
|
|
// 回调处理此长帧
|