fix mb & tty
This commit is contained in:
@@ -22,8 +22,8 @@ int chrg_north_send (rt_uint8_t *data, rt_size_t length)
|
||||
rt_ssize_t ret = -1;
|
||||
struct chrg_tty_t *pTTY = chrgnorth.tty;
|
||||
|
||||
if ((RT_NULL != pTTY)&&(RT_NULL != pTTY->dev)) {
|
||||
ret = rt_device_write(pTTY->dev, 0, data, length);
|
||||
if (RT_NULL != pTTY) {
|
||||
ret = chrg_tty_send(pTTY, data, length);
|
||||
}
|
||||
|
||||
return ret;
|
||||
@@ -37,12 +37,24 @@ 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;
|
||||
//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;
|
||||
//struct mq_msg_t msg;
|
||||
int len = 0;
|
||||
|
||||
chrg_tty_set_recv_tmo(pTTY, 200);
|
||||
if (chrg_tty_connect(pTTY) != RT_EOK) {
|
||||
chrg_tty_destory(pTTY);
|
||||
return;
|
||||
}
|
||||
|
||||
while (1) {
|
||||
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) {
|
||||
@@ -72,7 +84,7 @@ static void chrg_north_thread_entry (void *data)
|
||||
pNOR->rx_len = 0;
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
}
|
||||
|
||||
}
|
||||
@@ -82,8 +94,13 @@ static int chrg_north_init (void)
|
||||
rt_err_t ret;
|
||||
struct chrg_north_t *pNOR = &chrgnorth;
|
||||
|
||||
pNOR->tty = &chrgtty[IDX_TTY_NORTH];
|
||||
rt_memset(pNOR->rx_buf, 0, SIZE_BUF_UART);
|
||||
pNOR->tty = chrg_tty_create("uart3", 2000000, 0, -1, 1);
|
||||
if (RT_NULL == pNOR->tty) {
|
||||
LOG_E("tty can't create.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
rt_memset(pNOR->rx_buf, 0, SIZE_BUF_TTY);
|
||||
|
||||
ret = rt_mutex_init(&pNOR->lock, pNOR->name, RT_IPC_FLAG_FIFO);
|
||||
if (ret != RT_EOK) {
|
||||
|
||||
Reference in New Issue
Block a user