Skip to content

Commit

Permalink
Minor enhancements for PR #228
Browse files Browse the repository at this point in the history
  • Loading branch information
cheton committed Nov 15, 2017
1 parent 46c665e commit e6b8239
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
15 changes: 8 additions & 7 deletions src/app/controllers/Marlin/Marlin.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,7 @@ class MarlinLineParserResultHeater {

const heater = {
extruder: {},
bed: {},
reply: line.startsWith('ok')
bed: {}
};
const re = /(?:(?:(T|B|T\d+):([0-9\.\-]+)\s+\/([0-9\.\-]+)(?:\s+\((?:[0-9\.\-]+)\))?)|(?:(@|B@|@\d+):([0-9\.\-]+))|(?:(W):(\?|[0-9]+)))/ig;

Expand Down Expand Up @@ -277,7 +276,8 @@ class MarlinLineParserResultHeater {
return {
type: MarlinLineParserResultHeater,
payload: {
heater
ok: line.startsWith('ok'),
heater: heater
}
};
}
Expand Down Expand Up @@ -392,11 +392,12 @@ class Marlin extends events.EventEmitter {
if (!isEqual(this.state.heater, nextState.heater)) {
this.state = nextState; // enforce change
}
this.emit('heater', payload);
console.log(payload);
if (payload.heater.reply) {
this.emit('ok', 'temp ok');
if (payload.ok) {
// > M105
// < ok T:27.0 /0.0 B:26.8 /0.0 B@:0 @:0
this.emit('ok', { raw: '' });
}
this.emit('heater', payload);
return;
}
if (data.length > 0) {
Expand Down
19 changes: 12 additions & 7 deletions src/app/controllers/Marlin/MarlinController.js
Original file line number Diff line number Diff line change
Expand Up @@ -487,13 +487,16 @@ class MarlinController {
});

this.controller.on('ok', (res) => {
if (this.actionMask.queryPosition.reply) {
if (this.actionMask.replyPosition) {
this.actionMask.replyPosition = false;
this.emit('serialport:read', res.raw);
// M105 will emit an 'ok' event with empty raw
if (res.raw) {
if (this.actionMask.queryPosition.reply) {
if (this.actionMask.replyPosition) {
this.actionMask.replyPosition = false;
this.emit('serialport:read', res.raw);
}
this.actionMask.queryPosition.reply = false;
return;
}
this.actionMask.queryPosition.reply = false;
return;
}

const { hold, sent, received } = this.sender.state;
Expand All @@ -520,7 +523,9 @@ class MarlinController {
return;
}

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

// Feeder
this.feeder.next();
Expand Down

0 comments on commit e6b8239

Please sign in to comment.