[英]How to log the particular variable data which comes randomly at serial com port in C# from Arduino
I am working on a project in which I have set up a serial communication between Arduino and C# window form application.我正在开展一个项目,在该项目中,我在 Arduino 和 C# window 表单应用程序之间建立了串行通信。 When I send a start command to Arduino, Arduino starts rotating the servo motor attached to it and sends the angle position to c# in a continuous manner.
当我向 Arduino 发送启动命令时,Arduino 开始旋转连接到它的伺服电机,并以连续的方式将角度 position 发送到 Z240AA2CEC4B29C56F3BEE520A。
Now while Arduino is sending the data to C#, I request a variable data stored in Arduino at a random time at the same serial port and I want to log that variable data in my c#.i can log whatever data is being received on serial port but I can't select and extract that particular variable. Now while Arduino is sending the data to C#, I request a variable data stored in Arduino at a random time at the same serial port and I want to log that variable data in my c#.i can log whatever data is being received on serial port但我不能 select 并提取该特定变量。
Can anyone please help me with that?有人可以帮我吗?
I'll just lay this out here.我就在这里说一下吧。 Picking up where jdweng left off, your messages also need to contain messaging protocol state information.
从 jdweng 停止的地方开始,您的消息还需要包含消息协议 state 信息。 Once this information has been included, you will be able to de-serialize any message in any order because the information required to process it is contained in the message.
包含此信息后,您将能够以任何顺序对任何消息进行反序列化,因为处理它所需的信息包含在消息中。
Here is an example protocol.这是一个示例协议。
Message -信息 -
So your angle message would consist of three parts Length, Type, and Value所以你的角度信息将由长度、类型和值三部分组成
AngleMessage角度消息
ParameterMessage参数消息
MessageBody = {消息体 = {
} }
Using this scheme your message contains all the information you need to process it.使用此方案,您的消息包含处理它所需的所有信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.