johnny-five
Version:
The JavaScript Robotics and Hardware Programming Framework. Use with: Arduino (all models), Electric Imp, Beagle Bone, Intel Galileo & Edison, Linino One, Pinoccio, Raspberry Pi, Spark Core, TI Launchpad and more!
30 lines (21 loc) • 603 B
JavaScript
// Derived and adapted from firmata/test/MockSerialPort.js
var util = require("util"),
events = require("events");
var MockSerialPort = function(path) {
this.path = path;
this.isClosed = false;
};
util.inherits(MockSerialPort, events.EventEmitter);
MockSerialPort.prototype.write = function() {
};
MockSerialPort.prototype.close = function() {
this.isClosed = true;
};
module.exports.SerialPort = MockSerialPort;
var calls = 0;
module.exports.list = function(callback) {
calls++;
process.nextTick(function() {
callback(null, calls === 2 ? [{comName: "/dev/usb"}] : []);
});
};