嗨,大家好。我有关于串行通信的问题 [英] Hi Everyone. I Have Problem About Serial Communication

查看:70
本文介绍了嗨,大家好。我有关于串行通信的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Plz任何人都可以给我发送一个示例程序

我有关于串口plz帮助的问题。我有一个设备发送数据,如#23 14 35现在我想把它作为textbox1.text = 23 textbox2.text = 14和textbox3.text = 35

plz帮助如何做到这一点。我正在使用visual studio 2010

解决方案

首先查看 SerialPort类 [ ^ ]并确保在开始播放之前可以成功收到整条消息将它拆分 - 相比之下,拆分位是微不足道的。

最糟糕的是,一个简单的string.Split会这样做:

 < span class =code-keyword> string  input =  #23 14 35 ; 
string [] parts = input.Split( .ToArray());



所以请忽略它,直到你让复杂的位工作正常 - 它通常比你想到的更难启动。


Plz anyone can send me a sample program
i have an problem about serial port plz help. i have an device which send data like #23 14 35 now i want to get it as textbox1.text =23 textbox2.text=14 and textbox3.text=35
plz help how to do it. i am using visual studio 2010

解决方案

Start by looking at the SerialPort class[^] and make sure you can successfully receive the whole message before you start "playing" with it to split it up - the split bit is trivial in comparison.
At worst, a simple string.Split will do it:

string input = "#23 14 35";
string[] parts = input.Split("# ".ToArray());


So ignore that until you have the complex bit working properly - it's generally harder than you think when you get started.


这篇关于嗨,大家好。我有关于串行通信的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆