How to use the serialport.list function in serialport

To help you get started, we’ve selected a few serialport examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github berkon / wireless-microphone-analyzer / renderer.js View on Github external
function openPort () {
    let start_f = Math.floor ( START_FREQ / 1000 );
    let stop_f  = Math.floor ( STOP_FREQ  / 1000 );

    if( !PORT_MENU_SELECTION || PORT_MENU_SELECTION === 'AUTO' ) { // Automatic port selection
        SerialPort.list().then ( (ports, err) => {
            if ( err ) {
                console.log ( err );
                return;
            }

            let i = 0;

            console.log ( "Trying port " + ports[i].comName + " ...");
            port = new SerialPort ( ports[i].comName, { baudRate : 500000 }, function ( err ) {
                if ( err ) // Most likely the reason for the error is that the RF Explorer is not connected to this port. So we don't print an error message here.
                    return;

                setCallbacks();
                sendAnalyzer_SetConfig ( start_f, stop_f );
            });
github scimusmn / stele / src / main / serial / serialRelay.js View on Github external
const refreshPortList = () => {
  logger.info('serialRelay: refreshPortList');

  serialport.list().then((list) => {
    Object.keys(list).forEach((key) => {
      const portObj = list[key];
      const { comName, manufacturer } = portObj;

      // Scrape for Arduinos...
      if (autoEnableArduinos === true
          && manufacturer !== undefined) {
        if (manufacturer.indexOf('Arduino') !== -1
            || manufacturer.indexOf('Silicon Labs') !== -1) {
          console.log(`Auto-enabling: ${comName} - ${manufacturer}`);
          logger.info(`serialRelay: Auto-enabling: ${comName} - ${manufacturer}`);
          enableSerialPort(comName, { baudRate: defaultBaudRate });
        }
      }
    });
github berkon / wireless-microphone-analyzer / main.js View on Github external
ipcMain.on ( "SET_COUNTRY", (event, message) => {
        menuJSON[MENU_COUNTRY].submenu.forEach ( function ( elem ) {
            if ( elem.code === message.country_code ) {
                elem.checked = true;
                Menu.setApplicationMenu ( Menu.buildFromTemplate ( menuJSON ) );
            }
        });
    });

    menuJSON.push ( portMenuJSON  );
    menuJSON.push ( toolsMenuJSON );
    menuJSON.push ( helpMenuJSON  );

    // Add serial ports to the menu
    SerialPort.list().then ( (ports, err) => {
        let portNameArr = [];

        if ( err ) {
            console.log ( err );
            return;
        }
        
        ports.forEach ( ( port ) => {
            portNameArr.push ( port.comName );
        });

        menuJSON[MENU_PORT].submenu[0] = { label: 'Auto', type: 'radio', click () { wc.send ( 'SET_PORT',  portNameArr ); } }

        portNameArr.forEach ( ( port ) => {
            menuJSON[MENU_PORT].submenu.push (
                {
github bigclownlabs / bch-playground / src / utils / Gateway.js View on Github external
function port_list(callback) {
    SerialPort.list()
        .then((ports) => {

            // for (let i=0, l=ports.length; i {
                return port.manufacturer == "0403" || port.vendorId == "0403";
            }));
        })
        .catch(() => {
            callback([]);
        });
}
github bolandrm / rmb_multicopter / ui / app / serial / serialManager.js View on Github external
refreshPorts = (autoconnect = false) => {
    if (!_.isBoolean(autoconnect)) autoconnect = false

    SerialPort.list((error, ports) => {
      if (error) {
        console.log('failed to get devices')
      } else {
        ports = _.map(ports, (port) => port.comName)
        ports = _.filter(ports, (port) => !port.match(/[Bb]luetooth/) && port.match(/\/dev\/cu/))
        this.ports = ports

        let defaultDevice = this._findDefaultDevice(this.ports)

        if (defaultDevice) {
          this.portSelected = defaultDevice
          if (autoconnect === true) this.connect()
        } else {
          this.portSelected = this.ports[0]
        }
      }
github thingsSDK / flasher.js / back-end / scanForPorts.js View on Github external
function scanForPorts(callback) {
    serialport.list(callback);
}
github jos-b / language-circuitpython / lib / board-view.js View on Github external
connect() {
        SerialPort.list().then((ports) => {
            atom.notifications.addInfo("Attempting to locate board");

            ports = ports.map((v) => {
                if (!v.vendorId) {
                    v.vendorId = "";
                }

                return v;
            });

            let chosenBoard = ports.find(e => vendorIDs.indexOf(e.vendorId.toLowerCase()) != -1);

            if (!chosenBoard) {
                atom.notifications.addError("Could not find a valid device");
                return;
            }
github GridSpace / grid-host / src / serial.js View on Github external
function probeSerial(then) {
    let match = null;
    SerialPort.list((err, ports) => {
        ports.forEach(port => {
            if (port.pnpId) {
                match = port.comName;
            } else if (port.manufacturer && port.manufacturer.toLowerCase().indexOf("arduino") >= 0) {
                match = port.comName;
            } else if (!match && (port.vendorId || port.productId || port.serialNumber)) {
                match = port.comnName;
            }
        });
        then(match);
    });
}
github BiancoRoyal / node-red-contrib-modbus / src / modbus-client.js View on Github external
RED.httpAdmin.get('/modbus/serial/ports', RED.auth.needsPermission('serial.read'), function (req, res) {
    const SerialPort = require('serialport')
    SerialPort.list().then(ports => {
      res.json(ports)
    }).catch(err => {
      coreModbusClient.internalDebug(err.message)
    })
  })
}
github GladysAssistant / Gladys / server / services / usb / index.js View on Github external
async function list() {
    return SerialPort.list();
  }

serialport

Node.js package to access serial ports. Linux, OSX and Windows. Welcome your robotic JavaScript overlords. Better yet, program them!

MIT
Latest version published 8 months ago

Package Health Score

88 / 100
Full package analysis