From 2e23dfbdb74045dac2c16f1eef0032e274254405 Mon Sep 17 00:00:00 2001
From: openbuilds-engineer
Date: Thu, 9 Aug 2018 19:29:41 +0200
Subject: [PATCH] Fixes for Smoothieware
---
app/js/websocket.js | 87 ---------------------------------------------
index.js | 28 ++++++++-------
package.json | 2 +-
3 files changed, 17 insertions(+), 100 deletions(-)
diff --git a/app/js/websocket.js b/app/js/websocket.js
index 7ab6b9d..655e6de 100644
--- a/app/js/websocket.js
+++ b/app/js/websocket.js
@@ -3,7 +3,6 @@ var server = ''; //192.168.14.100';
var programBoard = {};
var grblParams = {}
var smoothieParams = {}
-var sduploading;
var nostatusyet = true;
var safeToUpdateSliders = false;
var laststatus
@@ -134,21 +133,6 @@ function initSocket() {
socket.on('data', function(data) {
// console.log(data.length, data)
var toPrint = data.response;
- if (data.response.indexOf("Done saving file.") != -1) {
- $('#sdupload_modal').modal('hide');
- $("#sduploadform").show()
- $("#sduploadprogress").hide()
- $("#sduploadbtn").prop('disabled', false);
- $("#sduploadcancelbtn").prop('disabled', false);
- $("#sdmodalclosebtn").prop('disabled', false);
- $('#sdprogressup').css('width', '0%').attr('aria-valuenow', 0);
- }
- if (data.response.indexOf("End file list") != -1) {
- // We just got an M20 sd listing back... lets update UI
- setTimeout(function() {
- sdListPopulate();
- }, 600);
- }
// Parse Grbl Settings Feedback
if (data.response.indexOf('$') === 0) {
@@ -192,11 +176,6 @@ function initSocket() {
var progressbar = $("#progressbar").data("progress");
progressbar.val(donepercent);
// }
- sduploading = data[2];
- if (sduploading) {
- var percent = 100 - (parseInt(data[0]) / parseInt(data[1]) * 100)
- $('#sdprogressup').css('width', percent + '%').attr('aria-valuenow', percent);
- }
})
socket.on('toastError', function(data) {
@@ -421,22 +400,6 @@ function initSocket() {
}
});
- $("#sdtogglemodal").on("click", function() {
- $('#sdupload_modal').modal('show');
- if (sduploading) {
- $("#sduploadform").hide()
- $("#sduploadprogress").show()
- } else {
- $("#sduploadform").show()
- $("#sduploadprogress").hide()
- }
- })
-
- $("#sdlist").on("click", function() {
- sendGcode("M20");
- })
-
-
var bellflash = setInterval(function() {
if (!nostatusyet) {
if (laststatus) {
@@ -500,42 +463,6 @@ function sendGcode(gcode) {
// $('#editorContextMenu').hide();
// }
-function sdListPopulate() {
- $('#sdfilelist').empty();
- if (laststatus.machine.sdcard.list.length > 0) {
- for (i = laststatus.machine.sdcard.list.length - 1; i >= 0; i--) {
- var name = laststatus.machine.sdcard.list[i]
- console.log(name);
- if (name.length > 25) {
- var newname = ""
- newname += name.substring(0, 10)
- newname += "..."
- newname += name.substring(name.length - 10)
- name = newname;
- }
-
- if (name.indexOf("config") != -1 || name.indexOf("CONFIG") != -1) {
- $("#sdfilelist").append(` ` + name + ` | |
`);
- } else if (name.indexOf("FIRMWARE.CUR") != -1 || name.indexOf("firmware.cur") != -1) {
- $("#sdfilelist").append(` ` + name + ` | |
`);
- } else {
- $("#sdfilelist").append(`
-
- ` + name + `
- |
-
-
-
-
-
- |
-
`);
- }
- }
- $("#sdlist_modal").modal("show")
- }
-
-}
function feedOverride(step) {
if (socket) {
@@ -549,20 +476,6 @@ function spindleOverride(step) {
}
}
-function sdUpload() {
- $("#sduploadbtn").prop('disabled', true);
- $("#sduploadcancelbtn").prop('disabled', true);
- $("#sdmodalclosebtn").prop('disabled', true);
- $("#sduploadform").hide()
- $("#sduploadprogress").show()
- var filename = $("#sdfilename").val();
- var gcode = editor.getValue()
- var data = []
- data.push(filename)
- data.push(gcode)
- socket.emit("saveToSd", data)
-}
-
function friendlyPort(i) {
// var likely = false;
var img = 'usb.png';
diff --git a/index.js b/index.js
index 77c4b79..9d7eefb 100644
--- a/index.js
+++ b/index.js
@@ -735,9 +735,7 @@ io.on("connection", function(socket) {
// Start interval for status queries
statusLoop = setInterval(function() {
if (status.comms.connectionStatus > 0) {
- if (!status.comms.sduploading) {
- addQRealtime("?");
- }
+ addQRealtime("?");
}
}, 250);
} else if (data.indexOf("LPC176") >= 0) { // LPC1768 or LPC1769 should be Smoothieware
@@ -756,12 +754,7 @@ io.on("connection", function(socket) {
// Start interval for status queries
statusLoop = setInterval(function() {
if (status.comms.connectionStatus > 0) {
- if (!status.comms.sduploading) {
- addQRealtime("?");
- if (status.machine.tools.hotend1 || status.machine.tools.hotend2 || status.machine.tools.heatbed) {
- addQToStart("M105\n");
- }
- }
+ addQRealtime("?");
}
}, 200);
} // end of machine identification
@@ -778,6 +771,11 @@ io.on("connection", function(socket) {
// console.log('got OK from ' + command)
command = sentBuffer.shift();
}
+
+ if (status.machine.firmware.type === "smoothie") {
+ // console.log('got OK from ' + command)
+ command = sentBuffer.shift();
+ }
status.comms.blocked = false;
send1Q();
} else if (data.indexOf('ALARM') === 0) { //} || data.indexOf('HALTED') === 0) {
@@ -797,7 +795,7 @@ io.on("connection", function(socket) {
status.comms.connectionStatus = 5;
} else if (data.indexOf('WARNING: After HALT you should HOME as position is currently unknown') != -1) { //} || data.indexOf('HALTED') === 0) {
status.comms.connectionStatus = 2;
- } else if (data.indexOf('Emergency Stop Requested ') != -1) { //} || data.indexOf('HALTED') === 0) {
+ } else if (data.indexOf('Emergency Stop Requested') != -1) { //} || data.indexOf('HALTED') === 0) {
console.log("Emergency Stop Requested")
status.comms.connectionStatus = 5;
} else if (data.indexOf('wait') === 0) { // Got wait from Repetier -> ignore
@@ -1321,10 +1319,16 @@ io.on("connection", function(socket) {
console.log('Cleaning Queue');
addQRealtime(String.fromCharCode(0x18)); // ctrl-x
console.log('Sent: Code(0x18)');
+ status.comms.connectionStatus = 2;
break;
case 'smoothie':
status.comms.paused = true;
addQRealtime('M112'); // ctrl-x
+ setTimeout(function() {
+ addQToEnd("?");
+ send1Q();
+ }, 1000);
+ status.comms.connectionStatus = 5;
console.log('Sent: M112');
break;
}
@@ -1332,12 +1336,12 @@ io.on("connection", function(socket) {
status.comms.queue = 0
queuePointer = 0;
gcodeQueue.length = 0; // Dump the queue
+ sentBuffer.length = 0; // Dump the queue
// sentBuffer.length = 0; // Dump bufferSizes
laserTestOn = false;
status.comms.blocked = false;
status.comms.paused = false;
status.comms.runStatus = 'Stopped';
- status.comms.connectionStatus = 2;
if (jogWindow && !jogWindow.isFocused()) {
appIcon.displayBalloon({
icon: nativeImage.createFromPath(iconPath),
@@ -1445,7 +1449,6 @@ function machineSend(gcode) {
var data = []
data.push(queueLeft);
data.push(queueTotal);
- data.push(status.comms.sduploading)
io.sockets.emit("queueCount", data);
// console.log(gcode)
port.write(gcode);
@@ -1774,6 +1777,7 @@ function send1Q() {
gcode = gcodeQueue[queuePointer];
queuePointer++;
status.comms.blocked = true;
+ sentBuffer.push(gcode);
machineSend(gcode + '\n');
// console.log('Sent: ' + gcode + ' Q: ' + (gcodeQueue.length - queuePointer));
}
diff --git a/package.json b/package.json
index c240e39..a73df49 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "OpenBuildsMachineDriver",
- "version": "1.0.62",
+ "version": "1.0.63",
"license": "AGPL-3.0",
"description": "Machine Interface Driver for OpenBuilds",
"author": "github.com/openbuilds ",