简体   繁体   中英

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). And I have to update the webform label every time the scanner reads something (it's connected through serial port). Any ideas?

BTW: I'm using C# and ASP.NET running on Windows 7.

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. I use it to read input into a buffer.

Tip: To link the DataReceived function you can just hit tab after typing "+=". Visual studio should build the function for you.

I am not sure about webforms, but for capturing serial events this should work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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