简体   繁体   English

如何将串行端口传入数据打印到WebForm标签上?

[英]How to print serial port incoming data to WebForm label?

I have the server and the client in the same machine (idk why is this web-oriented, it wasn't my call). 我将服务器和客户端放在同一台机器上(idk,为什么这是面向Web的,不是我的电话)。 And I have to update the webform label every time the scanner reads something (it's connected through serial port). 每当扫描仪读取某些内容(它通过串行端口连接)时,我都必须更新Webform标签。 Any ideas? 有任何想法吗?

BTW: I'm using C# and ASP.NET running on Windows 7. 顺便说一句:我正在使用Windows 7上运行的C#和ASP.NET。

This is what I use in my local serial port application: 这是我在本地串行端口应用程序中使用的:

using System.IO.Ports;

SerialPort testPort = new SerialPort();
testPort.DataReceived += testPort_DataReceived;

Every time data is received, the DataReceived function is called. 每次接收到数据时,都会调用DataReceived函数。 I use it to read input into a buffer. 我用它将输入读入缓冲区。

Tip: To link the DataReceived function you can just hit tab after typing "+=". 提示:要链接DataReceived函数,您只需在键入“ + =”后单击tab。 Visual studio should build the function for you. Visual Studio应该为您构建该功能。

I am not sure about webforms, but for capturing serial events this should work. 我不确定Webforms,但是对于捕获串行事件,应该可以使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM