diff --git a/applications/func/func.c b/applications/func/func.c index c0cab66..8faba88 100644 --- a/applications/func/func.c +++ b/applications/func/func.c @@ -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+11) LOG_HEX("frame",16,ndin,cnt); diff --git a/applications/usrcfg.h b/applications/usrcfg.h index 530be2e..5fa1284 100644 --- a/applications/usrcfg.h +++ b/applications/usrcfg.h @@ -70,4 +70,5 @@ typedef struct #define UPDATE_INTERVAL 10 #define RELAY +#define MAX_LEN_3S 300 #endif /* APPLICATIONS_USRCFG_H_ */