1-修改中控串口数据分析线程操作逻辑为双队列
2-数据库线程添加连续1000调用强制关闭一次数据库以清理内存
This commit is contained in:
1 parent
efc78addd9
commit
4096b49a15
4 files changed
+31
-27
No files matched your search
@@ -24,8 +24,8 @@
|
||||
#define DBG_LVL DBG_LOG
|
||||
#include <rtdbg.h>
|
||||
|
||||
rt_mq_t proc_mq;
|
||||
//static struct proc_request *req;
|
||||
struct rt_messagequeue *request_mq; // UART → Proc
|
||||
struct rt_messagequeue *response_mq; // Proc → UART
|
||||
|
||||
char cjson_falg=0;//是否解析cjson
|
||||
char *json_buffer=NULL;//
|
||||
@@ -535,7 +535,7 @@ void proc_thread_entry(void *parameter)
|
||||
while (1)
|
||||
{
|
||||
// 接收请求指针
|
||||
if (rt_mq_recv(proc_mq, &req, sizeof(req), RT_WAITING_FOREVER) >= RT_EOK)
|
||||
if (rt_mq_recv(request_mq, &req, sizeof(req), RT_WAITING_FOREVER) >= RT_EOK)
|
||||
{
|
||||
if (!req) continue;
|
||||
memcpy(DATA_api,req->input,5);
|
||||
@@ -565,11 +565,8 @@ void proc_thread_entry(void *parameter)
|
||||
{
|
||||
req->input[i]=0;
|
||||
}
|
||||
// 通知 UART 线程可以发送了
|
||||
if (req->sem)
|
||||
{
|
||||
rt_sem_release(req->sem);
|
||||
}
|
||||
// 发送到 UART 线程
|
||||
rt_mq_send(response_mq, &req, sizeof(req));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -580,8 +577,9 @@ static void *dat_comm_stack __attribute__((aligned(4)))= RT_NULL ;
|
||||
int data_comm_init(void)
|
||||
{
|
||||
rt_err_t dat_err;
|
||||
proc_mq = rt_mq_create("proc_mq", sizeof(struct proc_request*), 5, RT_IPC_FLAG_FIFO);
|
||||
if (proc_mq == RT_NULL)
|
||||
request_mq = rt_mq_create("request_mq", sizeof(struct proc_request*), 5, RT_IPC_FLAG_FIFO);
|
||||
response_mq = rt_mq_create("response_mq", sizeof(struct proc_request*), 5, RT_IPC_FLAG_FIFO);
|
||||
if ((request_mq == RT_NULL) || (response_mq ==RT_NULL))
|
||||
{
|
||||
LOG_E("Failed to create message queue!\n");
|
||||
return -1;
|
||||
|
||||
@@ -20,11 +20,11 @@ struct proc_request {
|
||||
int input_len;
|
||||
char output[MAX_OUTPUT_LEN];
|
||||
int output_len;
|
||||
struct rt_semaphore *sem; // 指向动态分配的信号量
|
||||
};
|
||||
|
||||
// 消息队列(供外部使用)
|
||||
extern rt_mq_t proc_mq;
|
||||
// 双消息队列声明
|
||||
extern struct rt_messagequeue *request_mq; // UART → Proc
|
||||
extern struct rt_messagequeue *response_mq; // Proc → UART
|
||||
|
||||
int data_comm_init(void);
|
||||
|
||||
|
||||
Reference in new issue
Block a user