• 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

    Not able to do MS/TP communication using BACnet4J

    BACnet4J general discussion
    2
    7
    1.4k
    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.
    • V
      Vihangi
      last edited by Vihangi

      Hi,
      I am trying to perform BACnet Master Slave communication and for that, I have done below things as given in the example.

      For Master Device:

      static void master(final SerialPort serialPort) throws Exception {
      		try (JsscSerialPortInputStream in = new JsscSerialPortInputStream(serialPort);
      				JsscSerialPortOutputStream out = new JsscSerialPortOutputStream(serialPort)) {
      			final MasterNode node = new MasterNode("test", in, out, (byte) 3, 2);
      			node.setMaxInfoFrames(5);
      			node.setUsageTimeout(100);
      			final MstpNetwork network = new MstpNetwork(node, 0);
      			final Transport transport = new DefaultTransport(network);
      			final LocalDevice ld = new LocalDevice(1970, transport);
      			ld.initialize();
      			System.out.println(prefix() + "Initialized");
      
      			for (int i = 0; i < 10; i++) {
      				System.out.println(prefix() + "Discovering");
      				final RemoteDeviceDiscoverer rdd = ld.startRemoteDeviceDiscovery((r) -> {
      					System.out.println(prefix() + "Device: " + r + ", " + r.getName());
      				});
      
      				ThreadUtils.sleep(6000);
      
      				System.out.println("remote device list :: "+rdd.getRemoteDevices());
      				rdd.stop();
      			}
      
      			System.out.println(prefix() + "Terminating");
      			ld.terminate();
      		}
      	}
      

      For Slave Device:

      static void slave(final SerialPort serialPort) throws Exception {
      		try (JsscSerialPortInputStream in = new JsscSerialPortInputStream(serialPort);
      				JsscSerialPortOutputStream out = new JsscSerialPortOutputStream(serialPort)) {
      			final SlaveNode node = new SlaveNode("test", in, out, (byte) 3); //Creating mstp node and place it in ideal state
      			final MstpNetwork network = new MstpNetwork(node, 0);
      			final Transport transport = new DefaultTransport(network);
      			final LocalDevice ld = new LocalDevice(111, transport);
      			ld.initialize();
      
      			ld.startRemoteDeviceDiscovery((r) -> {
      				System.out.println("Get instance number: "+r.getInstanceNumber());
      			});
      
      			ThreadUtils.sleep(100000);
      			System.out.println("getBytesIn :: "+node.getBytesIn());
      			System.out.println("getBytesOut :: "+node.getBytesOut());
      
      			ld.terminate();
      		}
      	}
      

      But still not able to discover the remote devices.
      Is there anything that I miss or any mistake I have done?

      I think it's probably obvious that I am new to BACnet and the BACnet4J library. I would be super grateful for any help!

      Thank you,
      Vihangi

      1 Reply Last reply Reply Quote 0
      • V
        Vihangi
        last edited by

        Hi,

        Anyone there to guide me with this issue...

        Please do the need full as I am stuck with the issue.

        Thanks,
        Vihangi

        1 Reply Last reply Reply Quote 0
        • terrypackerT
          terrypacker
          last edited by

          @Vihangi I see you are using snippets from this code:

          https://github.com/infiniteautomation/BACnet4J/blob/master/src/test/java/com/serotonin/bacnet4j/adhoc/rs485/PortTest.java

          I haven't actually run up that test in some time but I would check your serial port settings to make sure they match on each device you are running the code on.

          1 Reply Last reply Reply Quote 0
          • V
            Vihangi
            last edited by Vihangi

            @terrypacker Thank you so much for the response.

            Yes, I have used that snippet.

            Here is my serial port settings,

            final SerialPort serialPort = new SerialPort("COM12");
            		boolean b = serialPort.openPort();
            		System.out.println("port open? :: "+b);
            		b = serialPort.setParams(SerialPort.BAUDRATE_38400, SerialPort.DATABITS_8, SerialPort.STOPBITS_1,
            				SerialPort.PARITY_NONE);
            

            I am able to open the port and got below success logs for it.
            port open? :: true
            parameter set? : true

            Also with slave node, I have got below logs.
            getBytesIn :: 1855
            getBytesOut :: 0

            With the listen() snippet given in
            https://github.com/infiniteautomation/BACnet4J/blob/master/src/test/java/com/serotonin/bacnet4j/adhoc/rs485/PortTest.java

            I got frames as below...
            55ff0102010000f5
            55ff01030100007c
            55ff0104010000c6
            55ff01050100004f
            55ff0106010000d7
            55ff01070100005e
            55ff0108010000a0
            55ff010901000029
            55ff010a010000b1
            55ff010b01000038
            55ff010c01000082
            55ff010d0100000b
            55ff010e01000093

            And still not able to discover remote devices...

            Am I doing anything wrong in this?

            If you have any test case with MS/TP then please share. I will be very grateful to you.

            1 Reply Last reply Reply Quote 0
            • terrypackerT
              terrypacker
              last edited by

              @Vihangi I'm not 100% confident in that test class you are trying to use as I've not ever run it up. Seems like you shouldn't be starting a discovery on both slave and master at the same time.

              Here is a more verbose way to achieve the same thing using BACnet/IP. Once you understand what this is doing you should be able to break it into 2 programs and use on separate machines with BACnet MSTP.

              The idea for this example is to be able to discover another device using the an TCP/IP socket bridge that relays the messages to the other device. In your MSTP code you would remove the bridge and start the local devices using an MSTP Master and the other as the Slave.

              https://github.com/infiniteautomation/BACnet4J-samples/blob/master/src/test/java/com/infiniteautomation/bacnet4j/npdu/ip/BacnetIpListenerDiscoveryExample.java

              1 Reply Last reply Reply Quote 0
              • V
                Vihangi
                last edited by Vihangi

                @terrypacker Is it compulsory to start discovery on slave and master at the same time?

                I am able to discover remote devices using BACnet/IP.

                And the same way I am doing with MSTP. The difference between BACnet IP and MSTP is only about the connection type/ communication medium like Ethernet or serial [RS485]. Another thing related to request-response is the same. Am I correct?

                According to my understanding, I have to provide the serial config details to the master node and create one local device and initialize it and do the "WhoIs" request-response.
                But, currently, I am not able to get "iAmReceived" on local device listeners.
                Am I wrong at any place?

                Sorry terry, but I don't understand the socket bridge. Can you please give details like what should I do?

                I just want to do as simple as done in the below example.
                https://github.com/infiniteautomation/BACnet4J-samples/blob/master/src/test/java/com/infiniteautomation/bacnet4j/rs485/SerialTest.java

                1 Reply Last reply Reply Quote 0
                • V
                  Vihangi
                  last edited by

                  Hey @terrypacker,

                  Please help to resolve the above queries related to BACne MS/TP.

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