我试图通过使用java库打开和关闭xbee的别针(XB24-ZB)。
这是我的系统楔形图:1. (COM7) 2. (COM17)
其中两个具有相同的ID。我使用的是exmaple代码:
XBee xbee = new XBee();
xbee.open("COM17", 9600);
// this is the Serial High (SH) + Serial Low (SL) of the remote XBee
XBeeAddress64 addr64 = new XBeeAddress64("00 13 A2 00 40 A7 3E 7E");
// Turn on DIO0 (Pin 20)
RemoteAtRequest request = new RemoteAtRequest(addr64, "D0", new int[XBeePin.Capability.DIGITAL_OUTPUT_HIGH.getValue()]);
xbee.sendAsynchronous(request);
RemoteAtResponse response = (RemoteAtResponse) xbee.getResponse();
if (response.isOk()) {
System.out.println("Successfully turned on DIO0");
} else {
System.out.println("Attempt to turn on DIO0 failed. Status: " + response.getStatus());
}
// shutdown the serial port and associated threads
xbee.close();当我运行这段代码时,xbee #1上的DI0确实会更改为0(禁用),而不是5。
Log4j:没有为记录器(com.rapplogic.xbee.api.InputStreamThread)找到任何附加程序。Log4j:没有为记录器(com.rapplogic.xbee.api.InputStreamThread)找到任何附加程序。log4j :警告请正确初始化log4j系统。log4j :警告请正确初始化log4j系统。
"AP“设置为2,我得到的反应是好的。我在这里错过了什么?谢谢
发布于 2014-11-07 23:21:38
试着使用这些进口产品:
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;将这一行添加到类中:
private final static Logger log = Logger.getLogger(YourClass.class);在main()中,将这一行开头:
PropertyConfigurator.configure("log4j.properties");我从API src文件夹中的代码示例中获得了它,我的程序运行得很好。
https://stackoverflow.com/questions/25644499
复制相似问题