Click here to Skip to main content
15,891,248 members
Please Sign up or sign in to vote.
1.44/5 (2 votes)
See more:
There is a scenario in which we need to integrate Weighing machine and read the value using a web application created in MVC. Now the code we have in place works when the host is same as the client.
When we deploy the application on any other server, then the issue is the
Serial Port as its meta data says only reads for the current computer.

What I have tried:

I have gone through a few resources which say a windows application or ActiveX would do. But my query is,
ActiveX is browser specific i.e. only IE
and How would my web application hosted on cloud would interact with the windows application?

Any suggestions or example would help!
Regards
Posted
Updated 31-Oct-19 0:14am
Comments
Richard MacCutchan 6-Apr-16 10:42am    
That is exactly the root of the problem. Web applications are prevented from having direct access to devices on the client system for a very good reason.
Passion4Code 6-Apr-16 10:45am    
Yes correct. But any way round thats possible, I mean via any medium?

If you're pushing this site out to selected clients then you could do something like write a Windows Service that responds to HTTP requests and interacts with the hardware ports and sends an HTTP response back to the calling client. That way your webpage could use normal jQuery ajax to query the service and get data back that it can then pass to your server code like normal (another ajax call or a form submission).

It will still limit the client to Windows and need the clients to install a service, but it's an alternative to developing an ActiveX app or jaca applet or whatever.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 6-Apr-16 11:38am    
5ed.
—SA
A web application was a very poor choice. Unless the scale, communicating over a serial port, is directly connected to the web server you can't talk to the scale. As you've probably figured out by now, client-side javascript in a browser has no access to the PC's serial ports. Javascript can only talk to other web servers.

Now, here's an idea that doesn't involve you completely rewriting your application to support a rewritten client-side.

You write a Windows application or Service, which will have access to the serial ports. The app can talk to the scale and receive data from it but will also act as a web server, serving up the data it receives and can even accept commands from your client javascript code. You client code can only talk to web servers over HTTP using its normal operations like GET and POST. There's nothing that says the client-side code cannot talk to a web server running on the client itself.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 6-Apr-16 11:39am    
5ed.
—SA
Another way could be virtualizing your serial ports using a rs232 to etherenet converter, but you must know the client computers IP's.

Moxa Serial device servers
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900