Skip to content

Commit

Permalink
[Marlin] Do not change position query state for empty response
Browse files Browse the repository at this point in the history
  • Loading branch information
cheton committed Nov 16, 2017
1 parent e6b8239 commit 6d15c77
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
10 changes: 7 additions & 3 deletions src/app/controllers/Marlin/Marlin.js
Original file line number Diff line number Diff line change
Expand Up @@ -389,14 +389,18 @@ class Marlin extends events.EventEmitter {
...payload.heater
}
};

if (!isEqual(this.state.heater, nextState.heater)) {
this.state = nextState; // enforce change
}

// > M105
// < ok T:27.0 /0.0 B:26.8 /0.0 B@:0 @:0
if (payload.ok) {
// > M105
// < ok T:27.0 /0.0 B:26.8 /0.0 B@:0 @:0
this.emit('ok', { raw: '' });
// Emit an 'ok' event with empty response
this.emit('ok');
}

this.emit('heater', payload);
return;
}
Expand Down
7 changes: 4 additions & 3 deletions src/app/controllers/Marlin/MarlinController.js
Original file line number Diff line number Diff line change
Expand Up @@ -487,8 +487,9 @@ class MarlinController {
});

this.controller.on('ok', (res) => {
// M105 will emit an 'ok' event with empty raw
if (res.raw) {
// Do not change position query state for empty response
// Note: M105 will emit an 'ok' event with empty response
if (res) {
if (this.actionMask.queryPosition.reply) {
if (this.actionMask.replyPosition) {
this.actionMask.replyPosition = false;
Expand Down Expand Up @@ -523,7 +524,7 @@ class MarlinController {
return;
}

if (res.raw) {
if (res) {
this.emit('serialport:read', res.raw);
}

Expand Down

0 comments on commit 6d15c77

Please sign in to comment.