Link to home
Start Free TrialLog in
Avatar of WingTsunMonk
WingTsunMonk

asked on

Controlling Serial Port from Web Browser with Perl (And updating HTML textarea with incoming data)

I have an embedded device I would like to control through a web browser.

I've got my webserver and Perl interpreter running and executing Perl code.  I have also been able to print incoming text from the embedded device to a inline frame on a "control" web page.  (All local)

At this point, I believe I am missing something rather basic to put this whole webapp together.

Once I start the serial port process up and have data being fed to my HTML page, how do I:

1.  Re-establish communication with the running CGI process so that I may make configuration changes to the serial port, or send data to the embedded device.

I.e.  Raise the DTR signal, change baudrate/commport/parity etc.

2.  Stop the web browser from continually looking like it's continually loading data.

I.e. Spinning hourglass or "Transferring data from" message in the web browser.

Seems doable, but out of my reach at the current moment.  
TIA
Steve
Avatar of Adam314
Adam314

Is the serial port communication being done directly from your perl application, or is there some other application that is handling that communication?

What OS are you on?
Avatar of WingTsunMonk

ASKER

Adam314

Thanks for the reply.  

Communication is being handled by the Perl program/script.  

I am currently developing the program on W2K, but will port to Unix\Linux as well.
1.  The CGI process should be your perl process - the web browser makes a request to your web server, the web server starts your perl program, your perl program communicates with the port.  Not really sure what you are asking here.

2.  The web browser will wait until all data has been received.  What is the problem with this?
From what I understand of the traditional CGI web application model, a program is restarted with each web request.   It would appear, in my scenario, that I would have a continually running perl process that I would need to interact with at a later time.  

Our embedded device, once connected to a RS232 channel and DTR toggled High,  will continually spit out information that I need to display into a text area or inline frame.  I will also need to employ some sort of file upload to the embedded device to help facilitate firmware upgrades.

One approach I took was to load an HTML page that had an inline frame who's source was the perl script. I could get the serial information from the device, and display it in the inline frame, but I do not understand how to control the serial port program at this point.
Okay... I thought you were going to a web page, having the server send some info to the serial port, get the results, send them to the web browser, then be done.

It sounds like you need some program running continuously to get the data.

You could have that program get new information from the webserver in a couple of ways.  What you are looking for is known as interprocess communication - or IPC.  There is a perl page describing the different methods:
    http://perldoc.perl.org/perlipc.html

To have the web browser not be always loading, you could have the page get the available data - the server returns whatever is available so far, then finishes.  Then add a meta refresh to the page so it will get new data every so often.
Or you could use AJAX to have the page continually get new data.  
Thanks....I thought I was headed in the correct direction but may have been tripping up on some concept.  

I'll look more into the IPC, I came across those modules at CPAN but quickly got lost in the magnitude of modules available at CPAN.  

Have you heard of, or had any working experience with Continuity, CoroChannel or Seaside?  

Could you comment on these?

http://continuity.tlt42.org/
http://search.cpan.org/~mlehmann/Coro-4.803/Coro/Channel.pm
http://www.seaside.st/

They seem pretty new and there is not a "whole" lot of documentation on them.  
ASKER CERTIFIED SOLUTION
Avatar of Adam314
Adam314

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you.  Based on your comment I will attack my problem from the direction you suggested.  If I do have a question,shall I post here or is there another preferred way I might ask you a question?
Posting here is the best way.  Not only me, but other experts will see your question.
Cool,

FYI for anyone interested.

I experimented with the latest build of Continuity on CPAN on a W2K system with ActiveState Perl 5.10.

The examples in the Continuity /eg will not work on Windows because Fcntl is not implemented yet on 5.10. (Or maybe never?)