PLCBUS polling

Forum about Domotiga Open Source Home Automation for Linux.

Moderator: RDNZL

User avatar
vdoucet
Starting Member
Starting Member
Posts: 20
Joined: Sat Nov 13, 2010 3:01 pm
Location: Pau, France

Re: PLCBUS polling

Post by vdoucet »

So ... I'm doing my first steps in Gambas and there is probably a "nicer" answer to this issue but I modified line 304 in CPLCBUS.class as follows :

Code: Select all

  '--- check if valid frame ---
  IF RecBuf[0] = STX AND IF RecBuf[1] = &H6 AND IF (RecBuf[8] = ETX OR (RecBuf[0] + RecBuf[1] + RecBuf[2] + RecBuf[3] + RecBuf[4] + RecBuf[5] + RecBuf[6] + RecBuf[7] + RecBuf[8]) = 0) THEN
and I think it solved the issue :P . At least it works with addresses A and B, I didn't check further for the time being.
Ron, if you agree this could be integrated in the next release.

PS. As I said, I'm just starting with Gambas ... I don't quite understand why summing only positive values different from 0 would end up with 0 but ... The tests I did with gambas seems to indicate that RecBuf being defined as a Byte, it is limited to 255. That is to say if the sum ends up as 255 it will remain 255, if it ends up as 258 for example, it will be converted to 2 (&H02 + &H06 + &HFA = 258 (dec) => 2).
Ubuntu 10.10 + Domotiga 0.1.194 + Gambas 2.21
Interface PLCBUS II-T PLC1141 G+ (USB) ; 2x PLCBUS2-R PLC2268HX2 ; 2x PLCBUS II-R PLC2267-H ; 1x PLCBUS II-R PLC2267-K
Oregon Scientific (7x THN132ES, 3x THGN132ES, 1x PCR800)
RFXCOM (USB ; firmware 20)
User avatar
RDNZL
Forum Moderator
Forum Moderator
Posts: 1008
Joined: Sun Sep 24, 2006 1:45 pm
Location: Dordrecht, The Netherlands
Contact:

Re: PLCBUS polling

Post by RDNZL »

I have added your code to revision http://domotiga.nl/changeset/506 but shouldn't it be more like this:

Code: Select all

IF (RecBuf[0] = STX AND IF RecBuf[1] = &H6 AND IF RecBuf[8] = ETX) OR (RecBuf[0] + RecBuf[1] + RecBuf[2] + RecBuf[3] + RecBuf[4] + RecBuf[5] + RecBuf[6] + RecBuf[7] + RecBuf[8] = 0) THEN 
So not having a ( around the RecBuf[8] = ETX

Needs more testing/checking...
Regards, Ron.
Post Reply

Return to “DomotiGa Forum”