Skip to content
This repository has been archived by the owner on Dec 20, 2019. It is now read-only.

Refactored serialport adaptor to work with latest version of serialport #99

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions lib/adaptors/serialport.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.", "",
Expand Down Expand Up @@ -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);
Expand Down