中级会员
 
- 积分
- 490
- 金钱
- 490
- 注册时间
- 2015-2-5
- 在线时间
- 113 小时
|
1金钱
向大佬请假一下,目前用c8t6串口做转发,串口1接收数据用串口2转发出去,同理串口2接收到数据在用串口1转发出去,串口1和串口2的波特率不一样,目前我采用的是缓存区的办法void PutChar(uint8_t c){
USART1_fifo.Buf[USART1_fifo.Write] = c;
if(++USART1_fifo.Write >= FIFO_SIZE)
{
USART1_fifo.Write = 0;
}
}
uint8_t GetChar(uint8_t *c)
{
if(USART1_fifo.Read == USART1_fifo.Write)
{
return 0;
}
else
{
*c = USART1_fifo.Buf[USART1_fifo.Read];
if (++USART1_fifo.Read >= FIFO_SIZE)
{
USART1_fifo.Read = 0;
}
return 1;
}
}现在存在的问题就是数据转发过程中有分包现象,例如串口1接收到01,02,03,04,05;串口2发送会变成:01,02 03,04, 05 数据发生了断开的现象。请教大家有什么好的办法解决这个问题呢
|
|