Skip to content

Commit

Permalink
temp: reduce sampling interval (until lower level read failure issue …
Browse files Browse the repository at this point in the history
…is resolved)

Signed-off-by: Rick Waldron <waldron.rick@gmail.com>
  • Loading branch information
rwaldron committed May 31, 2016
1 parent 0190f74 commit 37279ac
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
3 changes: 2 additions & 1 deletion lib/tessel.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ function ToI2CBusPort(value) {
return undefined;
}

var samplingInterval = 10;
var samplingInterval = 100;

function Port() {}

Expand Down Expand Up @@ -864,6 +864,7 @@ if (process.env.IS_TEST_ENV) {
Tessel.ToPortI2CBus = ToPortI2CBus;
Tessel.ToI2CBusPort = ToI2CBusPort;
Tessel.Pin = Pin;
Tessel.defaultSamplingInterval = samplingInterval;
Tessel.tessel = tessel;
Tessel.purge = function() {
tessels.length = 0;
Expand Down
33 changes: 17 additions & 16 deletions test/tessel.js
Original file line number Diff line number Diff line change
Expand Up @@ -840,7 +840,7 @@ exports["Tessel.prototype.digitalRead"] = {
test.equal(this.spy.callCount, 1);
test.equal(this.spy.lastCall.args[0], 1);

this.clock.tick(11);
this.clock.tick(this.tessel.getSamplingInterval() + 1);

test.equal(this.portSockWrite.callCount, 2);
test.equal(this.portCork.callCount, 2);
Expand All @@ -854,7 +854,7 @@ exports["Tessel.prototype.digitalRead"] = {
test.equal(this.spy.callCount, 2);
test.equal(this.spy.lastCall.args[0], 0);

this.clock.tick(11);
this.clock.tick(this.tessel.getSamplingInterval() + 1);

test.equal(this.portSockWrite.callCount, 3);
test.equal(this.portCork.callCount, 3);
Expand Down Expand Up @@ -980,7 +980,7 @@ exports["Tessel.prototype.analogRead"] = {
test.equal(this.spy.callCount, 1);
test.equal(this.spy.lastCall.args[0], 128);

this.clock.tick(11);
this.clock.tick(this.tessel.getSamplingInterval() + 1);

test.equal(this.portSockWrite.callCount, 2);
test.equal(this.portCork.callCount, 2);
Expand All @@ -994,7 +994,7 @@ exports["Tessel.prototype.analogRead"] = {
test.equal(this.spy.callCount, 2);
test.equal(this.spy.lastCall.args[0], 64);

this.clock.tick(11);
this.clock.tick(this.tessel.getSamplingInterval() + 1);

test.equal(this.portSockWrite.callCount, 3);
test.equal(this.portCork.callCount, 3);
Expand Down Expand Up @@ -1426,6 +1426,7 @@ exports["Tessel.prototype.i2cWriteReg"] = {
exports["Tessel.prototype.i2cReadOnce"] = {
setUp: function(done) {
this.sandbox = sinon.sandbox.create();
this.clock = this.sandbox.useFakeTimers();
this.on = this.sandbox.spy(Tessel.prototype, "on");
this.transfer = this.sandbox.stub(T2.I2C.prototype, "transfer");
this.tessel = new Tessel();
Expand Down Expand Up @@ -1528,12 +1529,12 @@ exports["Tessel.prototype.i2cRead"] = {

this.tessel.i2cConfig({ address: 0x04, bus: "A" });
this.tessel.i2cRead(0x04, 4, handler);
this.clock.tick(10);
this.clock.tick(10);
this.clock.tick(10);
this.clock.tick(10);
this.clock.tick(10);
this.clock.tick(10);
this.clock.tick(this.tessel.getSamplingInterval());
this.clock.tick(this.tessel.getSamplingInterval());
this.clock.tick(this.tessel.getSamplingInterval());
this.clock.tick(this.tessel.getSamplingInterval());
this.clock.tick(this.tessel.getSamplingInterval());
this.clock.tick(this.tessel.getSamplingInterval());
},

regAndBytesToRead: function(test) {
Expand All @@ -1550,11 +1551,11 @@ exports["Tessel.prototype.i2cRead"] = {

this.tessel.i2cConfig({ address: 0x04, bus: "A" });
this.tessel.i2cRead(0x04, 0xff, 4, handler);
this.clock.tick(10);
this.clock.tick(10);
this.clock.tick(10);
this.clock.tick(10);
this.clock.tick(10);
this.clock.tick(this.tessel.getSamplingInterval());
this.clock.tick(this.tessel.getSamplingInterval());
this.clock.tick(this.tessel.getSamplingInterval());
this.clock.tick(this.tessel.getSamplingInterval());
this.clock.tick(this.tessel.getSamplingInterval());
},
};

Expand All @@ -1572,7 +1573,7 @@ exports["Tessel.prototype.setSamplingInterval"] = {
},
samplingIntervalDefault: function(test) {
test.expect(1);
test.equal(this.tessel.getSamplingInterval(), 10);
test.equal(this.tessel.getSamplingInterval(), Tessel.defaultSamplingInterval);
test.done();
},
samplingIntervalCustom: function(test) {
Expand Down

0 comments on commit 37279ac

Please sign in to comment.