Getting the address field
Through the following procedure
Calculate the serverAddress as ‘0x1163E’ to get ‘00 08 58 7D’
But this is actually wrong,
What is right should be:00 02 58 7D
static Object getAddress(final long value, final int size) {
if (size < 2 && value < 0x80) {
return (byte) (value << 1 | 1);
}
if (size < 4 && value < 0x4000) {
return (short) ((value & 0x3F80) << 2 | (value & 0x7F) << 1 | 1);
}
if (value < 0x10000000) {
return (int) ((value & 0xFE00000) << 4 | (value & 0x1FC000) << 3
| (value & 0x3F80) << 2 | (value & 0x7F) << 1 | 1);
}
throw new IllegalArgumentException("Invalid address.");
}
Hi,
Hi,
Your address should be 0x563E if you want to get bytes 00 02 58 7D.
You can read more from counting address:
http://www.gurux.fi/dlmsAddress
BR,
Mikko