How can a web page read from the user’s serial port?

One thing for sure, you will never be able to communicate with the local machine hardware without installing some special binaries (and run it with appropriate privileges) on the local machine. However, that doesn’t mean you necessary need to use an ActiveX component and stay stuck with Internet Explorer. Of course, you could also develop a component for every browser in the market.

I suggest another approach:

  • Write a Windows Service (I assume your machine runs Windows), configure it with necessary privileges. You will have to install something on the machine anyway. The service can be implemented in any language.
  • Add HTTP(S) server capabilities to it. You can use a lot of technologies here from WCF to WebAPI.
  • Invent your own communication protocol over HTTP. You could use JSON, Ajax, WebSockets, SignalR, etc.
  • Write a Javascript file that will be compatible with most browsers on the market – so you only have to write that once – that will become your Serial COM API. You can support all browsers with Javascript and Ajax capabilities (XmlHttpRequest), with only one code base.

Here is how it would look like:
enter image description here

Leave a Comment