[英]How can I print a message stored in a buffer?
我正在尝试编写一个名为 SerialSend 的 function,它将将环形缓冲区(名为 testbuff)的内容打印到我的控制台。这是我对 SerialSend 的定义。
void SerialSend (USInt* pusiBuffer, UDInt len, UDInt connectionId)
{
USART_WriteByte(DEMO_USART, testbuff[i]);
i++;
i %= DEMO_RING_BUFFER_SIZE;
}
调用时,SerialSend 正在打印 testbuff 中的第一个字符。 如何让它打印缓冲区内容的 rest? 这是我调用 SerialSend 并且中断不起作用的 main 代码。
while(i<17)
{
SerialSend(testbuff, 17, 0) //Sends contents of testbuff to print in console
if (i==16)
{
break; //Break isn't working, probably because i never hits 16 due to the ring
}
}
事实证明我的环形缓冲区太小了,所以我将大小增加到 50 并像这样在 main 中编辑调用:
while(1)
{
SerialSend(testbuff, 50, 0); //Sends contents of testbuff to print in console
if (i==17)
{
break;
}
}
testbuff 缓冲区包含我要打印的 17 个字符,因此当索引到达消息末尾时,if 语句用于中断。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.