工作经常使用串口读写数据,electron 想要替代原来的客户端,串口成了必须要突破的障碍。

get -->  https://github.com/EmergingTechnologyAdvisors/node-serialport  <-- 大神的模块

nmp install serialport 自动安装 (网络不好会失败) 如下:

Nodejs 使用 SerialPort 调用串口

自己下载,解压到对应的目录,来试一下 testport.js

1 var SerialPort = require("D:\\nodejs\\node_modules\\npm\\node_modules\\serialport");  //引入模块
2 //var SerialPort = require('serialport');
3 SerialPort.list(function (err, ports) {
4   ports.forEach(function(port) {
5     console.log(port.comName);
6     console.log(port.pnpId);
7     console.log(port.manufacturer);
8   });
9 });
View Code

相关文章:

  • 2021-11-18
  • 2021-12-04
  • 2021-11-27
  • 2022-12-23
  • 2021-09-08
  • 2022-02-03
猜你喜欢
  • 2021-08-31
  • 2021-10-05
  • 2022-12-23
  • 2022-12-23
  • 2022-01-03
  • 2022-12-23
相关资源
相似解决方案