R – ASP.NET web page to device connect to server’s USB (COM) port

arduinoasp.netusbvb.net

I am working on a way to send commands to an Arduino board from a web site. The Arduino board is connected to the computer via a USB port (a COM port).

I have managed to connect and control the board using a VB.NET program. I also wrote a VB.NET class that can instantiate a COM connection and send and receive messages.

My next step is to basically create a program that will act as a proxy between my web server (IIS 7 running on Windows Vista) and the Arduino board. When a user gets to my ASP.NET page, the page will then send a command to the proxy to open the COM connection. When the connection is open and ready then I can send commands to the proxy. In turn, the proxy will send these commands to the board and listen for the responses it receives from the board. The proxy will then pass these messages back to the ASP.NET page.

I have several questions I hope the group can help me answer…

  1. Am I in the right direction with this approach? Are there easier or more efficient ways of doing this?

  2. The main issue I see occurring is that if a second user opens the web page and tries to open the COM port, there will be an error. Will this cause the first connection to fail? I guess I can first check if the port is already in use and give the second user a message.

  3. Are there any other potential challenges I am missing or not seeing?

Best Solution

Rather than storing the connecting object in the HttpSessionState, store it in the HttpApplicationState so that it is accessible to all users.

You'll need to be careful to synchronize access to the COM port to avoid the serial communication initiated by individual HTTP requests from getting mixed up and confusing the Arduino.