• Recent
    • Tags
    • Popular
    • Register
    • Login
    1. Home
    2. davyv

    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.

    Radix IoT Website Mango 3 Documentation Website Mango 4 Documentation Website Mango 5 Documentation Website
    D
    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 1
    • Best 0
    • Controversial 0
    • Groups 0

    davyv

    @davyv

    0
    Reputation
    388
    Profile views
    1
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    davyv Unfollow Follow

    Latest posts made by davyv

    • Unable to find router to network

      I'm trying to connect to a BACNet device. The code I wrote for this looks somewhat like:

      public static void main(String[] args) throws ServiceException {
      
              Integer deviceId = 1234;
              String port = 0xBAC0, localBindAddress = "192.168.0.145";
      
              IpNetworkBuilder builder = new IpNetworkBuilder();
              builder.port(Integer.decode(port));
              builder.localBindAddress(localBindAddress);
      
              IpNetwork network = builder.build();
              LocalDevice localDevice = new LocalDevice(deviceId, new DefaultTransport(network));
              try {
                  localDevice.initialize();
              } catch (Exception e) {
                  throw new ServiceException("Unable to initialize localDevice", e);
              }
      
              localDevice.getEventHandler().addListener(new DeviceEventAdapter() {
                  @Override
                  public void iAmReceived(RemoteDevice remoteDevice) {
                      logger.debug("iAm Received from device: {}, NetworkNumber: {}",
                              remoteDevice.getInstanceNumber(),
                              remoteDevice.getAddress().getNetworkNumber()
                      );
      
                      Runnable task = () -> {
                          try {
                              DiscoveryUtils.getExtendedDeviceInformation(localDevice, remoteDevice);
                              SequenceOf<ObjectIdentifier> oids = RequestUtils.getObjectList(localDevice, remoteDevice);
      
                              for (ObjectIdentifier oid : oids) {
                                  String name = ((CharacterString) RequestUtils.getProperty(localDevice, remoteDevice, oid,
                                          PropertyIdentifier.objectName)).getValue();
                                  logger.info("Found object oid={}, name={} in device {}",
                                          oid,
                                          name,
                                          remoteDevice.getInstanceNumber()
                                  );
                              }
      
                              while(true) {
                                  for (ObjectIdentifier oid : oids) {
                                      Encodable value = RequestUtils.getProperty(
                                              localDevice,
                                              remoteDevice,
                                              oid,
                                              PropertyIdentifier.presentValue
                                      );
                                      logger.info("{}={}", oid, value);
                                  }
                                  try {
                                      Thread.sleep(5_000L);
                                  } catch (InterruptedException e) {
                                  }
                              }
                          } catch (BACnetException e) {
                              logger.error("Error getting values from remoteDevice", e);
                          }
                      };
                      new Thread(task).start();
                  }
              });
      
              localDevice.sendGlobalBroadcast(new WhoIsRequest());
          }
      

      The logging shows the following devices:
      iAm Received from device: 400, NetworkNumber: 0
      iAm Received from device: 401, NetworkNumber: 17436
      iAm Received from device: 402, NetworkNumber: 17436
      iAm Received from device: 404, NetworkNumber: 17436
      iAm Received from device: 500, NetworkNumber: 17436
      iAm Received from device: 501, NetworkNumber: 17436
      iAm Received from device: 502, NetworkNumber: 17436
      iAm Received from device: 0, NetworkNumber: 0
      iAm Received from device: 141, NetworkNumber: 0
      iAm Received from device: 200, NetworkNumber: 0
      iAm Received from device: 201, NetworkNumber: 16924
      iAm Received from device: 202, NetworkNumber: 16924

      When connection with an explorer I see that the 17436 network is behind the 400 device and the 16924 network behind the 200 device.

      I get the following errors when running this code.

      • com.serotonin.bacnet4j.exception.BACnetTimeoutException: Unable to find router to network 17436
      • java.lang.RuntimeException: Invalid arguments: router address not provided for remote recipient Address [networkNumber=17436, macAddress=[1c,44,91,1,0,0]]

      I bind the localDevice to to the BAC0 port on a specific ip adress on the machine this code is running on. The machine has 2 interfaces and the default gateway points to a machine on the other interface.

      I tried using port BAC1, however if I do that, I don't see the IAmReceived messages anymore. So the polling task will not start.

      Has anyone an idea what I'm doing wrong and how I can connect to that (foreign?) device?

      posted in BACnet4J general discussion
      D
      davyv