npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

node-red-node-serialport-zh

v2.0.7

Published

用于与串口通信的Node-RED节点(中文版)

Readme

node-red-node-serialport-zh

用于与硬件串口通信的Node-RED节点。

安装

要安装稳定版本,请使用菜单 - 管理调色板 - 安装选项并搜索node-red-node-serialport,或在Node-RED用户目录中运行以下命令,通常是 ~/.node-red

    npm i node-red-node-serialport-zh

安装期间可能会显示多条关于可选编译的消息。这些消息可能看起来像失败...因为它们报告为编译错误失败 - 但通常是警告,节点将继续安装,假设没有其他失败。 有时某些平台要求您安装完整的工具集以编译底层包。

使用方法

提供四个节点 - 一个用于接收消息,一个用于发送,一个请求节点可以发送然后等待响应,以及一个控制节点,允许动态控制正在使用的端口。

输入

从本地串口读取数据。

点击搜索图标将尝试自动检测连接到设备的串口,但许多需要手动指定。COM1、/dev/ttyUSB0等

它可以

  • 等待"分割"字符(默认\n)。也接受十六进制表示法(0x0a)。
  • 等待从接收到的第一个字符开始的超时(毫秒)
  • 等待填充固定大小的缓冲区

然后输出msg.payload,可以是UTF8 ascii字符串或二进制Buffer对象。

如果未指定分割字符,或超时或缓冲区大小为0,则发送单个字符流 - 同样作为ascii字符或大小为1的二进制缓冲区。

输出

提供到出站串口的连接。

仅发送msg.payload

可选地,用于分割输入的字符可以附加到发送到串口的每条消息。

请求

提供到请求/响应串口的连接。

此节点的行为与串入和串出节点的紧密耦合组合,它共享配置。

像使用串出节点一样,在msg.payload中发送请求消息。消息将遵循严格FIFO(先进先出)队列转发到串口,在传输下一个请求之前等待单个响应。一旦收到响应(使用串入节点的相同逻辑),或发生超时,将产生输出消息,其中msg.payload包含接收到的响应(或在超时的情况下缺失),msg.status包含相关信息,并保留所有其他字段。

为了与串入节点保持一致,msg.port也设置为所选端口的名称。

控制

当Node-RED启动时,流程(程序)会拾取预编程的串口,打开它,并开始通信。但在某些情况下,端口需要切换到不同的端口,停止,然后重新启动。例如,为了上传Arduino的新二进制文件,需要从nodered释放串口,上传后重新启动。或者当FTDI设备因任何原因断开连接后重新连接时,可能会更改端口号,而流程的用户无法更改端口。

此节点提供以下能力:

  1. 在运行时以编程方式更改串口及其配置。
  2. 停止通信并释放串口。
  3. 重新打开端口并重新启动通信。

为了控制通信,向控制节点发送msg.payload

{
    "serialport": "/dev/ttyUSB0",
    "serialbaud": 115200,
    "databits": 8,
    "parity": "none",
    "stopbits": 1,
    "enabled": true
}

即时更改串口及其配置。

以下可选参数仅在存在时才会更改配置。 可以传递它们的任何组合来更改/控制串口通信

  • serialport
  • serialbaud
  • databits
  • parity
  • stopbits
  • dtr
  • rts
  • cts
  • dsr
  • enabled

如果未传递enabled属性,则默认为true

{"enabled":true}{"enabled":false}将启动或停止通信。

如果enabled与其他参数一起传递,则将更改配置,端口将启动或保持停止,具体取决于其值,准备稍后启动。

任何输入消息都将导致节点输出当前端口配置。