@ KDEV 2007 Some Rights Reserved
GPIO I/O control extension for PHP

GPIO
is a PHP extension that provide you the commands to control I/O of the fox board from your PHP script.

Command Description
gpio_ctl() Verify is module is loaded gpio_ctl() is a simple function usefull to check if module is loaded.

Example:

<?
echo gpio_ctl();
?>

print on the sceen: GPIO module is loaded KDEV 2007

gpioXset("iomask") Set the lines specified by the bit mask "iomask" to 1 gpioXset("iomask") is a function that require a parameter, the IOMASK. IOMASK is a bit mask used to define which bits have to be set or reset by means of the ioctl() call.
With this method, the ports A,B and G can be configured changing X with the port,
gpioaset("iomask"); or gpiobset("iomask"); or gpiogset("iomask");

Example:
<?
//SET Port A line 3
echo gpioaset("1<<3");
?>

print on the sceen: 1

1 operation succeessfully executed
NULL an error occured and it is displayed in PHP WARNING message
gpioXclear("iomask") Set the lines specified by the bit mask "iomask" to 0 gpioXclear("iomask") is a function that require a parameter, the IOMASK. IOMASK is a bit mask used to define which bits have to be set or reset by means of the ioctl() call.
With this method, the ports A,B and G can be configured changing X with the port,
gpioaclear("iomask"); or gpiobclear("iomask"); or gpiogclear("iomask");

Example:

<?
//SET Port A line 3
echo gpioaclear("1<<3");
?>
1 operation succeessfully executed
NULL an error occured and it is displayed in PHP WARNING message
gpioXread() read an input line gpioXread() the return value of this function is a bitmask with all the current input line status.
With this method, you can read the ports A,B and G changing X with the port,
gpioaread(); or gpiobread(); or gpiogread();

Example:
<?
//READ port A
echo gpioaread();
?>

print on the sceen: 234
gpioXinput("iomask") set direction to INPUT gpioXinput("iomask") this function define the line as INPUT
IOMASK is a bit mask used to define which bits have to be set or reset by means of the ioctl() call.

1 operation succeessfully executed
NULL an error occured and it is displayed in PHP WARNING message
gpioXoutput("iomask") set direction to OUTPUT gpioXoutput("iomask") this function define the line as OUTPUT
IOMASK is a bit mask used to define which bits have to be set or reset by means of the ioctl() call.

1 operation succeessfully executed
NULL an error occured and it is displayed in PHP WARNING message

For example to set the lines 3,4 and 5 on Port G the value of iomask will be:

<?
$iomask = 1<<5 | 1<<4 | 1<<3; // iomask=00000000 00000000 00000000 00111000
$status=gpiogset($iomask);
if ($status=="1") { echo "Operation succesfully completed"; }
else { echo "An error occured"; }
?>



EXAMPLE

This example put 2 links in a webpage, ON and OFF, pushing ON you turn on the red led pushing off you turn it off.

<?
$cmd=$_REQUEST['cmd'];
echo "<a href=\"gpio.php?cmd=on\">ON</a> | <a href=\"gpio.php?cmd=off\">OFF</a>";
echo "<br>";
echo "<br>";
echo "<br>";
echo "<br>";
//change status
if ($cmd=="on")
{
$status=gpioaclr("1<<3");
}
if ($cmd=="off")
{
$status=gpioaset("1<<3");
}
echo "<br>";
//read port
echo "READ GPIOA PORT: <b><font color=\"red\">".gpioaread()."</font></b>";
//Directions
//$iomask="1<<3);
//$inputdir= gpioainput($iomask);
//$outputpir=gpioaoutput($iomask);
//
echo "<br>";
echo "<br>";
echo "<br>";
//
//control if module is loaded
echo gpio_ctl();
?>

Configuration files PATH
GPIO
configuration: /etc/php.ini

LOOK also LCD HITACHI HD44780 control extension for PHP
LOOK also I2C A/D converter PC8591 control extension for PHP

For more info go to:
ACME SYSTEMS WEBSITE I/O CONTROL USING C



SMS MMS FoxBox the appliance based on foxserve for messaging management








foXServe is Developed by KDEV a Davide Cantaluppi company and running on ACME SYSTEMS srl Hardware.

@ KDEV 2007 Some Rights Reserved
foXServe firmware is free
foXServe firmware
Download it now!


LICENSES

Apache/1.3.37 Server

Copyright 2007 Kdev of Davide Cantaluppi Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

PHP 5.0.5
"This product includes PHP software, freely available from <http://www.php.net/software/>"

MOD_DAV
This product includes software developed by Greg Stein <gstein@lyra.org> for use in the mod_dav module for Apache (http://www.webdav.org/mod_dav/).