diff --git a/lib/adaptors/serialport.js b/lib/adaptors/serialport.js index b928147..02f6a54 100644 --- a/lib/adaptors/serialport.js +++ b/lib/adaptors/serialport.js @@ -3,21 +3,21 @@ var util = require("util"), EventEmitter = require("events").EventEmitter; -var serialport, +var Serialport, isChrome = typeof chrome !== "undefined"; // thanks to https://github.com/jgautier/firmata/blob/master/lib/firmata.js try { if (isChrome) { - serialport = require("browser-serialport"); + Serialport = require("browser-serialport"); } else { - serialport = require("serialport"); + Serialport = require("serialport"); } } catch (error) { - serialport = null; + Serialport = null; } -if (serialport == null) { +if (Serialport == null) { var err = [ "It looks like you want to connect to a Sphero 1.0/2.0 or Sphero SPRK,", "but did not install the 'node-serialport' module.", "", @@ -52,7 +52,7 @@ util.inherits(Adaptor, EventEmitter); */ Adaptor.prototype.open = function open(callback) { var self = this, - port = this.serialport = new serialport.SerialPort(this.conn, {}); + port = this.serialport = new Serialport(this.conn, {}); function emit(name) { return self.emit.bind(self, name);