Hi,
I'm trying to detect MSTP bacnet devices connected to a rs485-usb adapter and I'm having a problem reliably getting IAm responses.
I get a response about once every five to ten WhoIs requests,
This increases to about once every two to three tries if I change the MAC address between each request.
Other than that I cannot find any patteren in the responses.
Once I get a response(and save its details) i can reliably send requests to that device as much and as often as i want.
This, combined with tests I've done with other software, leads me to believe its not the hardware I'm using.
Originally I assumed it was my code, but once simplified as much as I could I still got the same problem.
Is this a problem others have encountered? Is this a problem with the library? or am I using it wrong?
Here is my simplified code:
public static void main(String[] args) throws Exception
{
System.out.println("Loading Params");
SerialParameters params = new SerialParameters();
params.setCommPortId("COM3");
params.setBaudRate(9600);
params.setDataBits(8);
params.setStopBits(1);
params.setParity(0);
System.out.println("Creating Device");
localDevice = new LocalDevice(1234, new Transport(new MstpNetwork(new MasterNode(params,(byte) 0x01,1))));
try
{
System.out.println("Initilising");
localDevice.initialize();
localDevice.getEventHandler().addListener(new Listener());
localDevice.sendGlobalBroadcast(new WhoIsRequest());
System.out.println("Listening");
Thread.sleep(20000);
System.out.println("Done");
}
finally
{
localDevice.terminate();
}
}
static class Listener extends DeviceEventAdapter
{
@Override
public void iAmReceived(RemoteDevice d)
{
System.out.println("IAm received from " + d);
}
}
Thanks for any help you can give,
KT