No response from Remote Device
-
Hello,
I'm making multiple remote device binded into local device, But I still get error.final byte[] a = {(byte) 0xc0,(byte) 0xa8,0x01,0x65,(byte) 0xba,(byte) 0xc0}; final Address macAddress = new Address(a); final RemoteDevice rd = new RemoteDevice(localDevice, 1235); rd.setAddress(macAddress); final ObjectIdentifier ai1 = new ObjectIdentifier(ObjectType.analogInput, 0); final ObjectIdentifier ai2 = new ObjectIdentifier(ObjectType.analogInput, 1); System.out.println(macAddress); WhoIsRequest whr = new WhoIsRequest(); whr.handle(localDevice, macAddress); ai1.write(new ByteQueue(new byte[] { 0 }), 0); ai2.write(new ByteQueue(new byte[] { 1 }), 1); rd.setDeviceProperty(PropertyIdentifier.objectList, new SequenceOf<>(ai1, ai2)); final UnconfirmedRequestService service = new IAmRequest(ai1, new UnsignedInteger(1024), Segmentation.noSegmentation, new UnsignedInteger(99)); final APDU pdu = new UnconfirmedRequest(service); localDevice.sendGlobalBroadcast(service); final SequenceOf<ObjectIdentifier> objectList = rd.getDeviceProperty(PropertyIdentifier.objectList); RemoteDeviceFuture rdf1 = localDevice.getRemoteDevice(1235); System.out.println(rdf1); RemoteDevice rd1 = rdf1.get(); //error occurs on this line. System.out.println(rd1); RemoteDeviceFuture rdf2 = localDevice.getRemoteDevice(1236); System.out.println(rdf2); RemoteDevice rd2 = rdf2.get(); System.out.println(rd2); final EventNotifListener listener1 = new EventNotifListener(); localDevice.getEventHandler().addListener(listener1); localDevice.sendGlobalBroadcast(whr);
and my error message is this.
BROAD: 192.168.1.255 SUB: 255.255.0.0= Address [networkNumber=0, macAddress=[c0,a8,1,65,ba,c0]] com.serotonin.bacnet4j.LocalDevice$2@7a0a427b 1819 [BACnet4J transport for device 1234] WARN com.serotonin.bacnet4j.service.unconfirmed.IAmRequest - Received IAm from an object that is not a device from Address [networkNumber=0, macAddress=[c0,a8,1,65,ba,c0]] com.serotonin.bacnet4j.exception.BACnetTimeoutException: No response from instanceId 1235
I added some localdevice.send method, but I get this error.
localDevice.send(rd, new WritePropertyRequest(new ObjectIdentifier(ObjectType.analogInput, 0),PropertyIdentifier.presentValue, null, new UnsignedInteger(2), new UnsignedInteger(8))) .get();
1986 [BACnet4J transport for device 1234] ERROR com.serotonin.bacnet4j.transport.DefaultTransport - Error during send: OutgoingConfirmed [maxAPDULengthAccepted=-1, segmentationSupported=null, service=Encodable(com.serotonin.bacnet4j.service.confirmed.WritePropertyRequest), consumer=com.serotonin.bacnet4j.transport.ServiceFutureImpl@7b49796f, address=Address [networkNumber=0, macAddress=[c0,a8,1,65,ba,c0]], linkService=null] 1986 [BACnet4J transport for device 1234] ERROR com.serotonin.bacnet4j.transport.DefaultTransport - Original send stack java.lang.Exception at com.serotonin.bacnet4j.transport.DefaultTransport.send(DefaultTransport.java:290) at com.serotonin.bacnet4j.transport.DefaultTransport.send(DefaultTransport.java:280) at com.serotonin.bacnet4j.LocalDevice.send(LocalDevice.java:983) at bacnetTest.DispFrame.sendRemoteRequest(DispFrame.java:390) at bacnetTest.DispFrame$2.actionPerformed(DispFrame.java:144) at javax.swing.AbstractButton.fireActionPerformed(Unknown Source) at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source) at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source) at javax.swing.DefaultButtonModel.setPressed(Unknown Source) at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source) at java.awt.Component.processMouseEvent(Unknown Source) at javax.swing.JComponent.processMouseEvent(Unknown Source) at java.awt.Component.processEvent(Unknown Source) at java.awt.Container.processEvent(Unknown Source) at java.awt.Component.dispatchEventImpl(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Window.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.EventQueue.dispatchEventImpl(Unknown Source) at java.awt.EventQueue.access$500(Unknown Source) at java.awt.EventQueue$3.run(Unknown Source) at java.awt.EventQueue$3.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source) at java.awt.EventQueue$4.run(Unknown Source) at java.awt.EventQueue$4.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source) at java.awt.EventQueue.dispatchEvent(Unknown Source) at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.run(Unknown Source)
I want some help, or please give me advice.
thank you. :) -
Hi YEJI, welcome to the forum.
I'm making multiple remote device binded into local device, But I still get error.
Why? You shouldn't create RemoteDevice objects. They will be created in the LocalDevice through the course of regular discovery in response to receiving IAm messages. The test you got that idea from, RemoteDeviceTest.java is testing something other than actual device communication and is likely somewhat outdated for the library anyway.
You are asking why your are getting timeouts locating devices that don't really exist on your network. That is why YABE couldn't find them either. A "remote" device only makes sense in the context of a "local" device (any other device is remote to it), and they should only be created by the local device in any real application.
-
Hello, Thank you for answer.
so If I want to make a lot of instance number(devices), What should I do?
Should I get lot of IPs and make transports?
Is it possible to make one physical device and make multiple IP transports?final IpNetwork network = new IpNetworkBuilder().withBroadcast("192.168.1.101", 16).withPort(47808).withLocalBindAddress("192.168.1.255").build(); final IpNetwork network = new IpNetworkBuilder().withBroadcast("192.168.1.102", 16).withPort(47808).withLocalBindAddress("192.168.1.255").build(); transport = new DefaultTransport(network); transport2 = new DefaultTransport(network2); localDevice = new LocalDevice(1234, transport); localDevice2 = new LocalDevice(1235, transport2); localDevice.initialize(); localDevice2.initialize();
-
Currently, yes, that would be one way to do it (although your withBroadcast arguments seem questionable). You would have to have multiple network interfaces or multiple addresses on an interface. Another way to do it would be to implement your own transport based on routing between the networks that you wished to bridge. It looks like Terry may have fixed a bug concerning reusing the IP address and port recently, so perhaps you can pull and see if that will help you do what you are trying, https://github.com/infiniteautomation/BACnet4J/commit/9cb0864ef25be802b0b2e84ebd7013018bfafac3
Broadcast addresses are all ones in the address bits on a subnet usually, unless there is some unique routing going on there. I.E. 192.168.255.255/16 or 192.168.1.255/24