Skip to content
Branch: master
Find file History
Latest commit 7ddbf3e Jan 15, 2019
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
lib Don't test Serialport.list Jan 15, 2019
.tesselignore .tesselignore files for both packages Jan 15, 2019
package-lock.json Lerna/Monorepo: initial reorganization Oct 24, 2018
package.json v2.0.0 Jan 15, 2019
readme.md README: add newline marker to copyright lines Jan 15, 2019

readme.md

Firmata-io

This is Firmata.js without a default Transport.

Install

Install Firmata-io:

npm install firmata-io --save

Install a Transport:

npm install serialport --save

Transports

  • Serialport
  • Etherport

Basic Usage

With A Transport Class

Here's an example using the Serialport class:

// Require your Transport!
const Serialport = require("serialport"); 
// Pass the Transport class to the transport binding 
// function exported by firmata-io. The transport binding
// function will return the Firmata class object with
// the Transport class bound in its scope. 
const Firmata = require("firmata-io")(Serialport);

Firmata.requestPort((error, port) => {
  if (error) {
    console.log(error);
    return;
  }

  const board = new Firmata(port.comName);

  board.on("close", () => {
    // Unplug the board to see this event!
    console.log("Closed!");
  });
});

With A Transport Instance

Here's an example using a Serialport instance:

// Require your Transport!
const Serialport = require("serialport");
// Get the Firmata class without a bound transport. 
const Firmata = require("firmata-io").Firmata;

Serialport.list().then(ports => {
  // Figure which port to use...
  const port = ports.find(port => port.manufacturer.startsWith("Arduino"));
  
  // Instantiate an instance of your Transport class
  const transport = new Serialport(port.comName);

  // Pass the new instance directly to the Firmata class
  const board = new Firmata(transport);

  board.on("close", () => {
    // Unplug the board to see this event!
    console.log("Closed!");
  });
});

License

(The MIT License)

Copyright (c) 2011-2015 Julian Gautier julian.gautier@alumni.neumont.edu
Copyright (c) 2015-2019 The Firmata.js Authors (see AUTHORS.md)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

You can’t perform that action at this time.