单帧长度增加为200+,MAX_LEN_3S

upSend函数添加分包功能
This commit is contained in:
CSSC-WORK\murmur 2023-11-05 10:18:09 +08:00
parent efd3c2e425
commit d6edb25d2d
2 changed files with 14 additions and 8 deletions

View File

@ -194,20 +194,23 @@ void upSend_thread_entry(void* parameter)
time2Str(fin);
strcat(fin,".bin");
packInit(&cfg, fin, 0); //写入配置
#define PACK_SIZE 130
cfg.fcurpiece[0] = 1;
cfg.fallpiece[0] = 1;
cfg.fallpiece[0] = msg->len/PACK_SIZE+1;
#ifdef CRYPT_BEFRE_PACK
//crypt before pack
//更改后3S单帧数据由160升为240超出TT最大单包数据容量须分包
for (size_t var = 0; var < msg->len; var=var+PACK_SIZE) {
cfg.fcurpiece[0] = var+1;
uint8_t tmp[200];
uint8_t len = cryptSingleMsg(msg->data, msg->len, tmp);
if (len>170) {
LOG_W("length of msg is too long.[%d->%d]",msg->len,len);
}
uint8_t len = cryptSingleMsg(msg->data+var, (msg->len-var)>PACK_SIZE?PACK_SIZE:(msg->len-var), tmp);
size_t rst = packMsg(&cfg, tmp, len, dout);//packMsgs
#else
size_t rst = packMsg(&cfg, tmpmsg->data, msg->len, dout);//packMsgs
#endif
LOG_HEX("upSend", 27, dout, rst);
// LOG_HEX("upSend", 27, dout, rst);
if (rst)
{
if (sendMsg(dout, rst) == RT_EOK)
@ -220,12 +223,14 @@ void upSend_thread_entry(void* parameter)
cacheDataToFile(msg->data, msg->len);
}
}
}
// rt_sem_release(one_msg_send_done);
// list_thread();
return ;
}
/**
*
*
* @param din
* @param len
* @return
@ -1682,7 +1687,7 @@ void parseRS232(uint8_t *din, size_t len)
for (size_t i = 0; i < n; i++)
{
//按帧头分割
uint8_t ndin[300];
uint8_t ndin[MAX_LEN_3S];
int cnt=(i+1<n)?index[i+1]-index[i]:len-index[i];
memcpy(ndin,din+index[i],cnt);
if (n>1) LOG_HEX("frame",16,ndin,cnt);

View File

@ -70,4 +70,5 @@ typedef struct
#define UPDATE_INTERVAL 10
#define RELAY
#define MAX_LEN_3S 300
#endif /* APPLICATIONS_USRCFG_H_ */