Please Note This forum exists for community support for the Mango product family and the Radix IoT Platform. Although Radix IoT employees participate in this forum from time to time, there is no guarantee of a response to anything posted here, nor can Radix IoT, LLC guarantee the accuracy of any information expressed or conveyed. Specific project questions from customers with active support contracts are asked to send requests to support@radixiot.com.
Errors when attempting to read
-
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/hzrynxyfz9zxAnother 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.
-
If the app had actually received the response and for some reason misinterpreted it, you would see an exception like, "No waiting recipient for message: peer=...". Were there other messages, or just the timeouts?
-
Just the timeout. If you look at the packets in wireshark, bacnet4j sends the request 3 times and gets a reply back each time. For some reason it is refusing to read the awk packet. The packet bacnet4j is sending is identical to the one bacbeat sends out. However, bacbeat recognizes the awk packet and displays the value, while bacnet4j does not, so it shouldn't be a hardware problem.
The code running those 2 methods are here:
InetAddress deviceIP = InetAddress.getByName("192.168.16.3"); WriteProperty(deviceIP,47808,3331779,2,1,(float)3.3); String result = ReadProperty(deviceIP,47808,3331779,2,1);
-
Do you know how to add System.out statements to the code and build the jar? It seems as if BACnet4J isn't getting the response at all, since any other possibility should cause an exception to be thrown.
If so, add the following line in IpMessageControl at line 424:
try { socket.receive(p); System.out.println("Received a packet!"); // ADD THIS LINE incomingExecutorService.execute(new IncomingMessageExecutor(p)); p.setData(buffer); }
If the packet is being received, then we can go down the BACnet4J road. If not, there must be something else preventing its proper routing.
-
Added the line, and complied.
When running the line, nothing changed (did not display the "packet received message").
The question is however, why is bacbeat able to receive the packet while bacnet4j is not?
I have a few computers here, do you think I should try executing on another one?
-
The question is however, why is bacbeat able to receive the packet while bacnet4j is not?
running as root vs. usual user?
windows firewall?
port in use by other program? -
@craig said:
The question is however, why is bacbeat able to receive the packet while bacnet4j is not?
running as root vs. usual user?
windows firewall?
port in use by other program?- Running as administrator (windows)
-I'll shut off windows firewall and test that theory in a bit, though it was working last week with windows firewall on. - Happens directly after a fresh bootup. Before, when my program didn't exit properly I had to restart it to get it working again (thus the port was in use). On a fresh bootup however, I have doubts the bacnet port (47808) would be in use. I will however try to test for this.
Thanks for the tips :)
- Running as administrator (windows)
-
I'm also having the same error "Timeout while waiting for response for id 0 " as Randy.
I'm getting it with the following code: localDevice.getExtendedDeviceInformation(remoteDevice);
I looked at the wireshark and Bacnet4J is sending the readProperty request for property protocol-services-supported 3 times
and my device is answering everytime. I can see the data sent back but Bacnet4J can't seem to catch it.What is weird is that my code was working 1 year ago and tried it again this week and I get this.
Anyone found the reason for that problem or a workaround?
I suspect that something changed in our bacnet network but I don't know what to look for...
thanks!
Eric
-
@Randy hello,Randi, How did you solve the problem of InvocationTargetException,now I am also facing the same problem
-
@BigKING please create a new thread and reference this one. This one was solved over twelve years ago!
Fox