Skip to content

Commit

Permalink
Check serialport connection before sending periodical commands
Browse files Browse the repository at this point in the history
  • Loading branch information
cheton committed Mar 27, 2017
1 parent f2c118e commit e51a9fb
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
18 changes: 11 additions & 7 deletions src/app/controllers/Grbl/GrblController.js
Original file line number Diff line number Diff line change
Expand Up @@ -391,9 +391,11 @@ class GrblController {
return;
}

this.actionMask.queryStatusReport = true;
this.actionTime.queryStatusReport = now;
this.serialport.write('?');
if (this.isOpen()) {
this.actionMask.queryStatusReport = true;
this.actionTime.queryStatusReport = now;
this.serialport.write('?');
}
};

const queryParserState = _.throttle(() => {
Expand All @@ -416,10 +418,12 @@ class GrblController {
return;
}

this.actionMask.queryParserState.state = true;
this.actionMask.queryParserState.reply = false;
this.actionTime.queryParserState = now;
this.serialport.write('$G\n');
if (this.isOpen()) {
this.actionMask.queryParserState.state = true;
this.actionMask.queryParserState.reply = false;
this.actionTime.queryParserState = now;
this.serialport.write('$G\n');
}
}, 500);

this.queryTimer = setInterval(() => {
Expand Down
18 changes: 11 additions & 7 deletions src/app/controllers/Smoothie/SmoothieController.js
Original file line number Diff line number Diff line change
Expand Up @@ -345,9 +345,11 @@ class SmoothieController {
return;
}

this.actionMask.queryStatusReport = true;
this.actionTime.queryStatusReport = now;
this.serialport.write('?');
if (this.isOpen()) {
this.actionMask.queryStatusReport = true;
this.actionTime.queryStatusReport = now;
this.serialport.write('?');
}
};

const queryParserState = _.throttle(() => {
Expand All @@ -370,10 +372,12 @@ class SmoothieController {
return;
}

this.actionMask.queryParserState.state = true;
this.actionMask.queryParserState.reply = false;
this.actionTime.queryParserState = now;
this.serialport.write('$G\n');
if (this.isOpen()) {
this.actionMask.queryParserState.state = true;
this.actionMask.queryParserState.reply = false;
this.actionTime.queryParserState = now;
this.serialport.write('$G\n');
}
}, 500);

this.queryTimer = setInterval(() => {
Expand Down

0 comments on commit e51a9fb

Please sign in to comment.