Read Serial port via web browser

3.1k Views Asked by At

I am currently reading Modbus via Serial port (Serial.IO.Ports) using ASP.NET C# Web application, I am able to read the serial port as I am running the application on my local machine.

While working on the project, I thought that the web app won't work once deployed on server because, it will try to access server's Serial port(COM) and not client's (the one running the website) obviously. Is there any library or package I can use to read the Serial port of the machine which is running the browser.

Let me know if I was not clear or if you need any more info.

2

There are 2 best solutions below

1
Lukasz Pomianowski On BEST ANSWER

If you're developing your app for your customer(s) you can: 1. develop windows-service that accepts http requests 2. Share the serial somehow on the ethernet so that the server can connect to the KNOWN ip address.

Browser ( JavaScript ) can't talk directly to the serial port.

1
Joey Phillips On

You could Try

System.IO.Ports

Use this class to control a serial port file resource. This class provides synchronous and event-driven I/O, access to pin and break states, and access to serial driver properties. Additionally, the functionality of this class can be wrapped in an internal Stream object, accessible through the BaseStream property, and passed to classes that wrap or use streams.

https://learn.microsoft.com/en-us/dotnet/api/system.io.ports.serialport?view=netframework-4.7.2