View Full Version : 64 bit address to string comparison

07-06-2009, 10:15 PM

I'm getting a 64 bit address sent back from a sensor that I want to compare with the address in string form to confirm it is the one I think it is. I've defined a DAT entry as

Sensor1 byte "E80000016C5DB828", 0

And then in the code I'm trying to do a strcomp(@Sensor1, @addr)

but it's failing because they are two different data types I suspect....

Is there a way to do that or do I have to convert the 64 bit address to a string first? And how's that done...

OR how do I do it with numerical comparison?

Many thanks

I'll keep reading..........


07-06-2009, 10:22 PM
You could just AND them, but I think you'll have to do it in two 32-bit chunks as the prop is 32 bit :) - H


07-06-2009, 10:36 PM
Been a long time since I've done any coding...and it's showing...never was any good at bitwise operations anyway.

If anyone's got the time to demo the sort of code that might work it'd be appreciated.



Mike Green
07-06-2009, 10:53 PM
You're trying to compare a 64 bit value to an equivalent hexadecimal string. It is indeed like trying to compare apples to oranges. You need to get both things in the same form. It's easier to make your DAT information into a 64 bit value like this:

Sensor1 byte "E80000016C5DB828", 0


Sensor1 long $01_00_00_E8, $28_B8_5D_6C

Notice that the order of the bytes in each long is reversed. What I'm assuming here is that the 8 bytes shown in your hexadecimal string come in in the order shown so that "E8" is the 1st byte value. If you work out how the constants I've written are actually stored in memory, you'll see that the order works out correctly.

If you read in the sensor address into another two long array called "Address", you'd compare them like

IF Address[ 0 ] == Sensor1[ 0 ] AND Address[ 1 ] == Sensor1[ 1 ]

07-08-2009, 05:36 PM
Still struggling with this...sorry.

In order to output to the parallax serial terminal the program is

pst.hex(LONG[addr + 4],8)

I've tried any number of things but still can't get a comparison with Mike's suggested two longs array...

If someone could suggest what's going wrong it'd be appreciated. It doesn't help that I'm having to leave this and come back to it every so often and then starting again each time...


Many thanks


07-08-2009, 06:21 PM

phew, now on to doing something with this thing!!!