node-zserial 1.0.29 → 1.0.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/zserial.js +5 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-zserial",
3
- "version": "1.0.29",
3
+ "version": "1.0.30",
4
4
  "description": "Node-RED nodes to talk to serial ports",
5
5
  "dependencies": {
6
6
  "serialport": "^12.0.0"
package/zserial.js CHANGED
@@ -1091,18 +1091,19 @@ module.exports = function (RED) {
1091
1091
  const calcB = crc16x25(b, 1, expectedEnd - 2);
1092
1092
  const fcsOK = (calcA === fcs) || (calcB === fcs);
1093
1093
 
1094
- // 注意:FCS 不通过时不能返回 ok:true(否则会“强制截帧”吞掉其它协议帧)
1095
- // 但为了防止卡死,这里仍消费掉该段,并作为错误帧上报给 emitErr。
1094
+ // 现场经常遇到:帧内容完整(68..16 边界正确),但 FCS 因链路噪声/串口转换器问题偶发不一致。
1095
+ // 若此处直接判为错误帧并 dequeue,会导致上层“偶尔无法解码”(尤其是请求-响应严格匹配的场景)。
1096
+ // 因此:当边界与长度域一致时,允许“容错通过”,并在 _meta 中标记 fcs_ok=false 供上层排障。
1096
1097
  if (!fcsOK) {
1097
1098
  return {
1098
- ok: false,
1099
+ ok: true,
1099
1100
  used: expectedEnd + 1,
1100
1101
  frame: b.slice(0, expectedEnd + 1),
1101
1102
  fcs_ok: false,
1102
1103
  fcs_frame: fcs,
1103
1104
  fcs_calc_a: calcA,
1104
1105
  fcs_calc_b: calcB,
1105
- err: "698_LEN_FCS_FAIL"
1106
+ err: "698_LEN_FCS_FAIL_TOLERATED"
1106
1107
  };
1107
1108
  }
1108
1109