【发布时间】:2014-06-01 00:15:23
【问题描述】:
我希望 nodejs 使用 xbee 发送和接收消息。我知道 xbee 设置有效,因为我在 x-ctu 上对其进行了测试。我尝试了以下但无法收到消息。它说它是开放的。
var util = require('util');
var SerialPort = require('serialport').SerialPort;
var xbee_api = require('xbee-api');
var C = xbee_api.constants;
var xbeeAPI = new xbee_api.XBeeAPI({
api_mode: 1
});
var serialport = new SerialPort("COM7", {
baudrate: 9600,
parser: xbeeAPI.parseRaw(1000)
});
serialport.on("open", function() {
console.log("open");
});
// All frames parsed by the XBee will be emitted here
//I think this is the problem
xbeeAPI.on("frame_object", function(frame) {
console.log(">>", frame);
});
【问题讨论】: