Page 2 of 2

I receive data, but it doesn't make sense - SOLVED

Posted: Wed Jun 13, 2007 11:59 pm
by lfrancois
<blockquote id="quote"><font size="1" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote"><i>Originally posted by b_weijenberg</i>
<br />Ludo,

You have to put the receiver in Variable Length mode (command hex F02C)
<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">

done

<blockquote id="quote"><font size="1" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">
The first byte you receive will contain the message length in bits. For an RFXPower this will be hex 30 (48 decimal)
<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">

done too

<blockquote id="quote"><font size="1" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">
1) Check the number of bits received - should be hex 30,
<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">

$bytesNumber = scalar @bytes;
return 0 if ($bytesNumber != 6);

<blockquote id="quote"><font size="1" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">
2) Check if the 2 address bytes have the correct format: Byte 2 = byte 1 with the complement of the upper nibble (bit 7-4)
<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">

So I guess you are talking about byte 0 and 1, I did this test:

if (($bytes[0] + ($bytes[1] ^ 0x0F)) == 0xFF) {

But I never fill this condition, am I right?

<blockquote id="quote"><font size="1" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">
3) Check the 4 bits parity: This is the complement of:
byte 0 bit 7-4 + byte 0 bit 3-0 + byte 1 bit 7-4 + byte 1 bit 3-0 + byte 2 bit 7-4 + byte 2 bit 3-0 + byte 3 bit 7-4 + byte 3 bit 3-0 + byte 4 bit 7-4 + byte 4 bit 3-0 + byte 5 bit 7-4
<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">

I didn't yet try this one, because I don't success the second one.

<blockquote id="quote"><font size="1" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">
If this check is OK it is 99.999% sure it is an RFXPower or RFXMeter packet
<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">

Not yet, but I am asking me some questions about my communication between my rfxcom and my rfxpower, I think I am going to run a test with RFreceiver.exe from a windows machine, because in parallel I manage fine RFX10, I detect my Oregon Sensors, so maybe the problem is not in the code.

I receive data, but it doesn't make sense - SOLVED

Posted: Thu Jun 14, 2007 12:01 am
by lfrancois
<blockquote id="quote"><font size="1" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote"><i>Originally posted by beanz</i>
<br />Ludo,

I think your perl code is reading parts of messages. What I do is do a read, check the length in the first byte and if I don't have enough data I do another read ... appending the new data to the end. When I have enough I remove those bytes and keep the rest in case they are part of the next message - though actually this may not be the best strategy for staying in sync. You don't seem to be doing this, you seem to be throwing the bits away if you don't have enough data.

-Mark.

<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">

I read bytes one by one, so I use the first byte to know when I need to stop to read. So normally it seems too work, but maybe I made some mistakes

I receive data, but it doesn't make sense - SOLVED

Posted: Thu Jun 14, 2007 10:54 am
by beanz
<blockquote id="quote"><font size="1" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote"><i>Originally posted by lfrancois</i>
<br /><blockquote id="quote"><font size="1" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote"><i>Originally posted by b_weijenberg</i>

2) Check if the 2 address bytes have the correct format: Byte 2 = byte 1 with the complement of the upper nibble (bit 7-4)
<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">

So I guess you are talking about byte 0 and 1, I did this test:

if (($bytes[0] + ($bytes[1] ^ 0x0F)) == 0xFF) {

But I never fill this condition, am I right?
<hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote">

I think your condition is coded incorrectly. For example, consider the bytes 0xf0 and 0xff - they meet condition 2) as originally stated by bert but ... fail the test since 0x1e0 != 0xff.

Try:

if ($bytes[0] == ($bytes[1]^0xf)) {

Regards,
Mark.