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<9; 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)