• Recent
    • Tags
    • Popular
    • Register
    • Login

    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

    Quick-Test Programm

    BACnet4J general discussion
    2
    7
    4.9k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • D
      dufy
      last edited by

      Hello,

      i'am new to bacnet4j. I try since a few day to run the little test-programm but with no suggest.

      My hardware is a wago 750-830 bacnet-controller. when i run the programm with the following line i got an error like this.

      the test-programm

      /*
      Copyright (C) 2006-2009 Serotonin Software Technologies Inc.
      @author Matthew Lohbihler
      */
      package testing;
      import com.serotonin.bacnet4j.LocalDevice;
      import com.serotonin.bacnet4j.RemoteDevice;
      import com.serotonin.bacnet4j.service.unconfirmed.WhoIsRequest;
      import com.serotonin.bacnet4j.type.constructed.ObjectPropertyReference;
      import com.serotonin.bacnet4j.type.enumerated.ObjectType;
      import com.serotonin.bacnet4j.type.enumerated.PropertyIdentifier;
      import com.serotonin.bacnet4j.type.primitive.ObjectIdentifier;
      import com.serotonin.bacnet4j.util.PropertyReferences;
      import com.serotonin.bacnet4j.util.PropertyValues;

      /**

      • @author Matthew Lohbihler
        */
        public class QuickTest {
        public static void main(String[] args) throws Exception {
        LocalDevice localDevice = new LocalDevice(1, "255.255.255.255","localhost");
        try {
        localDevice.initialize();
        localDevice.sendBroadcast(47808, new WhoIsRequest(null,null));

             Thread.sleep(5000);
             
             RemoteDevice d = localDevice.getRemoteDevices().get(0);
             
             ObjectIdentifier oid = new ObjectIdentifier(ObjectType.multiStateOutput, 0);
             for (int i=8; i&lt9; i++) {
                 PropertyReferences refs = new PropertyReferences();
                 refs.add(oid, new PropertyIdentifier(i));
             
                 PropertyValues pvs = localDevice.readProperties(d, refs);
                 for (ObjectPropertyReference opr : pvs)
                     System.out.println(""+ i +": "+ pvs.getNoErrorCheck(opr));
             }
             Thread.sleep(2000);
         }
         finally {
             localDevice.terminate();
         }
        

        }
        }


      LocalDevice localDevice = new LocalDevice(1, "255.255.255.255");

      Exception in thread "main" java.net.BindException: Address already in use: Cannot bind
      at java.net.PlainDatagramSocketImpl.bind0(Native Method)
      at java.net.PlainDatagramSocketImpl.bind(Unknown Source)
      at java.net.DatagramSocket.bind(Unknown Source)
      at java.net.DatagramSocket.<init>(Unknown Source)
      at java.net.DatagramSocket.<init>(Unknown Source)
      at com.serotonin.bacnet4j.npdu.ip.IpMessageControl.initialize(IpMessageControl.java:147)
      at com.serotonin.bacnet4j.LocalDevice.initialize(LocalDevice.java:220)
      at testing.QuickTest.main(QuickTest.java:23)

      when i run the code with the following line:

      LocalDevice localDevice = new LocalDevice(1, "255.255.255.255","localhost");

      i got the following error:

      Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
      at java.util.concurrent.CopyOnWriteArrayList.get(Unknown Source)
      at testing.QuickTest.main(QuickTest.java:28)

      But in whireshark i see, that the bacnet-controller is sending something, everytime i start the programm.

      (i work on windows xp) what do i wrong?

      No. Time Source Destination Protocol Info
      10 3.005765 192.168.83.88 192.168.83.255 BACnet-APDU Unconfirmed-Request : i-Am

      Frame 10 (66 bytes on wire, 66 bytes captured)
      Arrival Time: Mar 1, 2010 17:44:20.476889000
      [Time delta from previous captured frame: 0.011106000 seconds]
      [Time delta from previous displayed frame: 3.005765000 seconds]
      [Time since reference or first frame: 3.005765000 seconds]
      Frame Number: 10
      Frame Length: 66 bytes
      Capture Length: 66 bytes
      [Frame is marked: True]
      [Protocols in frame: eth:ip:udp:bvlc:bacnet:bacapp:data]

      Ethernet II, Src: WagoKont_03:82:c6 (00:30:de:03:82:c6), Dst: Broadcast (ff:ff:ff:ff:ff:ff)
      Destination: Broadcast (ff:ff:ff:ff:ff:ff)
      Address: Broadcast (ff:ff:ff:ff:ff:ff)
      .... ...1 .... .... .... .... = IG bit: Group address (multicast/broadcast)
      .... ..1. .... .... .... .... = LG bit: Locally administered address (this is NOT the factory default)
      Source: WagoKont_03:82:c6 (00:30:de:03:82:c6)
      Address: WagoKont_03:82:c6 (00:30:de:03:82:c6)
      .... ...0 .... .... .... .... = IG bit: Individual address (unicast)
      .... ..0. .... .... .... .... = LG bit: Globally unique address (factory default)
      Type: IP (0x0800)
      Internet Protocol, Src: 192.168.83.88 (192.168.83.88), Dst: 192.168.83.255 (192.168.83.255)
      Version: 4
      Header length: 20 bytes
      Differentiated Services Field: 0x00 (DSCP 0x00: Default; ECN: 0x00)
      0000 00.. = Differentiated Services Codepoint: Default (0x00)
      .... ..0. = ECN-Capable Transport (ECT): 0
      .... ...0 = ECN-CE: 0
      Total Length: 52
      Identification: 0x3f57 (16215)
      Flags: 0x00
      0.. = Reserved bit: Not Set
      .0. = Don't fragment: Not Set
      ..0 = More fragments: Not Set
      Fragment offset: 0
      Time to live: 64
      Protocol: UDP (0x11)
      Header checksum: 0x12ba [correct]
      [Good: True]
      [Bad : False]
      Source: 192.168.83.88 (192.168.83.88)
      Destination: 192.168.83.255 (192.168.83.255)
      User Datagram Protocol, Src Port: bacnet (47808), Dst Port: bacnet (47808)
      Source port: bacnet (47808)
      Destination port: bacnet (47808)
      Length: 32
      Checksum: 0x8bdb [validation disabled]
      [Good Checksum: False]
      [Bad Checksum: False]
      BACnet Virtual Link Control
      Type: BACnet/IP (Annex J) (0x81)
      Function: Original-Broadcast-NPDU (0x0b)
      BVLC-Length: 4 of 24 bytes BACnet packet length
      Building Automation and Control Network NPDU
      Version: 0x01 (ASHRAE 135-1995)
      Control: 0x20
      0... .... = NSDU contains: BACnet APDU, message type field absent.
      .0.. .... = Reserved: Shall be zero and is zero.
      ..1. .... = Destination Specifier: DNET, DLEN and Hop Count present. If DLEN=0: broadcast, dest. address field absent.
      ...0 .... = Reserved: Shall be zero and is zero.
      .... 0... = Source specifier: SNET, SLEN and SADR absent
      .... .0.. = Expecting Reply: Other than a BACnet-Confirmed-Request-PDU, segment of BACnet-ComplexACK-PDU or network layer message expecting a reply present.
      .... ..0. = Priority: Not a Life Safety or Critical Equipment message.
      .... ...0 = Priority: Normal message
      Destination Network Address: 65535
      Destination MAC Layer Address Length: 0 indicates Broadcast on Destination Network
      Hop Count: 255
      Building Automation and Control Network APDU
      0001 .... = APDU Type: Unconfirmed-Request (1)
      Unconfirmed Service Choice: i-Am (0)
      ObjectIdentifier: device object, 230086
      Application Tag: BACnetObjectIdentifier, Length/Value/Type: 4
      .... 0... = Tag Class: Application Tag
      1100 .... = Application Tag Number: BACnetObjectIdentifier (12)
      Length Value Type: 4
      0000 0010 00.. .... .... .... .... .... = Object Type: device object (8)
      .... .... ..00 0011 1000 0010 1100 0110 = Instance Number: 230086
      Maximum ADPU Length Accepted: (Unsigned) 480
      Application Tag: Unsigned Integer, Length/Value/Type: 2
      .... 0... = Tag Class: Application Tag
      0010 .... = Application Tag Number: Unsigned Integer (2)
      Length Value Type: 2
      Segmentation Supported: segmented-both
      Application Tag: Enumerated, Length/Value/Type: 1
      .... 0... = Tag Class: Application Tag
      1001 .... = Application Tag Number: Enumerated (9)
      Length Value Type: 1
      Vendor ID: WAGO Kontakttechnik GmbH & Co. KG (222)
      Application Tag: Unsigned Integer, Length/Value/Type: 1
      .... 0... = Tag Class: Application Tag
      0010 .... = Application Tag Number: Unsigned Integer (2)
      Length Value Type: 1
      Vendor Identifier: WAGO Kontakttechnik GmbH & Co. KG (222)

      1 Reply Last reply Reply Quote 0
      • M
        mlohbihler
        last edited by

        You are getting the first error (cannot bind) because the port you are trying to bind to (0xBAC0 by default) is already in use. This is probably because a previous test that you ran is still running and using the port. Make sure all test programs are terminated before running again.

        The second error is because of this line (line 28, as the stack trace says):

        RemoteDevice d = localDevice.getRemoteDevices().get(0); 
        

        You are asking for element 0, which apparently doesn't exist.

        Best regards,
        Matthew

        1 Reply Last reply Reply Quote 0
        • D
          dufy
          last edited by

          Hello,

          now i have deinstall the wago-bacnet driver and start the programm after a new boot. i think it works. No errors.
          Now i get this output:

          8: errorClass=Object, errorCode=Unknown object

          what does it mean exactly?

          thank for help:

          1 Reply Last reply Reply Quote 0
          • M
            mlohbihler
            last edited by

            It looks like the oid that you specified was not found. Are you sure you have a multistate output with an id of 0? You can request an object list to find out.

            Also, your code would read a bit more easily of written like this:

                        ObjectIdentifier oid = new ObjectIdentifier(ObjectType.multiStateOutput, 0);
                        PropertyReferences refs = new PropertyReferences();
                        refs.add(oid, PropertyIdentifier.all);
                            
                        PropertyValues pvs = localDevice.readProperties(d, refs);
                        for (ObjectPropertyReference opr : pvs)
                            System.out.println(""+ opr.getPropertyIdentifier() +": "+ pvs.getNoErrorCheck(opr));
            
            

            Best regards,
            Matthew

            1 Reply Last reply Reply Quote 0
            • D
              dufy
              last edited by

              Hello,

              now with this code i get the following response:

              
              ObjectIdentifier oid = new ObjectIdentifier(ObjectType.multiStateValue, 0);
                          for (int i=1; i<2; i++) {
                              PropertyReferences refs = new PropertyReferences();
                              refs.add(oid, new PropertyIdentifier(79));
                          
                              PropertyValues pvs = localDevice.readProperties(d, refs);
                              for (ObjectPropertyReference opr : pvs){
                                  System.out.println(""+ i +": "+ pvs.getNoErrorCheck(opr));
                              }
                          }
              
              
              
              1: Multi-state Value
              
              

              The objectidentifier was wrong.

              But with this code

              
                ObjectIdentifier oid = new ObjectIdentifier(ObjectType.multiStateValue, 0);
                          for (int i=1; i<2; i++) {
                              PropertyReferences refs = new PropertyReferences();
                              refs.add(oid, PropertyIdentifier.all);
                          
                              PropertyValues pvs = localDevice.readProperties(d, refs);
                              for (ObjectPropertyReference opr : pvs){
                                  System.out.println(opr.getPropertyIdentifier() +" "+ i +": "+ pvs.getNoErrorCheck(opr));
                              }
                          }
              
              

              i got this error message:

              
              All 1: errorClass=Property, errorCode=Unknown property
              
              

              How can i read now the object-properties from the multi-state-value?

              Thanks for help

              1 Reply Last reply Reply Quote 0
              • M
                mlohbihler
                last edited by

                I'm not sure what this test program was intended for, but it has revealed an odd condition. The property identifiers "all", "required" and "optional" are special in that they refer to multiple properties rather than one. As such, a ReadProperty request cannot be used to retrieve them since the response can only contain a single property.

                But, the LocalDevice.readProperties method detects when a single property identifier was provided, and uses a ReadProperty request for efficiency. I will enhance the method to detect these properties. In the meantime, you can explicitly use a ReadPropertyMultiple request to retrieve "all" object properties.

                Best regards,
                Matthew

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post