From 81b9b33967aca3de5f3ec2a9d7d89f2b27416cc3 Mon Sep 17 00:00:00 2001 From: francis Date: Thu, 14 Nov 2024 13:58:02 -0800 Subject: [PATCH 1/4] Allow m6 code to passthrough the firmware as is so grblHal can execute it properly. --- src/server/controllers/Grbl/GrblController.js | 15 +++++---------- .../controllers/Grblhal/GrblHalController.js | 13 +++++++------ 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/src/server/controllers/Grbl/GrblController.js b/src/server/controllers/Grbl/GrblController.js index 96a28abf0..8a8ea0347 100644 --- a/src/server/controllers/Grbl/GrblController.js +++ b/src/server/controllers/Grbl/GrblController.js @@ -347,16 +347,14 @@ class GrblController { // // M6 Tool Change const passthroughM6 = store.get('preferences.toolChange.passthrough', false); - if (_.includes(words, 'M6')) { + if (!passthroughM6 && _.includes(words, 'M6')) { log.debug('M6 Tool Change'); this.feeder.hold({ data: 'M6', comment: commentString }); // Hold reason - if (!passthroughM6) { - line = line.replace('M6', '(M6)'); - } + line = line.replace('M6', '(M6)'); } @@ -472,7 +470,8 @@ class GrblController { } /* Emit event to UI for toolchange handler */ - if (_.includes(words, 'M6')) { + const passthroughM6 = store.get('preferences.toolChange.passthrough', false); + if (!passthroughM6 && _.includes(words, 'M6')) { log.debug(`M6 Tool Change: line=${sent + 1}, sent=${sent}, received=${received}`); // No toolchange in check mode @@ -512,11 +511,7 @@ class GrblController { }, 500); } } - - const passthroughM6 = store.get('preferences.toolChange.passthrough', false); - if (!passthroughM6) { - line = line.replace('M6', '(M6)'); - } + line = line.replace('M6', '(M6)'); line = line.replace(`${tool?.[0]}`, `(${tool?.[0]})`); } diff --git a/src/server/controllers/Grblhal/GrblHalController.js b/src/server/controllers/Grblhal/GrblHalController.js index fed38ca01..46137a30b 100644 --- a/src/server/controllers/Grblhal/GrblHalController.js +++ b/src/server/controllers/Grblhal/GrblHalController.js @@ -343,7 +343,8 @@ class GrblHalController { } // // M6 Tool Change - if (_.includes(words, 'M6')) { + const passthroughM6 = store.get('preferences.toolChange.passthrough', false); + if (!passthroughM6 && _.includes(words, 'M6')) { log.debug('M6 Tool Change'); this.feeder.hold({ data: 'M6', comment: commentString }); // Hold reason line = line.replace('M6', '(M6)'); @@ -463,7 +464,8 @@ class GrblHalController { } /* Emit event to UI for toolchange handler */ - if (_.includes(words, 'M6')) { + const passthroughM6 = store.get('preferences.toolChange.passthrough', false); + if (!passthroughM6 && _.includes(words, 'M6')) { log.debug(`M6 Tool Change: line=${sent + 1}, sent=${sent}, received=${received}`); const { toolChangeOption } = this.toolChangeContext; @@ -502,10 +504,9 @@ class GrblHalController { } } - const passthroughM6 = store.get('preferences.toolChange.passthrough', false); - if (!passthroughM6) { - line = line.replace('M6', '(M6)'); - } + + line = line.replace('M6', '(M6)'); + line = line.replace(`${tool?.[0]}`, `(${tool?.[0]})`); } From 8d5cc9d637a16d1483bb14d0f15cae367d1e4d2c Mon Sep 17 00:00:00 2001 From: francis Date: Sat, 21 Dec 2024 23:19:13 -0800 Subject: [PATCH 2/4] Fixing passthrough implementation. --- .../containers/Preferences/Preferences.jsx | 11 ----- .../Preferences/ToolChange/ToolChange.js | 47 +++++++++---------- src/app/store/defaultState.js | 1 - src/server/controllers/Grbl/GrblController.js | 30 +++++------- .../controllers/Grblhal/GrblHalController.js | 24 ++++++---- 5 files changed, 47 insertions(+), 66 deletions(-) diff --git a/src/app/containers/Preferences/Preferences.jsx b/src/app/containers/Preferences/Preferences.jsx index 7604033e0..a0b7ee3ce 100644 --- a/src/app/containers/Preferences/Preferences.jsx +++ b/src/app/containers/Preferences/Preferences.jsx @@ -182,7 +182,6 @@ class PreferencesPage extends PureComponent { shouldWarnZero: store.get('workspace.shouldWarnZero', false), ipRange: store.get('widgets.connection.ip', [192, 168, 5, 1]), toolChange: { - passthrough: store.get('workspace.toolChange.passthrough', false), skipDialog: store.get('workspace.toolChange.skipDialog', false) }, rotary: { @@ -750,15 +749,6 @@ class PreferencesPage extends PureComponent { } }, toolChange: { - handlePassthroughToggle: () => { - const { toolChange } = this.state; - this.setState({ - toolChange: { - ...toolChange, - passthrough: !toolChange.passthrough - } - }); - }, handleSkipDialog: () => { const { toolChange } = this.state; this.setState({ @@ -897,7 +887,6 @@ class PreferencesPage extends PureComponent { this.probeConfig.set('probeFastFeedrate', probeSettings.fastFeedrate); this.probeConfig.set('connectivityTest', probeSettings.connectivityTest); this.probeConfig.set('zProbeDistance', probeSettings.zProbeDistance); - store.set('workspace.toolChange.passthrough', toolChange.passthrough); store.set('workspace.toolChange.skipDialog', toolChange.skipDialog); controller.command('settings:updated', this.state); diff --git a/src/app/containers/Preferences/ToolChange/ToolChange.js b/src/app/containers/Preferences/ToolChange/ToolChange.js index a32fb36bc..020bf44f1 100644 --- a/src/app/containers/Preferences/ToolChange/ToolChange.js +++ b/src/app/containers/Preferences/ToolChange/ToolChange.js @@ -51,6 +51,11 @@ export const TOOLCHANGE_OPTIONS = { key: 'CODE', label: 'Code', description: 'Run code before and after the toolchange.' + }, + PASSTHROUGH: { + key: 'PASSTHROUGH', + label: 'Passthrough', + description: 'Send the toolchange line as is. This assumes that your firmware can properly handle both M6 and T commands.' } }; @@ -152,30 +157,7 @@ const ToolChange = ({ state, actions, mpos, $13 }) => { return (
- { - toolChangeOption !== 'Code' && ( - - - - ) - } - { - toolChangeOption === 'Code' && ( - - - - ) - } + Strategy to handle M6 tool change commands
{ toolChangeOption === 'Code' && (
- +