You were correct, this was an error in the way my hardware was responding. The new build fixes that issue.
I am now however having an issue that keeps happening randomly (but this time simply won't fix itself after many attempts). Bacnet4j sends the packet correctly, and the bacnet device responds, but for some reason bacnet4j won't acknowledge the fact that it received an awk packet. There errors are as following:
Write property:
public static int WriteProperty(InetAddress Address, int port, int instanceID, int propertyID,int objectID, float data) throws Exception {
LocalDevice localDevice = new LocalDevice(1234, "192.168.0.255"); //create new local device
localDevice.initialize(); //initialize the device
byte[] IPRaw = new byte[4]; //allocate mem for IP address
IPRaw=Address.getAddress(); //Convert InetAddress into bte array
RemoteDevice rd = new RemoteDevice(instanceID, new Address(new UnsignedInteger(port), //create a new bacnet drvice with proper Instance ID and IP
new OctetString(new byte[] {IPRaw[0], IPRaw[1], IPRaw[2], IPRaw[3]})), null);
localDevice.addRemoteDevice(rd); //add newly created bacnet device to the localdevice
ObjectIdentifier oid = new ObjectIdentifier(new ObjectType(propertyID),objectID);
rd.setSegmentationSupported(Segmentation.segmentedBoth); //needed to send packet properly
rd.setMaxAPDULengthAccepted(1476); //max length
RemoteObject ro = new RemoteObject(new ObjectIdentifier(new ObjectType(propertyID),objectID)); //create the object based on the right property ID (usually present value), and object ID.
rd.setObject(ro); //add object to remote device
Thread.sleep(1000); //wait for everything to setup properly
localDevice.setPresentValue(rd,oid,new Real(data)); //send data write packet
return 1;
}
Exception in thread "main" com.serotonin.bacnet4j.exception.BACnetTimeoutException: Timeout while waiting for response for id 0
at com.serotonin.bacnet4j.npdu.ip.IpMessageControl.send(IpMessageControl.java:298)
at com.serotonin.bacnet4j.npdu.ip.IpMessageControl.send(IpMessageControl.java:269)
at com.serotonin.bacnet4j.npdu.ip.IpMessageControl.send(IpMessageControl.java:225)
at com.serotonin.bacnet4j.LocalDevice.send(LocalDevice.java:413)
at com.serotonin.bacnet4j.LocalDevice.send(LocalDevice.java:401)
at com.serotonin.bacnet4j.LocalDevice.send(LocalDevice.java:394)
at com.serotonin.bacnet4j.LocalDevice.setProperty(LocalDevice.java:848)
at com.serotonin.bacnet4j.LocalDevice.setPresentValue(LocalDevice.java:852)
at com.serotonin.bacnet4j.test.Schneider.WriteProperty(Schneider.java:160)
at com.serotonin.bacnet4j.test.Schneider.main(Schneider.java:73)
read property:
public static String ReadProperty(InetAddress Address, int port, int instanceID, int propertyID, int objectID ) throws Exception {
LocalDevice localDevice = new LocalDevice(32491, "192.168.0.255"); //create device to send out packets
localDevice.initialize(); //initialize this device
byte[] IPRaw = new byte[4]; //allocate mem for IP adress
IPRaw=Address.getAddress(); //Convert InetAddress into byte array
RemoteDevice rd = new RemoteDevice(instanceID, new Address(new UnsignedInteger(port), //Create a new bacnet device with the proper instance ID and IP
new OctetString(new byte[] {IPRaw[0], IPRaw[1], IPRaw[2], IPRaw[3]})), null);
localDevice.addRemoteDevice(rd); //add the newly created bacnet device to the localdevice created earlier
// ObjectIdentifier oid = new ObjectIdentifier(new ObjectType(propertyID),objectID); //set oid to have the proper property (usually present value), and the right object property on the remote device
rd.setSegmentationSupported(Segmentation.segmentedBoth); //Needed to send the packet properly
rd.setMaxAPDULengthAccepted(1476); //needed to send the packet properly
RemoteObject ro = new RemoteObject(new ObjectIdentifier(new ObjectType(propertyID),objectID)); //create the object based on the right property ID (usually present value), and object ID.
rd.setObject(ro); //add the newly created object to the bacnet device
Thread.sleep(1000); //wait for everything to setup properly
PropertyValues values = localDevice.readPresentValues(rd);
PropertyReferences refs = new PropertyReferences();
// refs.add(rd.getObjectIdentifier(), new PropertyIdentifier(propertyID));
refs.add(rd.getObjectIdentifier(), PropertyIdentifier.all);
PropertyValues pvs = localDevice.readProperties(rd, refs);
ObjectPropertyReference opr = new ObjectPropertyReference(ro.getObjectIdentifier(),new PropertyIdentifier(propertyID));
System.out.println(opr.getPropertyIdentifier().toString());
System.out.println(pvs.getNoErrorCheck(opr));
System.out.println(opr.getPropertyIdentifier().toString());
System.out.println(values.getNoErrorCheck(opr));
String value = values.getString(new ObjectIdentifier(new ObjectType(propertyID),objectID),new PropertyIdentifier(propertyID));
System.out.println(value);
return value;
}
Exception in thread "main" com.serotonin.bacnet4j.exception.BACnetTimeoutException: Timeout while waiting for response for id 0
at com.serotonin.bacnet4j.npdu.ip.IpMessageControl.send(IpMessageControl.java:298)
at com.serotonin.bacnet4j.npdu.ip.IpMessageControl.send(IpMessageControl.java:269)
at com.serotonin.bacnet4j.npdu.ip.IpMessageControl.send(IpMessageControl.java:225)
at com.serotonin.bacnet4j.LocalDevice.send(LocalDevice.java:413)
at com.serotonin.bacnet4j.LocalDevice.send(LocalDevice.java:401)
at com.serotonin.bacnet4j.LocalDevice.send(LocalDevice.java:394)
at com.serotonin.bacnet4j.LocalDevice.readProperties(LocalDevice.java:809)
at com.serotonin.bacnet4j.LocalDevice.readOidPresentValues(LocalDevice.java:843)
at com.serotonin.bacnet4j.LocalDevice.readPresentValues(LocalDevice.java:832)
at com.serotonin.bacnet4j.LocalDevice.readPresentValues(LocalDevice.java:825)
at com.serotonin.bacnet4j.test.Schneider.ReadProperty(Schneider.java:99)
at com.serotonin.bacnet4j.test.Schneider.main(Schneider.java:74)
The captured packets are here:
http://www.filebox.com/hzrynxyfz9zx
Another bacnet client that I have does not have this issue with the hardware I am using.
And help would be greatly appreciated ?
PS. I know that I am writing 3.3 but it is returning 3.0000. Though this should have nothing to do with this issue.