How to use the firmata.Board.requestPort function in firmata

To help you get started, we’ve selected a few firmata 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 iamdustan / react-hardware / src / ReactHardwareMount.js View on Github external
function connect(maybePort:string, callback:Function) {
  if (maybePort !== TRANSIENT_CONTAINER_IDENTIFIER) {
    connect(maybePort);
  } else {
    console.info('Requesting port...');
    Board.requestPort((err, port) => {
      if (err) {
        throw err;
      } else {
        console.log(port.comName);
        // Remap the connection from transient state to the real port
        connectionsByContainer[port.comName] = connectionsByContainer[maybePort];
        delete connectionsByContainer[maybePort];
        connect(port.comName);
      }
    });
  }

  function connect(port) {
    console.info('Connecting to port "%s"', port);
    const board = new Board(port, function(err) {
      if (err) {
github iamdustan / react-hardware / src / firmata / HardwareInstanceManager.js View on Github external
connect(
    port : ?string,
    callback: Result
  ) {
    if (port == null) {
      console.info('Requesting port...');
      Board.requestPort((error, port) => {
        if (error) {
          callback(error);
        } else {
          setup(port.comName, callback);
        }
      });
    } else {
      setup(port, callback);
    }
  },

firmata

Firmata protocol implementation for programmatic interaction with Arduino and Arduino compatible development boards. Includes Serialport

MIT
Latest version published 4 years ago

Package Health Score

48 / 100
Full package analysis

Similar packages