help with byte Array
Anubisbot
Posts: 112
Hi,
i try to figure out how i get
from a byte array 4 bytes what present a half of a 64 bit xbee adress into my long variable ?
Since my longs are also a array, i can not figure it out
XBAdress[noparse][[/noparse]0]. byte[noparse][[/noparse]0] := $00
XBAdress[noparse][[/noparse]0]. byte := $13
XBAdress[noparse][[/noparse]0]. byte := $A2
XBAdress[noparse][[/noparse]0]. byte := $00
Thas for the first half of the 64 bit adi, and the second should go into the XBAdress
Post Edited (Anubisbot) : 4/29/2009 11:04:37 PM GMT
i try to figure out how i get
from a byte array 4 bytes what present a half of a 64 bit xbee adress into my long variable ?
Since my longs are also a array, i can not figure it out
XBAdress[noparse][[/noparse]0]. byte[noparse][[/noparse]0] := $00
XBAdress[noparse][[/noparse]0]. byte := $13
XBAdress[noparse][[/noparse]0]. byte := $A2
XBAdress[noparse][[/noparse]0]. byte := $00
Thas for the first half of the 64 bit adi, and the second should go into the XBAdress
Post Edited (Anubisbot) : 4/29/2009 11:04:37 PM GMT
Comments
You could give each 32 bit part of the 64 bit address as a long constant like:
XBAddress[noparse][[/noparse] 0 ] := $00A21300
XBAddress[noparse][[/noparse] 1 ] := <something else>
or you could give them as individual bytes like:
XBAddress.byte[noparse][[/noparse] 0 ] := $00
XBAddress.byte[noparse][[/noparse] 1 ] := $13
XBAddress.byte[noparse][[/noparse] 2 ] := $A2
XBAddress.byte[noparse][[/noparse] 3 ] := $00
XBAddress.byte[noparse][[/noparse] 4 ] := <something else>
XBAddress.byte[noparse][[/noparse] 5 ] := <something else>
... and so on ...
so when i get that right, i dont write it like this when i want to store more that 1 address :
instead i need to calculate the start position of the long, and that would look like this i guess:
This should bring me to long nr 3 in my long array to store addresses.