PHP is a server side and scripting language used primarily on the web. PHP is used in approx 80% of all websites (for example facebook.com and wikipedia.org) Brainboxes has provided a Brainboxes.IO PHP API to allow easy integration of Brainboxes Ethernet IO Modules (ED-xxx) into you PHP code.

Requirements

  • Windows/Mac/Linux Computer
  • PHP Runtime (PHP 5.3.0 and above)
  • PHP Development Environment (e.g. Eclipse, PHP for Visual Studio, IntelliJ, NetBeans, or a simple Text Editor)
  • Brainboxes.IO API for PHP

Code Sample

The following sample code connects to a Brainboxes Ethernet IO Module and sends the ASCII command to get the device name

Brainboxes.IO PHP API Example code

<h1>Brainboxes.IO PHP API Example</h1>
<?php
/*
This file is part of the javascript example/library code for communication with with 
Brainboxes Ethernet-attached data acquisition and control products, and is 
provided by Brainboxes Limited.  Examples in other programming languages are 
also available.
Visit http://www.brainboxes.com to see our range of Brainboxes Ethernet-
attached data acquisition and control products, and to check for updates to
this code package.

This is free and unencumbered software released into the public domain.
 */
include("../Brainboxes.IO/EDDevice.class.php");
use Brainboxes\IO\EDDevice as EDDevice;

$deviceIP = "192.168.0.109";
//$01M means get device name
$command = "$01M";
$response = null;
?>
<p>Attempting to connect to Brainboxes ED device at: <?php echo $deviceIP;?></p>
<?php 

	$device = new EDDevice($deviceIP);
	$device->connect();
	$response = $device->sendCommand($command);
?>

<p>Message sent: <?php echo $command; ?></p>
<p>Response: <?php echo $response; ?></p>

Reference

For a full list of ASCII protocol commands which can be sent to the device see:Brainboxes Remote IO ASCII protocol reference