fix south ch

This commit is contained in:
wmano
2025-09-24 21:47:15 +08:00
parent b7a2df5583
commit 21158288ac
6 changed files with 20 additions and 81 deletions
+8 -32
View File
@@ -1,4 +1,4 @@
#include <string.h>
#include <rtthread.h>
#include "chrg_north.h"
@@ -38,54 +38,30 @@ static void chrg_north_thread_entry (void *data)
return ;
}
//rt_uint8_t crc8 = 0;
//rt_size_t len_mq = 0, len_get = 0, len_msg = 0;
struct chrg_tty_t *pTTY = pNOR->tty;
//struct mq_msg_t msg;
int len = 0;
struct chrg_tty_t *pTTY = pNOR->tty;
chrg_tty_set_recv_tmo(pTTY, 200);
chrg_tty_set_recv_tmo(pTTY, 100);
if (chrg_tty_connect(pTTY) != RT_EOK) {
chrg_tty_destory(pTTY);
return;
}
while (1) {
memset(pNOR->rx_buf, 0, sizeof(pNOR->rx_buf));
len = chrg_tty_recv(pTTY, pNOR->rx_buf, sizeof(pNOR->rx_buf));
if (len > 0) {
chrg_tty_send(pTTY, pNOR->rx_buf, len);
}
/*
rt_memset(&msg, 0, sizeof(struct mq_msg_t));
len_mq = rt_mq_recv(pTTY->mq, &msg, sizeof(struct mq_msg_t), RT_WAITING_FOREVER);
if (len_mq <= 0) {
if (len <= 0) {
rt_thread_mdelay(1);
continue;
}
len_get = rt_device_read(msg.dev, 0, &pNOR->rx_buf[0], 1);
if (1 != len_get) {
continue;
}
pNOR->rx_len = 1;
rt_kprintf("%s\r\n", (char *)pNOR->rx_buf);
chrg_tty_send(pTTY, pNOR->rx_buf, len);
len_msg = rt_device_read(msg.dev, 0, &pNOR->rx_buf[1], len_get-1);
if (len_msg <= 0) {
continue;
}
pNOR->rx_len += len_msg;
if (len_msg == len_get-1) {
crc8 = calc_crc8(pNOR->rx_buf, len_msg);
if (crc8 == pNOR->rx_buf[len_msg]) {
pNOR->rx_len = 0;
}
}
*/
}
}