Web controlling using PHP and AJAX

Web controlling using PHP and AJAX

The portcontrol softwae web interface for controlling parallel port is simple modern web based interface for controlling parallel port. The software is based on PHP software running on Linux server and a JavaScript based client application running on the user web browser. With this apprioach it is possible to get the almost real-time status of the parallel port data pins to the screen nicely and do flexible controlling easily.

The server end is based on small piece of PHP code and portconrol software. portconrol is a simple general purpose I/O port control program for Linux. It allows you to write and read the supported I/O ports. The software allows writing specified value to port, reading value at given I/O address and printing it out to screen in different formats and bit-level manipulation of the port data.

Port control web interface

The control.php file does the port conrol magic. When it is loaded, the user gets a web page plus user end JavaScript code. That JavaScript code periodically (once in 5 seconds) asks the parallel port state from the server (AJAX call) and if it has changed updates status to the screen. It also handles the control buttons. Every control button press makes the control software to call the server to make desired function (AJAX call). After controlling is done, the server returns the current port status (it is printed to screen). When the control software is written in this way, it works prerry well and feels almost like a graphical application programs controlling the parallel port directly (instead of typical web application that loads web page again and again every time you do something).

Besides the actual controllign PHP script, I have written also an another version of the control.php file. This file controlfile.php work pretty much in the same way, but instead of controlling parallel port writes and reads the status from a file (status.txt in the same directory as the script is). You can use it to easily test the AJAX/PHP based control system anuwhere (the computer does not need to have any real port in it). The file based AJAX port control test application is availble here for you to test.

The portcontrol software with web interface is is available as portcontrol.tar package that includes the source code, instructions for compiling/installing and instructions for use. For more details check the README.

To use the software you need to download also SAJAX Simple Ajax Toolkit by ModernMethod from http://www.epanorama.net/counter.php?url=http://www.modernmethod.com/sajax/. I developed this software using PHP4 some years ago. I have not tested to software with PHP5.

Programming I/O



Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / เปลี่ยนแปลง )

Twitter picture

You are commenting using your Twitter account. Log Out / เปลี่ยนแปลง )

Facebook photo

You are commenting using your Facebook account. Log Out / เปลี่ยนแปลง )

Google+ photo

You are commenting using your Google+ account. Log Out / เปลี่ยนแปลง )

Connecting to %s

%d bloggers like this: