From 2c8ddb1cef06db9edea640d790969b9576b80d6d Mon Sep 17 00:00:00 2001 From: "CSSC-WORK\\murmur" Date: Wed, 21 Jun 2023 11:08:53 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20tcpRecMQ=20=E5=92=8C?= =?UTF-8?q?=E6=8E=A5=E6=94=B6=E7=BA=BF=E7=A8=8B=20=E9=80=80=E5=87=BA?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- applications/log2file.c | 2 +- applications/ttTR.c | 5 +++-- applications/ttmsg/ttmsg.c | 6 +++--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/applications/log2file.c b/applications/log2file.c index 761f287..c75bdb2 100644 --- a/applications/log2file.c +++ b/applications/log2file.c @@ -69,4 +69,4 @@ void sys_log_file_backend_init(void) ulog_file_backend_enable(file_be); //必须使能才能有效 } MSH_CMD_EXPORT(sys_log_file_backend_init,log2file); -//INIT_APP_EXPORT(sys_log_file_backend_init); +INIT_APP_EXPORT(sys_log_file_backend_init); diff --git a/applications/ttTR.c b/applications/ttTR.c index c659149..1e1953b 100644 --- a/applications/ttTR.c +++ b/applications/ttTR.c @@ -179,9 +179,10 @@ void tcpRecMQ_thread_entry(void) } else { - LOG_E("received error."); + msg.size=0;//收到数据长度为0表示tcp断开 + rt_mq_send(&TTrx_mq, &msg, sizeof(msg)); + LOG_E("tcp error, close."); break; -// return -RT_ERROR; } } } diff --git a/applications/ttmsg/ttmsg.c b/applications/ttmsg/ttmsg.c index 6f48993..f340365 100644 --- a/applications/ttmsg/ttmsg.c +++ b/applications/ttmsg/ttmsg.c @@ -540,6 +540,9 @@ void recTT_thread_entry() if (rt_mq_recv(&TTrx_mq, &msg, sizeof(msg), RT_WAITING_FOREVER) == RT_EOK) { // LOG_D("%d Bytes received...",msg.size); + if (!msg.size) {//收到数据长度为0表示tcp断开 + break; + } LOG_HEX("tcpTT", 16, msg.data, msg.size); //此处处理接收到数据 rt_uint8_t rec_good[] = { 0x88, 0xAA, 0xBB, 0x88 };//前四字节 @@ -548,9 +551,6 @@ void recTT_thread_entry() LOG_I("ack is good."); } } - if (!isTCPok()) {//TCP断开 - break; - } } } //INIT_COMPONENT_EXPORT(recTT_thread_entry);