从magellan 8300使用nodejs从串行端口读取数据

时间:2019-06-06 17:20:12

标签: node.js magellan

我有一个Magellan 8300扫描仪和电子秤,我需要从扫描仪读取数据并使用nodejs进行电子秤。我尝试了serialport,该端口已打开,但是没有数据从计算机返回。我使用RS232电缆在COM1上连接。任何人都可以通过一个小的代码来帮助我,该代码使我可以实时接收magellan 8300的编码数据和权重。

非常感谢您!

const SerialPort = require('serialport')
const Readline = require('@serialport/parser-readline')
const port = new SerialPort("COM1", { baudRate: 9600 })

const parser = new Readline()
port.pipe(parser)

parser.on('data', line => console.log(`> ${line}`))

我希望输出是数据或控制台日志上的任何内容。

0 个答案:

没有答案