How do I use PHP to communicate with my Remote IO Module?

FAQs

Download
PHP.Brainboxes.IO.zip (6.0 kB)

PHP is a server side and scripting language used primarily on the web. PHP is used in approximately 80% of all websites (for example, facebook.com & wikipedia.org). Brainboxes has provided a Brainboxes.IO PHP API to allow easy integration of Brainboxes Ethernet Remote IO Modules (ED-XXX) into your 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 Remote IO Module and sends the ASCII command to get the device name:

<h1>Brainboxes.IO PHP API Example</h1>
<?php
    /*
    This file is part of the javascript example/library code for communication 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,$port);
	$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

FAQs