From: Joel D. <jr...@io...> - 2006-08-30 15:09:13
|
Thorsten, it looks to me that that read_counter will either take an argument that specifies which page to read, or else it defaults to reading page 15. It starts by setting the variable CounterPage to the first argument (if it's there) or else undefined. (do a google search on 'perl shift') I don't understand why the code sets CounterPage to 3 if there was no argument and then increment it by 12, as that would seem to require that you pass in an argument of 2 or 3 to get page 14 or 15. You may have to check the spec on the part to see just how the 2 pages are addressed. Hope this helps some. Joel --=20 Joel Davidson Austin, TX On Wed, 30 Aug 2006, it would appear that Thorsten Weiss wrote: > Me again, > i foud out that the /page14/ and /page.15/ =FF=FFs counters are associa= ted > with the external /counters.A/ and /counters.B/ triggers. > > but how i can tell mh to read page14 and page15?? > The following is the original script in devices.pm but iam a perl noob.= .. > may anybody help?? > > */sub read_counter { > my $this =3D shift; > my $CounterPage =3D shift; > > $CounterPage =3D 3 if !defined $CounterPage; > $CounterPage +=3D 12; > > # access the device > if ( $this->select() ) { > my $c =3D $this->{'connection'}; > return undef if !$c->connected(); > > # create a block to send that reads the counter > my $send; > > # read memory and counter command > $send .=3D "\xA5"; > > # address of last data byte before counter > my $address =3D ($CounterPage << 5) + 31; # (1.02) > $send .=3D chr($address & 0xFF); > $send .=3D chr($address >> 8); > > my $crc =3D $c->docrc16( 0, $send ); > # now add the read bytes for data byte,counter,zero bits, crc16 > $send .=3D ( "\xFF" x 11 ); > > # now send the block > my $result =3D $c->owBlock( $send ); > if ( $result ) { > # perform the CRC16 on the last 11 bytes of packet > $crc =3D $c->docrc16( $crc, substr( $result, length( $send ) - 11 ) ); > > # verify CRC16 is correct > if ($crc =3D=3D 0xB001) { > # extract the counter value > return unpack( "V", substr( $result, 4, 4 ) ); > } > } > } > > # return the result flag rt > return undef; > } /* > > Thanks. > > Thorsten Weiss schrieb: > >> Hello again, >> The Decvice has two seperate counters >> i tried to read the every counter seperately but i dont know how to d= o >> this.... >> >> In the example codes only one counter read. >> >> Couldt anybody tell me how to read tthe counters seperately?? >> >> >> >> >> regards, >> >> Thorsten. >> |