Skip to content

Commit

Permalink
this.SERIAL_* properties tests & DEFAULT id
Browse files Browse the repository at this point in the history
  • Loading branch information
rwaldron committed Mar 14, 2016
1 parent 8e5c1f1 commit 819aa2d
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/firmata.js
@@ -1,6 +1,4 @@
/**
* Global Environment Dependencies
*/
// Global Environment Dependencies
/* jshint -W079 */
if (!Object.assign || !Map) {
require("es6-shim");
Expand Down Expand Up @@ -499,6 +497,12 @@ function Board(port, options, callback) {
SW_SERIAL1: 0x09,
SW_SERIAL2: 0x10,
SW_SERIAL3: 0x11,

// Default can be used by depender libraries to key on a
// single property name when negotiating ports.
//
// Firmata elects SW_SERIAL0: 0x08 as its DEFAULT
DEFAULT: 0x08,

This comment has been minimized.

Copy link
@dtex

dtex Mar 14, 2016

Contributor

Could we handle this here in the serialConfig method and not have to put it into every class that uses serial?

At line 1627:

if (typeof portId === "undefined") {
  portid = this.SERIAL_PORT_IDs.DEFAULT;
}
};

// map to the pin resolution value in the capability query response
Expand Down
45 changes: 45 additions & 0 deletions test/firmata.test.js
Expand Up @@ -2024,6 +2024,51 @@ describe("Board: lifecycle", function() {
});

describe("serial", function() {

it("has a SERIAL_MODES property", function(done) {

assert.deepEqual(board.SERIAL_MODES, {
CONTINUOUS_READ: 0x00,
STOP_READING: 0x01,
});

done();
});

it("has a SERIAL_PORT_IDs property", function(done) {

assert.deepEqual(board.SERIAL_PORT_IDs, {
HW_SERIAL0: 0x00,
HW_SERIAL1: 0x01,
HW_SERIAL2: 0x02,
HW_SERIAL3: 0x03,
SW_SERIAL0: 0x08,
SW_SERIAL1: 0x09,
SW_SERIAL2: 0x10,
SW_SERIAL3: 0x11,
DEFAULT: 0x08,
});

done();
});

// SERIAL_PIN_TYPES is currently unused.
// it("has a SERIAL_PIN_TYPES property", function(done) {

// assert.deepEqual(board.SERIAL_PORT_IDs, {
// RES_RX0: 0x00,
// RES_TX0: 0x01,
// RES_RX1: 0x02,
// RES_TX1: 0x03,
// RES_RX2: 0x04,
// RES_TX2: 0x05,
// RES_RX3: 0x06,
// RES_TX3: 0x07,
// });

// done();
// });

it("can configure a software serial port", function(done) {
board.serialConfig({
portId: 0x08,
Expand Down

0 comments on commit 819aa2d

Please sign in to comment.