开发者

Streaming RS-232 Output to the browser

Is this possible? If so, what is the industry standard as far as software goes? Specifically, I am referring to .net controls.

Thank you

EDITED: Here is what I need. I have a thin client with a balance where RS-232 is used to interact with the thin client. Currently, it is a compact framework app. What I would like to know id whether it is possible to have the same set up in a web application. So that would entail that the RS-232 is NOT the server R开发者_开发百科S-232 - it is the user's computer RS-232 - RS-232 is on the client. So when the RS-232 spits out input, it should go to the browser. Is it possible in a web application?


Two ways I can think of;

  • Buffer the serial data in an application object, and then use an ajax call triggered by a timer to grab and display the latest data.
  • For shorter streams of data, you could, instead of using asp.net controls per se, do something like;

    Response.ContentType = "text/plain";
    Response.Clear();
    
    String serialData;
    
    while(serialData = getSerialData() {
       Response.Write(serialData);
       Response.Flush();
    }
    

    This will write text content to the web browser in real time. You probably wouldn't want to keep this session open for too long though.

    If you wanted to display the stream of data within another page, then just place the page with the above code within an iFrame.

    Also note that the above would best be done in an ashx handler rather than an aspx page.


Sure, you can do it. You'd read from a System.IO.Ports.SerialPort instance, and output it via an HttpListener.

The trick will be knowing what you want to do with the page that the HttpListener serves up. Since data will be coming in on the COM port in real time, you'll probably want to buffer it between HTTP requests to your server, since otherwise, if you try to read the port without data waiting, you'll hang the listener. You can also miss data if you don't read it regularly and it fills the SerialPort read buffer.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜