Home/Support/Support Forum/Unable to open xbeedevice using XBee java library

Unable to open xbeedevice using XBee java library

0 votes
I using XBee Pro SX rf module mounted on sx development board and using XBee java library to open the xbeedevice conenction and broadcast a message.

Below is the code i am running in Eclipse-

public class MainApp {
/* Constants */
// TODO Replace with the port where your sender module is connected to.
private static final String PORT = "/dev/tty.usbserial-FTKDZ7DC";
// TODO Replace with the baud rate of your sender module.
private static final int BAUD_RATE = 9600;
private static final String DATA_TO_SEND = "Hello XBee World!";
public static void main(String[] args) {
XBeeDevice myDevice = new XBeeDevice(PORT, BAUD_RATE);
System.out.println("device info:"+myDevice.toString()+"~~~"+myDevice.isOpen());
byte[] dataToSend = DATA_TO_SEND.getBytes();
try {
myDevice.open();
System.out.format("Sending broadcast data: '%s'", new String
(dataToSend));
myDevice.sendBroadcastData(dataToSend);
System.out.println(" >> Success");
} catch (XBeeException e) {
System.out.println(" >> Error");
e.printStackTrace();
System.exit(1);
} finally {
myDevice.close();
}
}
}

I am getting the follwing error when i try to open the xbeedevice:

com.digi.xbee.api.exceptions.XBeeException: Error reading device information.
at com.digi.xbee.api.XBeeDevice.open(XBeeDevice.java:367)
at com.digi.xbee.example.MainApp.main(MainApp.java:20)
Caused by: com.digi.xbee.api.exceptions.ATCommandException: There was a problem sending the AT command packet. > Invalid command
at com.digi.xbee.api.AbstractXBeeDevice.checkATCommandResponseIsValid(AbstractXBeeDevice.java:1980)
at com.digi.xbee.api.AbstractXBeeDevice.sendParameter(AbstractXBeeDevice.java:2227)
at com.digi.xbee.api.AbstractXBeeDevice.getParameter(AbstractXBeeDevice.java:2160)
at com.digi.xbee.api.AbstractXBeeDevice.readDeviceInfo(AbstractXBeeDevice.java:485)
at com.digi.xbee.api.XBeeDevice.open(XBeeDevice.java:365)
... 1 more


I am stuck here. Need help to resolve this issue. Thanks
asked May 15, 2017 in RF Solutions and XBee by swarna1310 New to the Community (0 points)

Please log in or register to answer this question.

...