1

配置为 a 的 XBee 系列 2Coordinator API正在尝试向配置为 a 的 XBee 系列 2 发送数据包Router AT。Coordinator 连接到运行 node.js 和xbee-apilibrary的 Mac OSX 。

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 的 Serial Monitor,我们可以看到 Coordinator 发送的数据实际上到达了 Router。

在此处输入图像描述

问题:为什么会出现校验和错误?我们怎样才能解决这个问题?

路由器 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>
4

1 回答 1

1

解析在协调器上接收到的帧时似乎引发了错误。如果是这种情况,您可以转储接收到的帧吗?

堆栈跟踪指向fs.js:454:17——那是你的代码吗?什么东西在那里?

如果您尝试来自 的其他样本xbee-api,它们是否有效?

有点不相关,但我建议以 115200 bps 的速度运行协调器,并确保在串行库和 XBee 模块中都启用了流控制。这避免了缓冲区溢出的问题。来自网络的数据在堆积到 XBee 模块之前被传送到主机。

要启用硬件流控制,请将XBee 模块上的ATD6和设置为. 这要求主机在发送到 XBee 之前检查来自 XBee 的信号,并在准备好从 XBee 接收字节时断言信号。ATD71CTSRTS

于 2014-03-20T05:36:43.287 回答