upSend 线程限制为1个
降低repGetTT 和 getTT 的堆栈分配 更新build逻辑 recTT 调整优先级 rt_device_read返回结果判断 ------- 缓存版本,后续版本采用外置sram加大内存
This commit is contained in:
parent
f30132d825
commit
490eae8d23
@ -190,7 +190,7 @@ static void upSendFile_thread_entry(void *parameter)
|
|||||||
LOG_D("ready to send '%s---%d'",f->fname,f->index);
|
LOG_D("ready to send '%s---%d'",f->fname,f->index);
|
||||||
rt_uint8_t len = pack_File(f->fname, 0, d, s);
|
rt_uint8_t len = pack_File(f->fname, 0, d, s);
|
||||||
for (size_t i = 0; i < len; i++) {
|
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();
|
// list_thread();
|
||||||
if (len)
|
if (len)
|
||||||
@ -285,6 +285,7 @@ void getAndSendFile()
|
|||||||
}
|
}
|
||||||
//发送完毕
|
//发送完毕
|
||||||
// rt_sem_take(sem, timeout)
|
// rt_sem_take(sem, timeout)
|
||||||
|
LOG_D("mission done.");
|
||||||
resetTM();
|
resetTM();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -328,6 +329,7 @@ static void chkAndSendFile_thread_entry()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
LOG_W("---------------");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -472,7 +474,7 @@ void initTT_thread_entry()
|
|||||||
tcpRecMQ(); //开启tcp接收线程
|
tcpRecMQ(); //开启tcp接收线程
|
||||||
recTT();
|
recTT();
|
||||||
repGetTT();
|
repGetTT();
|
||||||
reportLoc();
|
// reportLoc();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -504,6 +506,7 @@ void deInitTT_thread_entry()
|
|||||||
// initThread = RT_NULL;
|
// initThread = RT_NULL;
|
||||||
|
|
||||||
deinitThread = RT_NULL;
|
deinitThread = RT_NULL;
|
||||||
|
list_thread();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -156,11 +156,12 @@ typedef struct
|
|||||||
|
|
||||||
} SMSG;//single messgae
|
} SMSG;//single messgae
|
||||||
|
|
||||||
|
rt_sem_t one_msg_send_done=RT_NULL;
|
||||||
void upSend_thread_entry(void* parameter)
|
void upSend_thread_entry(void* parameter)
|
||||||
{
|
{
|
||||||
SMSG* msg = RT_NULL;
|
SMSG* msg = RT_NULL;
|
||||||
msg = (SMSG*) parameter;
|
msg = (SMSG*) parameter;
|
||||||
LOG_D("1--%p",msg);
|
// LOG_D("1--%p",msg);
|
||||||
// LOG_HEX("--",16,msg->data,msg->len);
|
// LOG_HEX("--",16,msg->data,msg->len);
|
||||||
|
|
||||||
//check status
|
//check status
|
||||||
@ -216,6 +217,7 @@ void upSend_thread_entry(void* parameter)
|
|||||||
cacheDataToFile(msg->data, msg->len);
|
cacheDataToFile(msg->data, msg->len);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
rt_sem_release(one_msg_send_done);
|
||||||
list_thread();
|
list_thread();
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
@ -229,13 +231,24 @@ RT_WEAK int upSend(uint8_t *din, size_t len)
|
|||||||
{
|
{
|
||||||
LOG_D("try to upsend to TT.");
|
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;
|
static SMSG msg;
|
||||||
memset(&msg, 0, sizeof(SMSG));
|
memset(&msg, 0, sizeof(SMSG));
|
||||||
memcpy(msg.data,din,len);
|
memcpy(msg.data,din,len);
|
||||||
msg.len=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 线程 */
|
/* 创建 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)
|
if (thread != RT_NULL)
|
||||||
{
|
{
|
||||||
@ -593,7 +606,7 @@ static int packLocMsg(uint8_t *dout)
|
|||||||
alertMsg[8 + len + 1] = 0xED;
|
alertMsg[8 + len + 1] = 0xED;
|
||||||
|
|
||||||
len = 8 + len + 2;
|
len = 8 + len + 2;
|
||||||
LOG_HEX("packLocMsg", 16, alertMsg, len); //bccCRC+Tail
|
// LOG_HEX("packLocMsg", 16, alertMsg, len); //bccCRC+Tail
|
||||||
memcpy(dout, alertMsg, len);
|
memcpy(dout, alertMsg, len);
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
@ -852,7 +865,7 @@ void reSend(uint8_t *din, uint8_t len)
|
|||||||
|
|
||||||
char str[30]="";
|
char str[30]="";
|
||||||
bytes2str(din, len-1, 10, "_", str);
|
bytes2str(din, len-1, 10, "_", str);
|
||||||
|
strcat(f,"20");
|
||||||
strncat(f,str,8);
|
strncat(f,str,8);
|
||||||
strcat(f,"/");
|
strcat(f,"/");
|
||||||
strcat(f,str);
|
strcat(f,str);
|
||||||
@ -1027,7 +1040,7 @@ void parse3SData(uint8_t *din, size_t count)
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
LOG_I("pass-through raw data.");
|
LOG_I("pass-through raw data.");
|
||||||
if (isTTon())
|
if (isTTjh())
|
||||||
{//如果TT为开机状态(具备通信状态?待商榷)则不缓存直接发
|
{//如果TT为开机状态(具备通信状态?待商榷)则不缓存直接发
|
||||||
upSend(din, count);
|
upSend(din, count);
|
||||||
}
|
}
|
||||||
|
@ -371,7 +371,7 @@ void getTT(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* 创建 serial 线程 */
|
/* 创建 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)
|
if (thread != RT_NULL)
|
||||||
{
|
{
|
||||||
@ -469,7 +469,7 @@ void repGetTT(void)
|
|||||||
{}
|
{}
|
||||||
memset(rstInfo,0x3f,RST_LEN);//初始化
|
memset(rstInfo,0x3f,RST_LEN);//初始化
|
||||||
/* 创建 serial 线程 */
|
/* 创建 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)
|
if (thread != RT_NULL)
|
||||||
{
|
{
|
||||||
|
@ -102,8 +102,7 @@ void show_version(void)
|
|||||||
char str[30];
|
char str[30];
|
||||||
uint8_t t[10];
|
uint8_t t[10];
|
||||||
size_t len=time2Byte(t);
|
size_t len=time2Byte(t);
|
||||||
bytes2str(t, len, 10, "", str);
|
rt_kprintf("SW Version: %s, build-%s\n","1.5",bytes2str(t, 3, 10, "", str));
|
||||||
rt_kprintf("SW Version: %s, build-%s\n","1.46",bytes2str(t, len, 10, "", str));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MSH_CMD_EXPORT(show_version,显示版本号);
|
MSH_CMD_EXPORT(show_version,显示版本号);
|
||||||
|
@ -109,8 +109,8 @@ int mapParse(const char *fin,float *x, float *y)
|
|||||||
if (cJSON_IsArray(object))
|
if (cJSON_IsArray(object))
|
||||||
{
|
{
|
||||||
// LOG_D("size of 'features' is %d",cJSON_GetArraySize(object));
|
// LOG_D("size of 'features' is %d",cJSON_GetArraySize(object));
|
||||||
object = cJSON_GetArrayItem(object, 0);
|
cJSON *tmp = cJSON_GetArrayItem(object, 0);
|
||||||
item = cJSON_GetObjectItem(object, "geometry");
|
item = cJSON_GetObjectItem(tmp, "geometry");
|
||||||
if (item)
|
if (item)
|
||||||
{
|
{
|
||||||
cJSON *sitem = cJSON_GetObjectItem(item, "type");
|
cJSON *sitem = cJSON_GetObjectItem(item, "type");
|
||||||
@ -124,10 +124,10 @@ int mapParse(const char *fin,float *x, float *y)
|
|||||||
sitem = cJSON_GetObjectItem(item, "coordinates");
|
sitem = cJSON_GetObjectItem(item, "coordinates");
|
||||||
if (cJSON_IsArray(sitem))
|
if (cJSON_IsArray(sitem))
|
||||||
{
|
{
|
||||||
sitem = cJSON_GetArrayItem(sitem, 0);
|
cJSON *tmp2 = cJSON_GetArrayItem(sitem, 0);
|
||||||
if (cJSON_IsArray(sitem))
|
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);
|
LOG_D("cnt of 'coordinates' pairs is %d", cnt);
|
||||||
if (cnt<3) {//至少是个三角形
|
if (cnt<3) {//至少是个三角形
|
||||||
rst = -RT_ERROR;
|
rst = -RT_ERROR;
|
||||||
@ -136,8 +136,8 @@ int mapParse(const char *fin,float *x, float *y)
|
|||||||
}
|
}
|
||||||
for (size_t var = 0; var < cnt; var++)
|
for (size_t var = 0; var < cnt; var++)
|
||||||
{
|
{
|
||||||
cJSON *llp = cJSON_GetArrayItem(sitem, var);
|
cJSON *llp = cJSON_GetArrayItem(tmp2, var);
|
||||||
if (cJSON_IsArray(sitem))
|
if (cJSON_IsArray(llp))
|
||||||
{
|
{
|
||||||
float lon = cJSON_GetNumberValue(cJSON_GetArrayItem(llp, 0)); //经度
|
float lon = cJSON_GetNumberValue(cJSON_GetArrayItem(llp, 0)); //经度
|
||||||
x[var]= lon;
|
x[var]= lon;
|
||||||
@ -208,11 +208,13 @@ static demo(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
float polyX[10]={},polyY[10]={};
|
float polyX[10]={},polyY[10]={};
|
||||||
|
// cmd_free();
|
||||||
int polyCorners = mapParse(f,polyX,polyY);
|
int polyCorners = mapParse(f,polyX,polyY);
|
||||||
for (uint8_t var = 0; var < polyCorners; var++) {
|
for (uint8_t var = 0; var < polyCorners; var++) {
|
||||||
LOG_I("%d=%d.%d,%d.%d",var+1,
|
LOG_I("%d=%d.%d,%d.%d",var+1,
|
||||||
(int)polyX[var],(int)((long)(polyX[var]*1000000) % 1000000),
|
(int)polyX[var],(int)((long)(polyX[var]*1000000) % 1000000),
|
||||||
(int)polyY[var],(int)((long)(polyY[var]*1000000) % 1000000));
|
(int)polyY[var],(int)((long)(polyY[var]*1000000) % 1000000));
|
||||||
}
|
}
|
||||||
|
// cmd_free();
|
||||||
}
|
}
|
||||||
MSH_CMD_EXPORT_ALIAS(demo,d_parseFence,解析围栏);
|
MSH_CMD_EXPORT_ALIAS(demo,d_parseFence,解析围栏);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# V1.0
|
# V1.0
|
||||||
[tosend]
|
[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 1
|
||||||
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 2
|
||||||
|
|
||||||
[lstfile]
|
[lstfile]
|
||||||
|
@ -470,7 +470,7 @@ void recTT_thread_entry()
|
|||||||
void recTT(void)
|
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)
|
if (thread != RT_NULL)
|
||||||
{
|
{
|
||||||
|
@ -93,7 +93,10 @@ static void serial_thread_entry(void *parameter)
|
|||||||
{
|
{
|
||||||
/* 从串口读取数据*/
|
/* 从串口读取数据*/
|
||||||
rx_length = rt_device_read(msg.dev, 0, rx_buffer, msg.size);
|
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_I("%d Bytes received from RS232",rx_length);
|
||||||
LOG_HEX("232rx:",16,rx_buffer,rx_length);//print what received.
|
LOG_HEX("232rx:",16,rx_buffer,rx_length);//print what received.
|
||||||
parseRS232(rx_buffer, rx_length);
|
parseRS232(rx_buffer, rx_length);
|
||||||
|
Loading…
Reference in New Issue
Block a user