I’ve encountered an issue where the meter can send an incorrect response to the request for first attribute and after that local LN is changed.
Current Behavior:
When parsing the response for the first attribute, the Logical Name of a local object is being updated based on the meter’s response. This can cause problems if the response is incorrect. I’ve observed cases where the LN becomes null or changes to a different one entirely. (I've seen a meter to respond with two PDUs in one TCP message, or meter closed the TCP connection before responding.)
Once this happens, further communication with that object is impossible. The only way to recover is to refresh the association or manually correct the Logical Name.
Example:
In one instance, the meter responded to the current security setup 0.0.43.0.0.255 with the real instance of currently connected security setup: 0.0.43.0.5.255. That changed the local object from 0.0.43.0.0.255 to 0.0.43.0.5.255.
Suggested Solution:
The Logical Name should never be modified based on responses from the meter.
A possible solution would be to maintain an internal copy of the LN that remains immutable and is used for all requests, while a secondary copy could reflect any changes reported by the meter.
Currently it should be handled by this method. But the check can be skipped, if the value is not a byte[]. If it is a null, it will return a null. This check needs some work and also the setLogicalName in each object can be adjusted, to not to change the LN. But the LN needs to be changed when loading the object from xml or i think when reading the associacion list, it uses this method also.
public static String toLogicalName(final Object value) {
if (value instanceof byte[]) {
byte[] buff = (byte[]) value;
if (buff.length == 0) {
buff = new byte[6];
}
if (buff.length == 6) {
return (buff[0] & 0xFF) + "." + (buff[1] & 0xFF) + "." + (buff[2] & 0xFF) + "." + (buff[3] & 0xFF) + "."
+ (buff[4] & 0xFF) + "." + (buff[5] & 0xFF);
}
throw new IllegalArgumentException("Invalid Logical name.");
}
return (String) value;
}