From 490eae8d23b89d6eed646484c9c5854605cae557 Mon Sep 17 00:00:00 2001 From: "CSSC-WORK\\murmur" Date: Fri, 25 Aug 2023 08:08:30 +0800 Subject: [PATCH] =?UTF-8?q?upSend=20=E7=BA=BF=E7=A8=8B=E9=99=90=E5=88=B6?= =?UTF-8?q?=E4=B8=BA1=E4=B8=AA=20=E9=99=8D=E4=BD=8ErepGetTT=20=E5=92=8C=20?= =?UTF-8?q?getTT=20=E7=9A=84=E5=A0=86=E6=A0=88=E5=88=86=E9=85=8D=20?= =?UTF-8?q?=E6=9B=B4=E6=96=B0build=E9=80=BB=E8=BE=91=20recTT=20=E8=B0=83?= =?UTF-8?q?=E6=95=B4=E4=BC=98=E5=85=88=E7=BA=A7=20rt=5Fdevice=5Fread?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E7=BB=93=E6=9E=9C=E5=88=A4=E6=96=AD=20------?= =?UTF-8?q?-=20=E7=BC=93=E5=AD=98=E7=89=88=E6=9C=AC=EF=BC=8C=E5=90=8E?= =?UTF-8?q?=E7=BB=AD=E7=89=88=E6=9C=AC=E9=87=87=E7=94=A8=E5=A4=96=E7=BD=AE?= =?UTF-8?q?sram=E5=8A=A0=E5=A4=A7=E5=86=85=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- applications/core.c | 7 +++++-- applications/func/func.c | 25 +++++++++++++++++++------ applications/getinfo.c | 4 ++-- applications/main.c | 3 +-- applications/map.c | 16 +++++++++------- applications/tosend.ini | 4 ++-- applications/ttmsg/ttmsg.c | 2 +- applications/uart_3S.c | 5 ++++- 8 files changed, 43 insertions(+), 23 deletions(-) diff --git a/applications/core.c b/applications/core.c index 3a61778..8b793c9 100644 --- a/applications/core.c +++ b/applications/core.c @@ -190,7 +190,7 @@ static void upSendFile_thread_entry(void *parameter) LOG_D("ready to send '%s---%d'",f->fname,f->index); rt_uint8_t len = pack_File(f->fname, 0, d, s); for (size_t i = 0; i < len; i++) { - LOG_HEX("sendFile",27,d[i],s[i]); + LOG_HEX("msg",27,d[i],s[i]); } // list_thread(); if (len) @@ -285,6 +285,7 @@ void getAndSendFile() } //发送完毕 // rt_sem_take(sem, timeout) + LOG_D("mission done."); resetTM(); } @@ -328,6 +329,7 @@ static void chkAndSendFile_thread_entry() } } } + LOG_W("---------------"); } } @@ -472,7 +474,7 @@ void initTT_thread_entry() tcpRecMQ(); //开启tcp接收线程 recTT(); repGetTT(); - reportLoc(); +// reportLoc(); } } @@ -504,6 +506,7 @@ void deInitTT_thread_entry() // initThread = RT_NULL; deinitThread = RT_NULL; + list_thread(); } /** diff --git a/applications/func/func.c b/applications/func/func.c index e0e1fdb..e704b11 100644 --- a/applications/func/func.c +++ b/applications/func/func.c @@ -156,11 +156,12 @@ typedef struct } SMSG;//single messgae +rt_sem_t one_msg_send_done=RT_NULL; void upSend_thread_entry(void* parameter) { SMSG* msg = RT_NULL; msg = (SMSG*) parameter; - LOG_D("1--%p",msg); +// LOG_D("1--%p",msg); // LOG_HEX("--",16,msg->data,msg->len); //check status @@ -216,6 +217,7 @@ void upSend_thread_entry(void* parameter) cacheDataToFile(msg->data, msg->len); } } + rt_sem_release(one_msg_send_done); list_thread(); return ; } @@ -229,13 +231,24 @@ RT_WEAK int upSend(uint8_t *din, size_t len) { LOG_D("try to upsend to TT."); + if (one_msg_send_done == RT_NULL) { + one_msg_send_done = rt_sem_create("senddone", 1, RT_IPC_FLAG_PRIO); + } + static SMSG msg; memset(&msg, 0, sizeof(SMSG)); memcpy(msg.data,din,len); msg.len=len; - LOG_D("0--%p",&msg); +// LOG_D("0--%p",&msg); +//仅创建一个线程用于发送 + if (rt_sem_take(one_msg_send_done, rt_tick_from_millisecond(10000)) != RT_EOK) { + //10s等待,上一发送仍未完成 + LOG_E("wait error, try to cache %d bytes data to file.",msg.len); + cacheDataToFile(msg.data, msg.len); + return -RT_ERROR; + } /* 创建 serial 线程 */ - rt_thread_t thread = rt_thread_create("upSend", upSend_thread_entry, (void *) &msg, 1024 * 5, 27, 10); + rt_thread_t thread = rt_thread_create("upSend", upSend_thread_entry, (void *) &msg, 1024 * 5, 27-1, 10); /* 创建成功则启动线程 */ if (thread != RT_NULL) { @@ -593,7 +606,7 @@ static int packLocMsg(uint8_t *dout) alertMsg[8 + len + 1] = 0xED; len = 8 + len + 2; - LOG_HEX("packLocMsg", 16, alertMsg, len); //bccCRC+Tail +// LOG_HEX("packLocMsg", 16, alertMsg, len); //bccCRC+Tail memcpy(dout, alertMsg, len); return len; } @@ -852,7 +865,7 @@ void reSend(uint8_t *din, uint8_t len) char str[30]=""; bytes2str(din, len-1, 10, "_", str); - + strcat(f,"20"); strncat(f,str,8); strcat(f,"/"); strcat(f,str); @@ -1027,7 +1040,7 @@ void parse3SData(uint8_t *din, size_t count) break; default: LOG_I("pass-through raw data."); - if (isTTon()) + if (isTTjh()) {//如果TT为开机状态(具备通信状态?待商榷)则不缓存直接发 upSend(din, count); } diff --git a/applications/getinfo.c b/applications/getinfo.c index 755dfa3..ab9e152 100644 --- a/applications/getinfo.c +++ b/applications/getinfo.c @@ -371,7 +371,7 @@ void getTT(int argc, char **argv) } /* 创建 serial 线程 */ - rt_thread_t thread = rt_thread_create("getTT", getTTinfo_thread_entry, (void *) &cfg, 1024 * 3, 25, 10); + rt_thread_t thread = rt_thread_create("getTT", getTTinfo_thread_entry, (void *) &cfg, 1024 * 1, 25, 10); /* 创建成功则启动线程 */ if (thread != RT_NULL) { @@ -469,7 +469,7 @@ void repGetTT(void) {} memset(rstInfo,0x3f,RST_LEN);//初始化 /* 创建 serial 线程 */ - rt_thread_t thread = rt_thread_create("repGetTT", repGetTT_thread_entry, RT_NULL, 1024 * 3, 27, 10); + rt_thread_t thread = rt_thread_create("repGetTT", repGetTT_thread_entry, RT_NULL, 1024 * 2, 27, 10); /* 创建成功则启动线程 */ if (thread != RT_NULL) { diff --git a/applications/main.c b/applications/main.c index 5a4bf8c..1e73ced 100644 --- a/applications/main.c +++ b/applications/main.c @@ -102,8 +102,7 @@ void show_version(void) char str[30]; uint8_t t[10]; size_t len=time2Byte(t); - bytes2str(t, len, 10, "", str); - rt_kprintf("SW Version: %s, build-%s\n","1.46",bytes2str(t, len, 10, "", str)); + rt_kprintf("SW Version: %s, build-%s\n","1.5",bytes2str(t, 3, 10, "", str)); } MSH_CMD_EXPORT(show_version,显示版本号); diff --git a/applications/map.c b/applications/map.c index 2c8b3d7..8601e90 100644 --- a/applications/map.c +++ b/applications/map.c @@ -109,8 +109,8 @@ int mapParse(const char *fin,float *x, float *y) if (cJSON_IsArray(object)) { // LOG_D("size of 'features' is %d",cJSON_GetArraySize(object)); - object = cJSON_GetArrayItem(object, 0); - item = cJSON_GetObjectItem(object, "geometry"); + cJSON *tmp = cJSON_GetArrayItem(object, 0); + item = cJSON_GetObjectItem(tmp, "geometry"); if (item) { cJSON *sitem = cJSON_GetObjectItem(item, "type"); @@ -124,10 +124,10 @@ int mapParse(const char *fin,float *x, float *y) sitem = cJSON_GetObjectItem(item, "coordinates"); if (cJSON_IsArray(sitem)) { - sitem = cJSON_GetArrayItem(sitem, 0); - if (cJSON_IsArray(sitem)) + cJSON *tmp2 = cJSON_GetArrayItem(sitem, 0); + if (cJSON_IsArray(tmp2)) { - size_t cnt = cJSON_GetArraySize(sitem)-1;//最后一个是重复的 + size_t cnt = cJSON_GetArraySize(tmp2)-1;//最后一个是重复的 LOG_D("cnt of 'coordinates' pairs is %d", cnt); if (cnt<3) {//至少是个三角形 rst = -RT_ERROR; @@ -136,8 +136,8 @@ int mapParse(const char *fin,float *x, float *y) } for (size_t var = 0; var < cnt; var++) { - cJSON *llp = cJSON_GetArrayItem(sitem, var); - if (cJSON_IsArray(sitem)) + cJSON *llp = cJSON_GetArrayItem(tmp2, var); + if (cJSON_IsArray(llp)) { float lon = cJSON_GetNumberValue(cJSON_GetArrayItem(llp, 0)); //经度 x[var]= lon; @@ -208,11 +208,13 @@ static demo(int argc, char **argv) } float polyX[10]={},polyY[10]={}; +// cmd_free(); int polyCorners = mapParse(f,polyX,polyY); for (uint8_t var = 0; var < polyCorners; var++) { LOG_I("%d=%d.%d,%d.%d",var+1, (int)polyX[var],(int)((long)(polyX[var]*1000000) % 1000000), (int)polyY[var],(int)((long)(polyY[var]*1000000) % 1000000)); } +// cmd_free(); } MSH_CMD_EXPORT_ALIAS(demo,d_parseFence,解析围栏); diff --git a/applications/tosend.ini b/applications/tosend.ini index 0a33a6d..771fbe3 100644 --- a/applications/tosend.ini +++ b/applications/tosend.ini @@ -1,6 +1,6 @@ # V1.0 [tosend] -sd/rxdata/2023_08_23/23_08_23_08_31_44_14.bin 0 -sd/rxdata/2023_08_23/23_08_23_08_31_44_14.bin 0 +sd/rxdata/2023_08_23/23_08_23_08_31_44_14.bin 1 +sd/rxdata/2023_08_23/23_08_23_08_31_44_14.bin 2 [lstfile] diff --git a/applications/ttmsg/ttmsg.c b/applications/ttmsg/ttmsg.c index 73d53c7..cd95d0a 100644 --- a/applications/ttmsg/ttmsg.c +++ b/applications/ttmsg/ttmsg.c @@ -470,7 +470,7 @@ void recTT_thread_entry() void recTT(void) { /* 创建线程 */ - rt_thread_t thread = rt_thread_create("recTT", recTT_thread_entry, RT_NULL, 1024 * 6, 27, 10); + rt_thread_t thread = rt_thread_create("recTT", recTT_thread_entry, RT_NULL, 1024 * 6, 27-1, 10); /* 创建成功则启动线程 */ if (thread != RT_NULL) { diff --git a/applications/uart_3S.c b/applications/uart_3S.c index 14b73d1..980db95 100644 --- a/applications/uart_3S.c +++ b/applications/uart_3S.c @@ -93,7 +93,10 @@ static void serial_thread_entry(void *parameter) { /* 从串口读取数据*/ rx_length = rt_device_read(msg.dev, 0, rx_buffer, msg.size); - + if (!rx_length) { + LOG_W("read from RS232 error"); + continue; + } LOG_I("%d Bytes received from RS232",rx_length); LOG_HEX("232rx:",16,rx_buffer,rx_length);//print what received. parseRS232(rx_buffer, rx_length);