Node Red 升级串口node-red-node-serialport后,程序打印illegal instruction后退出

本文解决了一个NodeRed中使用node-red-node-serialport节点遇到的illegalinstruction问题,通过从源代码重新编译节点,最终解决了该问题。

问题

设备中NodeRed节点“node-red-node-serialport”发现有了更新(0.10.3),索性删除了节点,并使用npm指令和界面安装,但不论哪种方式,在使用节点后,都会出现 illegal instruction 后退出,不论再安何种版本,都是异常。。。。尴尬😅

解决方案

在网上搜索 NodeRed serialport ,找到一个贴子

I suspect that your image somehow got a serial node installed that was not built from sources but consists of a pre-built binary for standard i586, rather than the Quark processor. That caused crashes in the past. Normally, the serial node gets rebuilt during installation and even updates. You can trigger that manually by running "npm rebuild --build-from-source node-red-node-serialport" in /home/root/.node-red/node_modules.

提到了可能是因为节点安装不是由源码编译,而是包含预编译的二进制数据。

这个方向很有可能。。。。

按照给出的方法

npm rebuild --build-from-source node-red-node-serialport

然而没有奏效。。。。尴尬😅

继续找的过程中又发现了一个

How did you install the serialport nodes?

For the Quark processor they have to be built from source:

npm install serialport --build-from-source


Kind regards!

删除node-red-node-serialport后,依然不启效果,但已然感觉是没有编译的问题

最后解决方法

npm rebuild --build-from-source

在漫长的编译过程后,可以使用了 😁,问题解决

 

node-serialport 是一个 Node.js 的包,用来对串口数据进行读写操作。基本示例代码:var SerialPort = require("serialport").SerialPort var serialPort = new SerialPort("/dev/tty-usbserial1", {   baudrate: 57600 }, false); // this is the openImmediately flag [default is true] serialPort.open(function (error) {   if ( error ) {     console.log('failed to open: ' error);   } else {     console.log('open');     serialPort.on('data', function(data) {       console.log('data received: '   data);     });     serialPort.write("ls\n", function(err, results) {       console.log('err '   err);       console.log('results '   results);     });   } });罗列所有串口:var serialPort = require("serialport"); serialPort.list(function (err, ports) {   ports.forEach(function(port) {     console.log(port.comName);     console.log(port.pnpId);     console.log(port.manufacturer);   }); });串口配置:baudRatedataBitsstopBitsparityrtsctsxonxoffxanyflowControlbufferSizeparserencodingdataCallbackdisconnectedCallbackplatformOptions - sets platform specific options, see below.目前已有很多项目在使用这个包进行串口处理:Johnny-Five - Firmata based Arduino Framework.Cylon.js - JavaScript Robotics, By Your Command.node-l8smartlight (source) A node library to control the L8 Smartlight via Bluetooth or USB portfirmata Talk natively to Arduino using the firmata protocol.tmpad source - a DIY midi pad using infrared, arduino, and nodejs. Videoduino - A higher level framework for working with Arduinos in node.js.Arduino Drinking Game Extravaganza - AKA "The Russian" a hexidecimal drinking game for geeks by Uxebu presented at JSConf EU 2011.Arduino controlling popcorn.js - Controlling a popcorn.js video with an Arduino kit.Robotic JavaScript - The first live presentation of the node-serialport code set as presented at JSConf EU 2010.devicestack - This module helps you to represent a device and its protocol.reflecta A communication protocol that combines Arduino Libraries and NodeJS into an integrated system.rc4pt-node - Control Popcorntime with an
### Node-RED 中 `node-red-node-serialport` 使用说明 #### 安装 为了使用 `node-red-node-serialport` 节点,在Node-RED环境中需先安装此包。可以通过npm全局安装来实现这一操作: ```bash npm install -g node-red-node-serialport@2.0.2 ``` 完成上述命令之后,重启Node-RED服务使新加入的串口节点生效[^1]。 #### 配置与连接设备 当成功安装并重新加载Node-RED后,可以在调色板中找到名为 "Serial" 的输入/输出节点用于配置串行通信参数,比如波特率、数据位等设置项。通过拖拽方式将其放置于工作区,并双击打开属性面板进行具体设定以匹配目标硬件的要求。 #### 创建基本流程实例 下面给出一段简单的例子展示如何利用这个插件读取来自Arduino或其他微控制器的数据并通过调试窗口显示出来: ```json [ { "id": "read_serial", "type": "serial in", "z": "flow_id", "name": "", "serial": "com_port", // COM端口号, 如COM3 或 /dev/ttyUSB0 "baudrate": "9600", "databits": "8", "parity": "none", "stopbits": "1", "bin": false, "out": "char", "addchar": "\n" }, { "id": "debug_output", "type": "debug", "z": "flow_id", "name": "", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "payload", "targetType": "msg", "x": 450, "y": 160, "wires": [] } ] ``` 在这个JSON片段里定义了一个从指定串口接收字符消息并将它们发送给Debug查看器的过程。请注意替换实际使用的串行接口名称以及调整其他必要的选项以便适应特定应用场景下的需求。
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值