Jump to content

Controlling a GPIO box via PHP


animinimo

Recommended Posts

Hi there,

 

I'am trying to control a GPIO box via telnet commands over the internet. The hardware box came with a php script to read the outputs and set the inputs, this is only working for the outputs. I broke the script down to just a simple connect to the box with fsockopen function and now I am trying to send a hex message to it. I have a list of hex messages to set the input states. Still it is not working.

 

The box itself has an windows application wich allows me to set all the parameters of it, so I know it is working properly with this ip and port.

 

My php knowledge is fair, but I cant seem to figure out how to send the hexadecimal message...Probably I am doing something dumb or silly...

 

If someone could take a peek at my script, that would be great.

 

Thanks in advance!

 

This is the script I use to connect to the box. I tried a couple different ways to create my hex message, so that's the command and tryout variables you see. The tryout variable you see typed in here is the hex code I want to send to the unit.

 

$fp = fsockopen( "192.168.147.86", 23, $errno,$errdesc)
  or die("Connection to PP failed");

    $command = Chr(255);
    $command .= Chr(250);
    $command .= Chr(44);
    $command .= Chr(50);
    $command .= Chr(0);
    $command .= Chr(255);
    $command .= Chr(240);
    
    $origineel = '';
    
    $tryout = FFFA2C3440FFF0;

fputs($fp, $tryout);

echo $errno.$errdesc.'<br/>';
echo $tryout;

fclose($fp);

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.