Problem with getting object-list from device
-
I was running into an issue with getting the object-list from a device.
The device would return an APDU error: 5, error class: resources, error code: other when attempting to get the object list.
When using another program to obtain the object list, it would get the same error and then send the request again successfully.
What I discovered is in the LocalDevice file, there were two exceptions that were handled - the AbortAPDUException error and the ErrorAPDUException eror. The AbortAPDUException performs this retry with propertyArrayIndex set, while the ErrorAPDUException did not. The error I was getting from the device was being processed by the ErrorAPDUException routine (if it would have gone to the AbortAPDUException routine I don't think I would have had the problem).
I copied the retry code into the ErrorAPDUException routine (from the AbortAPDUException routine) and added the code to catch the particular error and it now will get the object-list. Since I am just getting into the code I wanted to put this here in case someone else runs into the same problem but will leave the more intensive troubleshooting/testing to the people who know the code much better.
catch (ErrorAPDUException e) { if (e.getBACnetError().equals(ErrorClass.property, ErrorCode.unknownProperty)) return null; if (e.getBACnetError().equals(ErrorClass.resources, ErrorCode.other)){ if (ObjectProperties.getPropertyTypeDefinition(oid.getObjectType(), pid).isSequence()) { // ... then try getting it by sending requests for indices. Find out how many there are. int len = ((UnsignedInteger) sendReadPropertyAllowNull(d, oid, pid, new UnsignedInteger(0))) .intValue(); // Create a list of individual property references. PropertyReferences refs = new PropertyReferences(); for (int i = 1; i <= len; i++) refs.add(oid, new PropertyReference(pid, new UnsignedInteger(i))); // Send the request. Use the method that automatically partitions the request. PropertyValues pvs = readProperties(d, refs); // We know that the original request property was a sequence, so create one to store the result. SequenceOf<Encodable> list = new SequenceOf<Encodable>(); for (int i = 1; i <= len; i++) list.add(pvs.getNoErrorCheck(oid, new PropertyReference(pid, new UnsignedInteger(i)))); // And there you go. return list; } } throw e; }
-
Thanks! I was just pulling my hair out on a similar problem.