func.c 更新upSend函数

This commit is contained in:
CSSC-WORK\murmur 2023-07-25 14:55:03 +08:00
parent cee3c8ae2d
commit 98dd4840bb
4 changed files with 54 additions and 15 deletions

View File

@ -82,8 +82,39 @@ RT_WEAK int getPowerLevel(void)
return 0;
}
typedef struct
{
rt_uint8_t len;
rt_uint8_t data[];
} SMSG;//single messgae
void upSend_thread_entry(void* parameter)
{
SMSG* msg = RT_NULL;
msg = (SMSG*) parameter;
//打包数据
uint8_t dout[200];
static MSG cfg;
rt_memset(&cfg, 0, sizeof(MSG)); // 分配空间
char fin[30];
time2Str(fin);
strcat(fin,".bin");
packInit(&cfg, fin, 0); //写入配置
cfg.fcurpiece[0] = 1;
cfg.fallpiece[0] = 1;
size_t rst = packMsg(&cfg, msg->data, msg->len, dout);
LOG_HEX("upSend", 27, dout, rst);
if (rst)
{
if (sendMsg(dout, rst) == RT_EOK)
{
tcpClose();
LOG_I("send to TT Done.");
};
}
return 0;
}
/**
*
* @param din
@ -93,20 +124,26 @@ return 0;
RT_WEAK int upSend(uint8_t *din, size_t len)
{
//此函数有打包操作,需线程操作
LOG_D("upsend.");
return 0;
// LOG_D("upsend.");
// return 0;
static SMSG msg;
memset(&msg, 0, sizeof(SMSG));
memcpy(msg.data,din,len);
msg.len=len;
uint8_t dout[200];
//打包数据
static MSG cfg;
rt_memset(&cfg, 0, sizeof(MSG)); // 分配空间
char *fin;
time2Str(fin);
packInit(&cfg, fin, 0); //写入配置
size_t rst = packMsg(&cfg, din, len, dout);
LOG_HEX("upSend", 16, dout, rst);
return 0;
/* 创建 serial 线程 */
rt_thread_t thread = rt_thread_create("upSend", upSend_thread_entry, (void *) &msg, 1024 * 10, 27, 10);
/* 创建成功则启动线程 */
if (thread != RT_NULL)
{
rt_thread_startup(thread);
}
else
{
LOG_E("thread 'upSend' create failure.");
return;
}
}
/**

View File

@ -131,7 +131,7 @@ void show_version(void)
uint8_t t[10];
size_t len=time2Byte(t);
bytes2str(t, len, 10, "", str);
rt_kprintf("SW Version: %s build%s\n","1.44",bytes2str(t, len, 10, "", str));
rt_kprintf("SW Version: %s, build-%s\n","1.45",bytes2str(t, len, 10, "", str));
}
MSH_CMD_EXPORT(show_version,);

View File

@ -122,7 +122,9 @@ static size_t getID(const char *str, rt_uint8_t *out)
tmp[i] = v;
}
LOG_HEX("file ID",16,tmp,len);
// LOG_HEX("file ID",16,tmp,len);
char idstr[30];
LOG_I("msg id:%s",bytes2str(tmp, len, 16, "_", idstr));
memcpy(out, tmp, len);
return len;
}

View File

@ -30,7 +30,7 @@
#define SAMPLE_UART_NAME "uart3" /* 串口设备名称 */
#endif
#define MAX_SIZE_TO_SAVE 1024*2
#define MIN_FRAME_LEN 11
#define MIN_FRAME_LEN 10
/* 串口接收消息结构*/
struct rx_msg
{