本文介绍了node.js 读取 USB 端口信号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经使用 npm 为 node.js 安装了 serialport 模块.(npm install serialport).现在我想通过我的电脑的 USB 端口从我的 android 手机发送一些消息到节点应用程序(假设节点可以读取串口信号).以前有人这样做过吗?
I have installed serialport module for node.js using npm.(npm install serialport). Now I would like to send some messages from my android phone to node application via usb port of my computer(assuming node can read serial port signals). Has anyone done this before?
提前致谢.
推荐答案为什么,是的,这当然是可行的.serialport 包主页 本身列出了大量示例.
Why, yes, it's certainly doable. There's a plenty of examples listed at the serialport package homepage itself.
您的 node.js 应用程序将以...开头
Your node.js application will start with...
var SerialPort = require("serialport").SerialPort var serialPort = new SerialPort("/dev/tty-usbserial1"); serialPort.on('data', function(data) { /* processing data */ });更多推荐
node.js 读取 USB 端口信号
发布评论