Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dishwasher module sometimes reads off the end of the buffer and crashes #2

Open
Hixie opened this issue Apr 26, 2016 · 1 comment
Open

Comments

@Hixie
Copy link

Hixie commented Apr 26, 2016

Here's my code:

require('events').EventEmitter.prototype._maxListeners = 0;

const greenBean = require("green-bean");

function report(name) {
  return function(data) {
    console.log('');
    if (typeof data == 'number') {
      console.log(name + ': ' + data + '; 0x' + data.toString(16) + '; 0b' + data.toString(2));
    } else if (typeof data == 'string') {
      console.log(name + ': "' + data + '"');
    } else if (typeof data == 'object') {
      var s = '';
      for (var f in data) {
        s += ' ' + f + '=' + data[f];
      }
      console.log(name + ': ' + s);
    } else {
      console.log(name + ': (' + typeof data + ') ' + data);
    }
    console.log('');
  }
}

var fields = [
  'cycleStatus', 'operatingMode', 'disabledFeatures', 'reminders', 'rates', 'turbidityCalibration', 'doorCount',
  'userConfiguration', 'error', 'cycleCounts', 'continuousCycle', 'controlLock', 'personality',
  'diverterCalibration', 'cycleState', 'analogData', 'cycleData0', 'cycleData1', 'cycleData2', 'cycleData3',
  'cycleData4', 'dryDrainCounters', 'tubLight'
];

var dishwasher;
greenBean.connect("dishwasher", function(dw) {
    dishwasher = dw;
    var fields = [
      'cycleStatus', 'operatingMode', 'disabledFeatures', 'reminders', 'rates', 'turbidityCalibration', 'doorCount',
      'userConfiguration', 'error', 'cycleCounts', 'continuousCycle', 'controlLock', 'personality',
      'diverterCalibration', 'cycleState', 'analogData', 'cycleData0', 'cycleData1', 'cycleData2', 'cycleData3',
      'cycleData4', 'dryDrainCounters', 'tubLight'
    ];
    for (var index = 0; index < fields.length; index += 1) {
      var field = fields[index];
      if (field in dishwasher)
        dishwasher[field].subscribe(report(field));
      else
        console.log('API doesn\'t have ', field);
    }
});

Here's the output from running it:

$ sudo node listen-dishwasher.js

cycleStatus:  cycleRunning=0 activeCycle=0 activeCycleStep=0 stepsExecuted=0 stepsEstimated=0


cycleData1:  cycleTime=112962 cycleNumber=0 cycleDurationInMinutes=118 cycleCompleted=1 cycleMinimumTemperatureInFahrenheit=70 cycleMaximumTemperatureInFahrenheit=142 cycleFinalCirculationTemperatureInFahrenheit=142 cycleMinimumTurbidityInNTU=32 cycleMaximumTurbidityInNTU=3962


cycleData2:  cycleTime=114539 cycleNumber=0 cycleDurationInMinutes=114 cycleCompleted=1 cycleMinimumTemperatureInFahrenheit=69 cycleMaximumTemperatureInFahrenheit=143 cycleFinalCirculationTemperatureInFahrenheit=142 cycleMinimumTurbidityInNTU=4 cycleMaximumTurbidityInNTU=1161

buffer.js:625
    throw new RangeError('index out of range');
    ^

RangeError: index out of range
    at checkOffset (buffer.js:625:11)
    at Buffer.readUInt8 (buffer.js:663:5)
    at readUInt8 (/home/ianh/node_modules/green-bean/node_modules/gea-sdk/node_modules/binary-stream/index.js:69:23)
    at Adapter.<anonymous> (/home/ianh/node_modules/green-bean/node_modules/gea-sdk/src/erd.js:177:56)
    at emitOne (events.js:82:20)
    at Adapter.emit (events.js:169:7)
    at onPacketReceived (/home/ianh/node_modules/green-bean/node_modules/gea-adapter-usb/index.js:103:26)
    at /home/ianh/node_modules/green-bean/node_modules/gea-adapter-usb/index.js:128:17
@Hixie
Copy link
Author

Hixie commented Apr 26, 2016

This is with a GE GDF570SGFWW.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant