配置为Coordinator API
的XBee系列2正在尝试将数据包发送到配置为Router AT
的XBee Series 2。协调器连接到运行node.js的Mac OSX和xbee-api
library。
var frame_obj = {
type: 0x10,
ud: 0x01,
destination64: "0013a20040b19213",
data: "1"
}
serialport.write(xbeeAPI.buildFrame(frame_obj))
这会导致Node抛出错误:
/Users/me/Dropbox/Projects/test-node/node_modules/xbee-api/lib/xbee-api.js:173
throw new Error("Checksum Mismatch", S);
^
Error: Checksum Mismatch
at XBeeAPI.parseRaw (/Users/me/Dropbox/Projects/test-node/node_modules/xbee-api/lib/xbee-api.js:173:15)
at Object.parser (/Users/me/Dropbox/Projects/test-node/node_modules/xbee-api/lib/xbee-api.js:119:10)
at Object.SerialPort.options.dataCallback (/Users/me/Dropbox/Projects/test-node/node_modules/serialport/serialport.js:136:15)
at SerialPortFactory.SerialPort._emitData (/Users/me/Dropbox/Projects/test-node/node_modules/serialport/serialport.js:305:20)
at afterRead (/Users/me/Dropbox/Projects/test-node/node_modules/serialport/serialport.js:283:18)
at /Users/me/Dropbox/Projects/test-node/node_modules/serialport/serialport.js:297:9
at Object.wrapper [as oncomplete] (fs.js:454:17)
在AT Router
侧使用Arduino的串行监视器,我们可以看到协调器发送的数据实际到达了路由器。
问题:为什么会出现校验和错误?我们如何解决这个问题?
路由器AT配置
<data>
<profile>
<description_file>XB24-ZB_22A7.xml</description_file>
<settings>
<setting command="ID">2001</setting>
<setting command="SC">FFFF</setting>
<setting command="SD">3</setting>
<setting command="ZS">0</setting>
<setting command="NJ">FF</setting>
<setting command="NW">0</setting>
<setting command="JV">1</setting>
<setting command="JN">0</setting>
<setting command="DH">13A200</setting>
<setting command="DL">40A74613</setting>
<setting command="NI">0x20</setting>
<setting command="NH">1E</setting>
<setting command="BH">0</setting>
<setting command="AR">FF</setting>
<setting command="DD">30000</setting>
<setting command="NT">3C</setting>
<setting command="NO">3</setting>
<setting command="CR">3</setting>
<setting command="SE">E8</setting>
<setting command="DE">E8</setting>
<setting command="CI">11</setting>
<setting command="PL">4</setting>
<setting command="PM">1</setting>
<setting command="EE">0</setting>
<setting command="EO">0</setting>
<setting command="KY"></setting>
<setting command="BD">3</setting>
<setting command="NB">0</setting>
<setting command="SB">0</setting>
<setting command="RO">3</setting>
<setting command="D7">1</setting>
<setting command="D6">0</setting>
<setting command="CT">64</setting>
<setting command="GT">3E8</setting>
<setting command="CC">2B</setting>
<setting command="SM">0</setting>
<setting command="SN">1</setting>
<setting command="SO">0</setting>
<setting command="SP">20</setting>
<setting command="ST">1388</setting>
<setting command="PO">0</setting>
<setting command="D0">0</setting>
<setting command="D1">0</setting>
<setting command="D2">0</setting>
<setting command="D3">0</setting>
<setting command="D4">0</setting>
<setting command="D5">1</setting>
<setting command="P0">1</setting>
<setting command="P1">0</setting>
<setting command="P2">0</setting>
<setting command="PR">1FFF</setting>
<setting command="LT">0</setting>
<setting command="RP">28</setting>
<setting command="DO">1</setting>
<setting command="IR">3E8</setting>
<setting command="IC">0</setting>
<setting command="V+">0</setting>
</settings>
</profile>
</data>
协调员API配置
<data>
<profile>
<description_file>XB24-ZB_21A7.xml</description_file>
<settings>
<setting command="ID">2001</setting>
<setting command="SC">FFFF</setting>
<setting command="SD">3</setting>
<setting command="ZS">0</setting>
<setting command="NJ">FF</setting>
<setting command="DH">0</setting>
<setting command="DL">FFFF</setting>
<setting command="NI">0x20</setting>
<setting command="NH">1E</setting>
<setting command="BH">0</setting>
<setting command="AR">FF</setting>
<setting command="DD">30000</setting>
<setting command="NT">3C</setting>
<setting command="NO">3</setting>
<setting command="CR">3</setting>
<setting command="PL">4</setting>
<setting command="PM">1</setting>
<setting command="EE">0</setting>
<setting command="EO">0</setting>
<setting command="KY"></setting>
<setting command="NK"></setting>
<setting command="BD">3</setting>
<setting command="NB">0</setting>
<setting command="SB">0</setting>
<setting command="D7">1</setting>
<setting command="D6">0</setting>
<setting command="AP">1</setting>
<setting command="AO">0</setting>
<setting command="SP">20</setting>
<setting command="SN">1</setting>
<setting command="D0">1</setting>
<setting command="D1">0</setting>
<setting command="D2">0</setting>
<setting command="D3">0</setting>
<setting command="D4">0</setting>
<setting command="D5">1</setting>
<setting command="P0">1</setting>
<setting command="P1">0</setting>
<setting command="P2">0</setting>
<setting command="PR">1FFF</setting>
<setting command="LT">0</setting>
<setting command="RP">28</setting>
<setting command="DO">1</setting>
<setting command="IR">0</setting>
<setting command="IC">0</setting>
<setting command="V+">0</setting>
</settings>
</profile>
</data>
答案 0 :(得分:1)
在解析协调器上收到的帧时,看起来会抛出错误。如果是这种情况,您可以转储收到的框架吗?
堆栈跟踪指向fs.js:454:17
- 是您的代码吗?那里有什么?
如果您尝试xbee-api
中的其他样本,它们是否有效?
有些不相关,但我建议以115200 bps运行协调器,并确保在串行库和XBee模块中都启用了流量控制。这避免了溢出缓冲区的问题。来自网络的数据会在它堆积在XBee模块上之前传送到主机。
要启用硬件流控制,请将XBee模块上的ATD6
和ATD7
设置为1
。这要求主机在发送之前检查来自XBee的CTS
信号,并在准备好从XBee接收字节时断言RTS
信号。