相关疑难解决方法(0)

Arduino串行通信未收到整个消息

我对Arduino通信有疑问.这很难描述,所以我不能在标题中使用它.无论如何,这里有以下内容:

所以我的接收端有这个代码:

if(Serial1.available())
{
    while(Serial1.available())
    {
        uint8_t inByte = Serial1.read();

        inByte = inByte ^ k;

        Serial.write(inByte); 
    }

    Serial.println(" done");
}
Run Code Online (Sandbox Code Playgroud)

它应该在一行打印并在完成后打印完成.在Serial1.available()似乎跳过下Serial1.available(),我不知道发生了什么事情.无论如何这里是我当前的,坏的,输出:

h done
e done
l done
l done
o done

done
Run Code Online (Sandbox Code Playgroud)

应该是什么时候:

hello done
Run Code Online (Sandbox Code Playgroud)

我很抱歉,如果这可以说得更好但是现在我可以打字,我的大脑有点痛苦.我从未在Windows c ++控制台应用程序中遇到过这种行为.

serial-port communication arduino

2
推荐指数
1
解决办法
3944
查看次数

标签 统计

arduino ×1

communication ×1

serial-port ×1