[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1280
  • Last Modified:

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
0
WingTsunMonk
Asked:
WingTsunMonk
  • 5
  • 5
1 Solution
 
Adam314Commented:
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?
0
 
WingTsunMonkAuthor Commented:
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.
0
 
Adam314Commented:
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?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
WingTsunMonkAuthor Commented:
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.
0
 
Adam314Commented:
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.  
0
 
WingTsunMonkAuthor Commented:
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.  
0
 
Adam314Commented:
No, I haven't used any of those.  I have used several of the methods discussed on the perl IPC page though, so if you decide to go that way, and have questions about that, let me know.
0
 
WingTsunMonkAuthor Commented:
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?
0
 
Adam314Commented:
Posting here is the best way.  Not only me, but other experts will see your question.
0
 
WingTsunMonkAuthor Commented:
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?)



0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

  • 5
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now