You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"use strict";var SerialPort=require("serialport"),Readline=SerialPort.parsers.Readline,inquirer=require("inquirer"),listofports=[];function openPortAndOutputData(serialport){var port=new SerialPort(serialport,{baudRate:9600},function(err){if(err)return console.log("Error: ",err.message)}),parser=new Readline;port.pipe(parser),parser.on("data",function(data){console.log("data received: "+data)})}SerialPort.list(function(e,ports){let serialPortChoices={type:"list",message:"Choose serial port you would like to connect:",name:"serialport"},listOfdevices=[];ports.forEach(element=>{listOfdevices.push(element.comName)}),serialPortChoices.choices=listOfdevices,listofports.push(serialPortChoices),inquirer.prompt(listofports).then(answer=>{openPortAndOutputData(answer.serialport)})});