64 bit address to string comparison
adri
Posts: 34
Hi
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..........
Adri
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..........
Adri
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
If anyone's got the time to demo the sort of code that might work it'd be appreciated.
TIA
adri
Sensor1 byte "E80000016C5DB828", 0
becomes
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[noparse][[/noparse] 0 ] == Sensor1[noparse][[/noparse] 0 ] AND Address[noparse][[/noparse] 1 ] == Sensor1[noparse][[/noparse] 1 ]
In order to output to the parallax serial terminal the program is
pst.hex(LONG[noparse][[/noparse]addr + 4],8)
pst.hex(LONG[noparse][[/noparse]addr],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...
Ugh!
Many thanks
Nick
phew, now on to doing something with this thing!!!