Custom Logging / Data Extraction

Do you have a question on how to do something.
Ask in here.
Post Reply
soyrex
Posts: 24
Joined: Sun Aug 24, 2014 6:38 am

Custom Logging / Data Extraction

Post by soyrex »

Is there a way i can get access to the state of my relays and the values of my probes? Ie: if i wanted to build a web interface to display these? Ideally i would like a way that i can connect to the RA over a socket on my internal LAN to gather this data.. is this possible with my WIFI expansion?
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Custom Logging / Data Extraction

Post by rimai »

Roberto.
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Re: Custom Logging / Data Extraction

Post by lnevo »

I've been pulling the stats from my ra every minute for a long time to feed a web page. I'm doing this now with mrtg :)

http://www.easte.net/mrtg
soyrex
Posts: 24
Joined: Sun Aug 24, 2014 6:38 am

Re: Custom Logging / Data Extraction

Post by soyrex »

Roberto: Thanks. very helpful.

With the relay data in the XML output... how is the relay status encoded? (do you have docs anywhere or should I dig through the wifi cpp?).

Lee: nice... novel use of mrtg ;).


Sent from my iPhone using Tapatalk
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: Custom Logging / Data Extraction

Post by rimai »

Relay status is a 8 bit representation of the 8 ports.
So, for example value 8 would be port 4 on, value 5 would be port 1 and 3 on.
Roberto.
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Re: Custom Logging / Data Extraction

Post by lnevo »

Code: Select all

   function applyMasks($a,$b,$c) {
        $a &= $c;
        $a |= $b;
        return str_pad(decbin($a),8,"0",STR_PAD_LEFT);
    }

    function getBin($a) {
        return str_pad(decbin($a),8,"0",STR_PAD_LEFT);
    }

Code: Select all

  $R=$xml->{'R'};
  $RBIN=getBin($R);
  $RON=$xml->{'RON'};
  $ROFF=$xml->{'ROFF'};
  $RMASK=applyMasks($xml->{'R'},$xml->{'RON'},$xml->{'ROFF'});
  $relay1val=$RBIN[7];
  $relay2val=$RBIN[6];
  $relay3val=$RBIN[5];
  $relay4val=$RBIN[4];
  $relay5val=$RBIN[3];
  $relay6val=$RBIN[2];
  $relay7val=$RBIN[1];
  $relay8val=$RBIN[0];
  $relay1status=$RMASK[7];
  $relay2status=$RMASK[6];
  $relay3status=$RMASK[5];
  $relay4status=$RMASK[4];
  $relay5status=$RMASK[3];
  $relay6status=$RMASK[2];
  $relay7status=$RMASK[1];
  $relay8status=$RMASK[0];
soyrex
Posts: 24
Joined: Sun Aug 24, 2014 6:38 am

Re: Custom Logging / Data Extraction

Post by soyrex »

thanks Roberto! i should have checked back here sooner. I reverse engineered the same answer from the JS code in the u-app. ;)


Sent from my iPhone using Tapatalk
Post Reply