根据官方文档做了以下端口创建:
const xn_serialPort = require('@serialport/stream')
const MockBinding = require('@serialport/binding-mock')
xn_serialPort.Binding = MockBinding
MockBinding.createPort('COM122', { echo: true, record: true })
MockBinding.createPort('COM123', { echo: true, record: true })
然后通过内部代码连接这个虚拟串口成功了
let port = new xn_serialPort('COM123',{
baudRate: 9600, //波特率
dataBits: 8, //数据位
parity: 'none', //奇偶校验
stopBits: 1, //停止位
flowControl: false,
autoOpen: false
})
port.open(function (error) {
if (error) {
console.log('打开虚拟串口失败'+error)
}else {
console.log('打开虚拟串口成功')
port.on("data", function(data) {
console.log('虚拟串口接收的数据是:'+data)
})
}
})
然后显示连接成功了
但是设备管理器里面又看不见这两个串口,
请问,怎么才能让虚拟出来的两个串口显示在设备管理器上面。