java - BACnet client not connecting to BACnet interface using BACnet4j -


i newbie bacnet , other automation protocols.we going write 1 bacnet client expected connect bacnet interface fetch objects , further going ingest these objects in our microservices layer.our server infrastructure contains luminsight desktop push data onto bacnet interface. referring 1 example code while running getting below issue:

> inside main....com.serotonin.bacnet4j.transport.defaulttransport@7b7221a0 inside main....3996: bacnet device exception in thread "main" java.net.bindexception: address in use: cannot bind     @ java.net.dualstackplaindatagramsocketimpl.socketbind(native method)     @ java.net.dualstackplaindatagramsocketimpl.bind0(unknown source)     @ java.net.abstractplaindatagramsocketimpl.bind(unknown source)     @ java.net.datagramsocket.bind(unknown source)     @ java.net.datagramsocket.<init>(unknown source)     @ com.serotonin.bacnet4j.npdu.ip.ipnetwork.initialize(ipnetwork.java:215)     @ com.serotonin.bacnet4j.transport.defaulttransport.initialize(defaulttransport.java:183)     @ com.serotonin.bacnet4j.localdevice.initialize(localdevice.java:228)     @ com.bacnet.main.main(main.java:110)       package com.bacnet;      import com.serotonin.bacnet4j.localdevice;     import com.serotonin.bacnet4j.remotedevice;     import com.serotonin.bacnet4j.servicefuture;     import com.serotonin.bacnet4j.event.deviceeventadapter;     import com.serotonin.bacnet4j.exception.bacnetexception;     import com.serotonin.bacnet4j.exception.errorapduexception;     import com.serotonin.bacnet4j.npdu.ip.ipnetwork;     import com.serotonin.bacnet4j.service.acknowledgement.readpropertyack;     import com.serotonin.bacnet4j.service.acknowledgement.readpropertymultipleack;     import com.serotonin.bacnet4j.service.confirmed.*;     import com.serotonin.bacnet4j.service.unconfirmed.whoisrequest;     import com.serotonin.bacnet4j.transport.defaulttransport;     import com.serotonin.bacnet4j.transport.transport;     import com.serotonin.bacnet4j.type.constructed.readaccessresult;     import com.serotonin.bacnet4j.type.constructed.readaccessspecification;     import com.serotonin.bacnet4j.type.constructed.sequenceof;     import com.serotonin.bacnet4j.type.enumerated.objecttype;     import com.serotonin.bacnet4j.type.enumerated.propertyidentifier;     import com.serotonin.bacnet4j.type.enumerated.segmentation;     import com.serotonin.bacnet4j.type.primitive.objectidentifier;     import com.serotonin.bacnet4j.type.primitive.real;     import com.serotonin.bacnet4j.util.discoveryutils;     import com.serotonin.bacnet4j.remoteobject;      import java.util.arraylist;     import java.util.list;      public class main {         public static void main(string[] args) throws exception {              ipnetwork network = new ipnetwork("10.44.55.5", ipnetwork.default_port);              transport transport = new defaulttransport(network);             system.out.println("inside main...." + transport);             transport.settimeout(500);             transport.setsegtimeout(150);             final localdevice localdevice = new localdevice(3996, transport);             system.out.println("inside main...." + localdevice);             localdevice.geteventhandler().addlistener(new deviceeventadapter() {                 @override                 public void iamreceived(remotedevice device) {                     system.out.println("inside received...");                     system.out.println("discovered device " + device);                     localdevice.addremotedevice(device);                      final remotedevice remotedevice = localdevice                             .getremotedevice(device.getaddress());                      remotedevice                             .setsegmentationsupported(segmentation.segmentedboth);                     new thread(new runnable() {                         @override                         public void run() {                             try {                                 try {                                     discoveryutils.getextendeddeviceinformation(                                             localdevice, remotedevice);                                 } catch (bacnetexception e) {                                     e.printstacktrace();                                 }                                 system.out.println(remotedevice.getname() + " "                                         + remotedevice.getvendorname() + " "                                         + remotedevice.getmodelname() + " "                                         + remotedevice.getaddress() + " "                                         + remotedevice.getprotocolrevision() + " "                                         + remotedevice.getprotocolversion());                                  readpropertyack ack = localdevice.send(                                         remotedevice,                                         new readpropertyrequest(remotedevice                                                 .getobjectidentifier(),                                                 propertyidentifier.objectlist))                                         .get();                                 sequenceof<objectidentifier> value = ack.getvalue();                                  (objectidentifier id : value) {                                      list<readaccessspecification> specs = new arraylist<readaccessspecification>();                                     specs.add(new readaccessspecification(id,                                             propertyidentifier.presentvalue));                                     specs.add(new readaccessspecification(id,                                             propertyidentifier.units));                                     specs.add(new readaccessspecification(id,                                             propertyidentifier.objectname));                                     specs.add(new readaccessspecification(id,                                             propertyidentifier.description));                                     specs.add(new readaccessspecification(id,                                             propertyidentifier.objecttype));                                     readpropertymultiplerequest multiplerequest = new readpropertymultiplerequest(                                             new sequenceof<readaccessspecification>(                                                     specs));                                      readpropertymultipleack send = localdevice                                             .send(remotedevice, multiplerequest)                                             .get();                                     sequenceof<readaccessresult> readaccessresults = send                                             .getlistofreadaccessresults();                                      system.out.print(id.getinstancenumber() + " "                                             + id.getobjecttype() + ", ");                                     (readaccessresult result : readaccessresults) {                                         (readaccessresult.result r : result                                                 .getlistofresults()) {                                             system.out.print(r.getreadresult()                                                     + ", ");                                         }                                     }                                     system.out.println();                                 }                                  objectidentifier mode = new objectidentifier(                                         objecttype.analogvalue, 11);                                  servicefuture send = localdevice.send(remotedevice,                                         new writepropertyrequest(mode,                                                 propertyidentifier.presentvalue,                                                 null, new real(2), null));                                 system.out.println(send.getclass());                                 system.out.println(send.get().getclass());                              } catch (errorapduexception e) {                                 system.out.println("could not read value "                                         + e.getapdu().geterror() + " " + e);                             } catch (bacnetexception e) {                                 e.printstacktrace();                             }                          }                     }).start();                 }                  @override                 public void ihavereceived(remotedevice device, remoteobject object) {                     system.out.println("value reported " + device + " " + object);                 }             });              localdevice.initialize();             localdevice.sendglobalbroadcast(new whoisrequest());              list<remotedevice> remotedevices = localdevice.getremotedevices();             (remotedevice device : remotedevices) {                 system.out.println("remote dev " + device);             }              system.in.read();             localdevice.terminate();         }      } 


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -