问题标签 [node-serialport]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
node.js - 节点串行端口在高山 linux 上失败
我正在开发一个使用 node-serialport https://github.com/voodootikigod/node-serialport的小型 nodejs (nodejs v4.3) 项目。我将它包装在 docker 图像中。首先,我成功地使用了 debian 作为基础镜像,但它的总大小约为 600MB。然后我切换到 alpine linux https://hub.docker.com/_/alpine/并实现了 100MB 的图像大小。然而,nodejs 项目停止使用 alpine 作为基础镜像。以下是一些日志:
安装节点串行端口日志:
当我尝试打开串行端口时,出现错误:
正如我所说,使用 debian 作为基本映像它可以工作。我认为这可能与 alpine linux 缺少 node-serialport 所依赖的东西有关。我在https://github.com/voodootikigod/node-serialport/issues/682上创建了一个问题,但我不确定这是 node-serialport 还是 alpine linux 的问题。我读到关于 node-pre-gyp 在 alpine/busybox 上的错误。
javascript - Javascript,serialport不能输出数字,只能输出ascii
所以我希望我的程序将一个 int 传递给串行端口,但是 javascript 使所有数字都浮动,这很糟糕。如果我尝试更多
我把它连接到一个公共汽车海盗上,这样我就可以检查输出了
如果我将数字转换为十六进制字符串,那么串口会发出与我的数字等效的字符,这也很糟糕。
但它确实输出 asci 字符,以便我在另一侧得到正确的十六进制
我试过了
但是对于那个 0xff=>0x2505
我也试过
它可以完美地工作到 127,之后它是 2 个字节,第一个字节是 194 或 195
我需要能够将 8 个字节的整数位数据发送到 arduino。
node.js - 无法在树莓派上使用 node-serialport 读取串行端口
我正在使用在 Jessy (8)、节点 v0.12.6 和串行端口 2.0.6 上运行的树莓派(第一个模型)。我已将引脚 Rx 连接到物理串行端口的引脚 Tx 上。
它与cat /dev/ttyAMA0
和一起工作正常echo "Hello" > /dev/ttyAMA0
用 node-serialport 在串口上写是好的。我正在使用下面的代码(并cat
用于阅读此内容)(来源:https ://www.npmjs.com/package/serialport )
我现在正在尝试使用 node-serialport 读取我的串行端口,但它不起作用。当我尝试使用 node-serialport 读取串行端口(并echo
用于在其上写入)时,来自终端的数据echo
不会写入终端。终端只说“打开”。我正在使用此代码,相同的来源:
我不明白这里发生了什么。任何帮助将非常感激!
非常感谢!:)
尼古拉斯
node.js - 分离从节点串口获取的数据
我正在使用 arduino 从不同的传感器获取值并打印这些值(例如温度和湿度)。
我想分离从节点串行端口获得的数据,以便我可以清楚地定义节点中的温度和湿度值。
这是我的 NodeJS 代码:
我认为我应该阵列但我无法实施。关于如何做到这一点的任何建议?
提前致谢!
node.js - Arduino UNO 连接后立即断开连接
我一直在努力获取适用于 Windows 机器(Windows 8)但不适用于 Macintosh(OS X Snow Leopard)的 node.js(Javascript)代码。这里的代码是Macintosh代码,修改了一些代码:
这是输出:
端口似乎在打开后立即关闭。我不确定为什么。有什么线索吗?(我知道 DTR/DSR 问题可能是其背后的原因,但我不确定如何解决这些问题。)
node.js - 在 nw.js 中运行 node-serialport
我正在尝试在nw.js中运行node- serialport 。在遵循有关本机模块的 nw.js 文档之后,node-serialport 似乎构建得很好,并且可以在常规节点进程中完美运行。
不幸的是,我在 nw.js 控制台窗口中收到以下错误:
{project_dir}\node_modules\serialport\node_modules\bindings\bindings.js:83 未捕获错误:模块版本不匹配。预期48,得到46。
我怎样才能一起运行这些?我错过了一些明显的东西吗?
请注意,我目前正在运行:
- 视窗 7 x64
- 节点 v4.4.4
- npm v2.4.1
- nw.js v0.15.0
- 节点gyp v3.3.1
- 串口 v3.1.2
javascript - Send CR LF in JavaScript string to node.js serialport server
I've successfully followed the instructions for creating a webpage to talk to serial ports found here. And here's the GitHub repository for his project. I've modified it slightly to use Windows COM ports and fake the Arduino data. Now I'm trying to modify it further to talk to one of my company's test boards. I've established two-way communication, so I know I can talk in both directions over the serial port.
Sending id?CRLF
over serial to the board will get a response of something like id=91
. I can do this in PuTTY by just typing in id?
& hitting the Enter key, or in DockLight by creating a send sequence id?rn
, both of which work as expected, I get the id=91
response.
However, in the client.js JavaScript, trying to send: socket.send("id?\r\n");
in the console doesn't work, but I see it show up with an extra line in the server response. So I see something like this:
So I tried to send the ASCII equivalents by doing:
Which also doesn't work, although two extra lines show up in the server.
EDIT: I've also tried: socket.send('id?\u000d\u000a');
Same results as the first Message received blurb above.
I see the sent command arrive at the server (I've modified it a bit to do a console.log upon receipt of a message from the client):
I'm not positive that the CRLF is the problem, but I'm pretty sure it is. Possibly it's being swallowed by the server?
How can I embed it in a string to be sent to the server so it get interpreted properly and sent along to the serial port?
Other SO pages I've read:
How can I insert new line/carriage returns into an element.textContent?
xbee - 从与 XBee 模块远程连接的 TOSR0X-T 继电器读取响应
我想从继电器获取板上继电器的状态,但我只能得到 ACK。
我有两个 XBee 模块,一个通过 USB 连接到计算机,用作串行设备,另一个连接到 TOSR0X-T 继电器。我计划稍后通过更多继电器将更多 XBee 模块添加到网络中,因此我使用 API 模式,而不是简单的 AT 模式,因为我需要单独解决它们。
我正在向远程 XBee 发送具有 64 位地址的 TX 帧以打开或关闭继电器。这很好,我正确地得到了 ACK 响应帧。但是,如果我通过发送 0x5B 发送消息以获取中继状态,我只会返回一个 ACK,并且我找不到返回指示中继状态的实际数据的方法。
我正在使用node-serialport和X-CTU软件,但无法读取数据,我发现的唯一示例使用连接到同一台机器的两个 XBees - 这样 RX 出现在目标 XBee 上 - 但我需要得到以某种方式远程。
此处的 TOSR0X-T 文档仅告诉我有关通过 TX 消息与之交谈的信息,因此我不知道是否可以通过命令实现任何目标(以及如何实现)。
node.js - 无法获取 Mac 上的 USB 端口列表
我正在使用以下代码列出使用 node-serialport npm 的可用端口:
它仅列出蓝牙端口,但不列出 USB 端口
下面是我得到的输出:
我安装了 OSX Captain 并且有两个 USB 端口未在此处列出。
node.js - Serialport nodejs奇怪的字符
我尝试接收 celestron nexstar goto 系统的 goto 固件版本。
我使用串行端口库接收了一些数据,但收到了一些奇怪的字符,Termite 是唯一能显示好字符的软件。
这是我收到的数据和 Termite 显示的数据的示例。
来自 node.js 的串行端口:♦§#
白蚁 : [04][15]#
这是连接到安装并显示接收到的数据的代码:
有什么方法可以显示好的数据吗?我搜索,我认为这是一个编码问题
谢谢你的帮助 !