Skip to content

Commit

Permalink
Merge pull request #4 from rsteckler/s5pro-fix
Browse files Browse the repository at this point in the history
S5pro fix
  • Loading branch information
rsteckler authored Aug 14, 2023
2 parents ea45c77 + 0ea5716 commit 81d859b
Show file tree
Hide file tree
Showing 29 changed files with 137 additions and 38 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cncjs",
"version": "1.10.3",
"version": "1.10.4",
"description": "A web-based interface for CNC milling controller running Grbl, Marlin, Smoothieware, or TinyG",
"homepage": "https://github.com/cncjs/cncjs",
"author": "Cheton Wu <[email protected]>",
Expand Down
2 changes: 1 addition & 1 deletion scripts/build-prod.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ popd
babel -d dist/cncjs/server src/server
i18next-scanner --config i18next-scanner.server.config.js \"src/server/**/*.{html,js,jsx}\" \"!src/server/i18n/**\" \"!**/node_modules/**\"

cross-env NODE_ENV=production webpack-cli --config webpack.config.production.js
cross-env NODE_ENV=production NODE_OPTIONS=--openssl-legacy-provider webpack-cli --config webpack.config.production.js
i18next-scanner --config i18next-scanner.app.config.js \"src/app/**/*.{html,js,jsx}\" \"!src/app/i18n/**\" \"!**/node_modules/**\"

mkdir -p dist/cncjs/app
Expand Down
18 changes: 16 additions & 2 deletions src/app/containers/Settings/MachineProfiles/CreateRecord.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import PropTypes from 'prop-types';
import React, { Component } from 'react';
import { Form, Field } from 'react-final-form';
import { Input } from 'app/components/FormControl';
import { Checkbox } from 'app/components/Checkbox';
import FormGroup from 'app/components/FormGroup';
import { FlexContainer, Row, Col } from 'app/components/GridSystem';
import Margin from 'app/components/Margin';
Expand Down Expand Up @@ -34,7 +35,8 @@ class CreateRecord extends Component {
ymax: 0,
zmin: 0,
zmax: 0,
}
},
avoidParens: false
}
};
}
Expand All @@ -51,7 +53,8 @@ class CreateRecord extends Component {
ymax: Number(_get(values, 'limits.ymax')) || 0,
zmin: Number(_get(values, 'limits.zmin')) || 0,
zmax: Number(_get(values, 'limits.zmax')) || 0,
}
},
avoidParens: Boolean(_get(values, 'avoidParens', false))
});
};

Expand Down Expand Up @@ -180,6 +183,17 @@ class CreateRecord extends Component {
{this.renderLimits()}
</Margin>
</SectionGroup>
<SectionGroup>
<Field name="avoidParens" type="checkbox">
{({ input, meta }) => (
<Checkbox
{...input}
>
{i18n._('Don\'t send parentheses to this machine (ONLY for Shapeoko 5 Pro)')}
</Checkbox>
)}
</Field>
</SectionGroup>
</Modal.Body>
<Modal.Footer>
<button
Expand Down
18 changes: 16 additions & 2 deletions src/app/containers/Settings/MachineProfiles/UpdateRecord.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import PropTypes from 'prop-types';
import React, { Component } from 'react';
import { Form, Field } from 'react-final-form';
import { Input } from 'app/components/FormControl';
import { Checkbox } from 'app/components/Checkbox';
import FormGroup from 'app/components/FormGroup';
import { FlexContainer, Row, Col } from 'app/components/GridSystem';
import Margin from 'app/components/Margin';
Expand Down Expand Up @@ -36,7 +37,8 @@ class UpdateRecord extends Component {
ymax: Number(_get(values, 'limits.ymax')) || 0,
zmin: Number(_get(values, 'limits.zmin')) || 0,
zmax: Number(_get(values, 'limits.zmax')) || 0,
}
},
avoidParens: Boolean(_get(values, 'avoidParens', false))
}
};
}
Expand All @@ -55,7 +57,8 @@ class UpdateRecord extends Component {
ymax: Number(_get(values, 'limits.ymax')) || 0,
zmin: Number(_get(values, 'limits.zmin')) || 0,
zmax: Number(_get(values, 'limits.zmax')) || 0,
}
},
avoidParens: Boolean(_get(values, 'avoidParens', false))
}, forceReload);
};

Expand Down Expand Up @@ -184,6 +187,17 @@ class UpdateRecord extends Component {
{this.renderLimits()}
</Margin>
</SectionGroup>
<SectionGroup>
<Field name="avoidParens" type="checkbox">
{({ input, meta }) => (
<Checkbox
{...input}
>
{i18n._('Don\'t send parentheses to this machine (ONLY for Shapeoko 5 Pro)')}
</Checkbox>
)}
</Field>
</SectionGroup>
</Modal.Body>
<Modal.Footer>
<button
Expand Down
3 changes: 2 additions & 1 deletion src/app/i18n/cs/resource.json
Original file line number Diff line number Diff line change
Expand Up @@ -537,5 +537,6 @@
"SET": "NASTAVIT",
"CLR": "VYMAZAT",
"Set RTS line status upon opening": "Nastavit stav řádky RTS při otevírání",
"Use RTS/CTS flow control": "Použijte řízení toku RTS/CTS"
"Use RTS/CTS flow control": "Použijte řízení toku RTS/CTS",
"Don't send parentheses to this machine (ONLY for Shapeoko 5 Pro)": ""
}
3 changes: 2 additions & 1 deletion src/app/i18n/de/resource.json
Original file line number Diff line number Diff line change
Expand Up @@ -537,5 +537,6 @@
"SET": "SETZEN",
"CLR": "LÖSCHEN",
"Set RTS line status upon opening": "Setze den RTS-Leitungsstatus beim Öffnen",
"Use RTS/CTS flow control": "Verwende RTS/CTS-Flusskontrolle"
"Use RTS/CTS flow control": "Verwende RTS/CTS-Flusskontrolle",
"Don't send parentheses to this machine (ONLY for Shapeoko 5 Pro)": ""
}
3 changes: 2 additions & 1 deletion src/app/i18n/en/resource.json
Original file line number Diff line number Diff line change
Expand Up @@ -537,5 +537,6 @@
"SET": "SET",
"CLR": "CLR",
"Set RTS line status upon opening": "Set RTS line status upon opening",
"Use RTS/CTS flow control": "Use RTS/CTS flow control"
"Use RTS/CTS flow control": "Use RTS/CTS flow control",
"Don't send parentheses to this machine (ONLY for Shapeoko 5 Pro)": "Don't send parentheses to this machine (ONLY for Shapeoko 5 Pro)"
}
3 changes: 2 additions & 1 deletion src/app/i18n/es/resource.json
Original file line number Diff line number Diff line change
Expand Up @@ -537,5 +537,6 @@
"SET": "ESTABLECER",
"CLR": "BORRAR",
"Set RTS line status upon opening": "Establecer el estado de la línea RTS al abrir",
"Use RTS/CTS flow control": "Utilice control de flujo RTS/CTS"
"Use RTS/CTS flow control": "Utilice control de flujo RTS/CTS",
"Don't send parentheses to this machine (ONLY for Shapeoko 5 Pro)": ""
}
3 changes: 2 additions & 1 deletion src/app/i18n/fr/resource.json
Original file line number Diff line number Diff line change
Expand Up @@ -537,5 +537,6 @@
"SET": "ÉTABLIR",
"CLR": "CLR",
"Set RTS line status upon opening": "Définir l'état de la ligne RTS à l'ouverture",
"Use RTS/CTS flow control": "Utilisez le contrôle de flux RTS/CTS"
"Use RTS/CTS flow control": "Utilisez le contrôle de flux RTS/CTS",
"Don't send parentheses to this machine (ONLY for Shapeoko 5 Pro)": ""
}
3 changes: 2 additions & 1 deletion src/app/i18n/hu/resource.json
Original file line number Diff line number Diff line change
Expand Up @@ -537,5 +537,6 @@
"SET": "BEÁLLÍT",
"CLR": "TÖRLÉS",
"Set RTS line status upon opening": "RTS vonal állapotának beállítása az nyitáskor",
"Use RTS/CTS flow control": "Használjon RTS/CTS áramvezérlést"
"Use RTS/CTS flow control": "Használjon RTS/CTS áramvezérlést",
"Don't send parentheses to this machine (ONLY for Shapeoko 5 Pro)": ""
}
3 changes: 2 additions & 1 deletion src/app/i18n/it/resource.json
Original file line number Diff line number Diff line change
Expand Up @@ -537,5 +537,6 @@
"SET": "IMPOSTA",
"CLR": "CANCELLA",
"Set RTS line status upon opening": "Imposta lo stato della linea RTS all'apertura",
"Use RTS/CTS flow control": "Utilizzare il controllo di flusso RTS/CTS"
"Use RTS/CTS flow control": "Utilizzare il controllo di flusso RTS/CTS",
"Don't send parentheses to this machine (ONLY for Shapeoko 5 Pro)": ""
}
3 changes: 2 additions & 1 deletion src/app/i18n/ja/resource.json
Original file line number Diff line number Diff line change
Expand Up @@ -537,5 +537,6 @@
"SET": "設定",
"CLR": "クリア",
"Set RTS line status upon opening": "開くときにRTSラインの状態を設定する",
"Use RTS/CTS flow control": "RTS/CTSフロー制御を使用する"
"Use RTS/CTS flow control": "RTS/CTSフロー制御を使用する",
"Don't send parentheses to this machine (ONLY for Shapeoko 5 Pro)": ""
}
3 changes: 2 additions & 1 deletion src/app/i18n/nb/resource.json
Original file line number Diff line number Diff line change
Expand Up @@ -537,5 +537,6 @@
"SET": "SETT",
"CLR": "SLETT",
"Set RTS line status upon opening": "Sett RTS-linjestatus ved åpning",
"Use RTS/CTS flow control": "Bruk RTS/CTS strømstyring"
"Use RTS/CTS flow control": "Bruk RTS/CTS strømstyring",
"Don't send parentheses to this machine (ONLY for Shapeoko 5 Pro)": ""
}
3 changes: 2 additions & 1 deletion src/app/i18n/nl/resource.json
Original file line number Diff line number Diff line change
Expand Up @@ -537,5 +537,6 @@
"SET": "INSTELLEN",
"CLR": "WISSEN",
"Set RTS line status upon opening": "Stel RTS-lijnstatus in bij opening",
"Use RTS/CTS flow control": "Gebruik RTS/CTS-stroomregeling"
"Use RTS/CTS flow control": "Gebruik RTS/CTS-stroomregeling",
"Don't send parentheses to this machine (ONLY for Shapeoko 5 Pro)": ""
}
3 changes: 2 additions & 1 deletion src/app/i18n/pt-br/resource.json
Original file line number Diff line number Diff line change
Expand Up @@ -537,5 +537,6 @@
"SET": "DEFINIR",
"CLR": "LIMPAR",
"Set RTS line status upon opening": "Definir status da linha RTS na abertura",
"Use RTS/CTS flow control": "Use o controle de fluxo RTS/CTS"
"Use RTS/CTS flow control": "Use o controle de fluxo RTS/CTS",
"Don't send parentheses to this machine (ONLY for Shapeoko 5 Pro)": ""
}
3 changes: 2 additions & 1 deletion src/app/i18n/pt-pt/resource.json
Original file line number Diff line number Diff line change
Expand Up @@ -537,5 +537,6 @@
"SET": "DEFINIR",
"CLR": "LIMPAR",
"Set RTS line status upon opening": "Definir estado da linha RTS na abertura",
"Use RTS/CTS flow control": "Use o controlo de fluxo RTS/CTS"
"Use RTS/CTS flow control": "Use o controlo de fluxo RTS/CTS",
"Don't send parentheses to this machine (ONLY for Shapeoko 5 Pro)": ""
}
3 changes: 2 additions & 1 deletion src/app/i18n/ru/resource.json
Original file line number Diff line number Diff line change
Expand Up @@ -537,5 +537,6 @@
"SET": "УСТАНОВИТЬ",
"CLR": "ОЧИСТИТЬ",
"Set RTS line status upon opening": "Установить статус линии RTS при открытии",
"Use RTS/CTS flow control": "Используйте контроль потока RTS/CTS"
"Use RTS/CTS flow control": "Используйте контроль потока RTS/CTS",
"Don't send parentheses to this machine (ONLY for Shapeoko 5 Pro)": ""
}
3 changes: 2 additions & 1 deletion src/app/i18n/tr/resource.json
Original file line number Diff line number Diff line change
Expand Up @@ -537,5 +537,6 @@
"SET": "AYARLA",
"CLR": "TEMİZLE",
"Set RTS line status upon opening": "Açılışta RTS hat durumunu ayarla",
"Use RTS/CTS flow control": "RTS/CTS akış kontrolü kullanın"
"Use RTS/CTS flow control": "RTS/CTS akış kontrolü kullanın",
"Don't send parentheses to this machine (ONLY for Shapeoko 5 Pro)": ""
}
3 changes: 2 additions & 1 deletion src/app/i18n/zh-cn/resource.json
Original file line number Diff line number Diff line change
Expand Up @@ -537,5 +537,6 @@
"SET": "设置",
"CLR": "清除",
"Set RTS line status upon opening": "打开时设置RTS线路状态",
"Use RTS/CTS flow control": "使用RTS/CTS流控制"
"Use RTS/CTS flow control": "使用RTS/CTS流控制",
"Don't send parentheses to this machine (ONLY for Shapeoko 5 Pro)": ""
}
3 changes: 2 additions & 1 deletion src/app/i18n/zh-tw/resource.json
Original file line number Diff line number Diff line change
Expand Up @@ -537,5 +537,6 @@
"SET": "設置",
"CLR": "清除",
"Set RTS line status upon opening": "開啟時設置RTS線路狀態",
"Use RTS/CTS flow control": "使用RTS/CTS流量控制"
"Use RTS/CTS flow control": "使用RTS/CTS流量控制",
"Don't send parentheses to this machine (ONLY for Shapeoko 5 Pro)": ""
}
4 changes: 3 additions & 1 deletion src/app/widgets/Visualizer/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import controller from 'app/lib/controller';
import i18n from 'app/lib/i18n';
import log from 'app/lib/log';
import portal from 'app/lib/portal';
import store from 'app/store';
import * as WebGL from 'app/lib/three/WebGL';
import { in2mm } from 'app/lib/units';
import WidgetConfig from '../WidgetConfig';
Expand Down Expand Up @@ -245,7 +246,8 @@ class VisualizerWidget extends PureComponent {
}
}));

controller.command('gcode:load', name, gcode, context, (err, data) => {
const machine = store.get('workspace.machineProfile');
controller.command('gcode:load', name, gcode, machine, context, (err, data) => {
if (err) {
this.setState((state) => ({
gcode: {
Expand Down
2 changes: 1 addition & 1 deletion src/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cncjs-app",
"version": "1.10.3",
"version": "1.10.4",
"productName": "CNCjs",
"description": "CNC Milling Controller",
"homepage": "https://github.com/cncjs/cncjs",
Expand Down
8 changes: 5 additions & 3 deletions src/server/api/api.machines.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import _castArray from 'lodash/castArray';
import _isPlainObject from 'lodash/isPlainObject';
import uuid from 'uuid';
import settings from '../config/settings';
import { ensureNumber, ensureString } from '../lib/ensure-type';
import { ensureNumber, ensureString, ensureBoolean } from '../lib/ensure-type';
import logger from '../lib/logger';
import config from '../services/configstore';
import { getPagingRange } from './paging';
Expand Down Expand Up @@ -46,7 +46,7 @@ const getSanitizedRecords = () => {
};

const ensureMachineProfile = (payload) => {
const { id, name, limits } = { ...payload };
const { id, name, limits, avoidParens } = { ...payload };
const { xmin = 0, xmax = 0, ymin = 0, ymax = 0, zmin = 0, zmax = 0 } = { ...limits };

return {
Expand All @@ -59,7 +59,8 @@ const ensureMachineProfile = (payload) => {
ymax: ensureNumber(ymax) || 0,
zmin: ensureNumber(zmin) || 0,
zmax: ensureNumber(zmax) || 0,
}
},
avoidParens: ensureBoolean(avoidParens)
};
};

Expand Down Expand Up @@ -149,6 +150,7 @@ export const update = (req, res) => {
['limits.ymax', ensureNumber],
['limits.zmin', ensureNumber],
['limits.zmax', ensureNumber],
['avoidParens', ensureBoolean],
].forEach(it => {
const [key, ensureType] = it;
const defaultValue = _get(record, key);
Expand Down
25 changes: 21 additions & 4 deletions src/server/controllers/Grbl/GrblController.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,11 +236,16 @@ class GrblController {
log.debug('M6 Tool Change');
this.feeder.hold({ data: 'M6', msg: originalLine }); // Hold reason


// Surround M6 with parentheses to ignore
// unsupported command error. If we nuke the whole
// line, then we'll likely lose other commands that
// share the line, like a T~. This makes tool
// changes complicated.


//This apparently never gets called and instead the sender version does. Leaving this as-is for now
//without replacing the parentheses until I understand the situations where this code executes.
line = line.replace('M6', '(M6)');
}

Expand Down Expand Up @@ -340,6 +345,18 @@ class GrblController {
line = line.replace('M6', '(M6)');
}

//It's unclear to me at the moment why the gcode_parser allows parentheses comments to come through. There's code in
//parser.parseLine (called above) that strips parentheses comments, at least as shown in the source, though I haven't
//debugged it: https://github.com/cncjs/gcode-parser/blob/d3f431d15abd2d49f4d89b9b01556142f6ebf1da/src/index.js#L69

//In any case, the parentheses are coming through and the M6 toolchange code above adds even more after-the-fact. We'll
//add the removal here as the step JUST before it gets sent to the controller as a catch-all.
if (this.sender.state.machine.avoidParens) {
if (_.includes(line, '(')) {
line = line.replace(/\(.*?\)/g, '');
}
}

return line;
}
});
Expand Down Expand Up @@ -1083,7 +1100,7 @@ class GrblController {
command(cmd, ...args) {
const handler = {
'gcode:load': () => {
let [name, gcode, context = {}, callback = noop] = args;
let [name, gcode, machine, context = {}, callback = noop] = args;
if (typeof context === 'function') {
callback = context;
context = {};
Expand All @@ -1094,16 +1111,16 @@ class GrblController {
// be no queued motions, as long as no more commands were sent after the G4.
// This is the fastest way to do it without having to check the status reports.
const dwell = '%wait ; Wait for the planner to empty';
const ok = this.sender.load(name, gcode + '\n' + dwell, context);
const ok = this.sender.load(name, gcode + '\n' + dwell, machine, context);
if (!ok) {
callback(new Error(`Invalid G-code: name=${name}`));
return;
}

this.emit('gcode:load', name, this.sender.state.gcode, context);
this.emit('gcode:load', name, this.sender.state.gcode, machine, context);
this.event.trigger('gcode:load');

log.debug(`Load G-code: name="${this.sender.state.name}", size=${this.sender.state.gcode.length}, total=${this.sender.state.total}`);
log.debug(`Load G-code: name="${this.sender.state.name}", machineName=${this.sender.state.machine.name}, size=${this.sender.state.gcode.length}, total=${this.sender.state.total}`);

this.workflow.stop();

Expand Down
2 changes: 1 addition & 1 deletion src/server/controllers/Marlin/MarlinController.js
Original file line number Diff line number Diff line change
Expand Up @@ -1109,7 +1109,7 @@ class MarlinController {
// be no queued motions, as long as no more commands were sent after the G4.
// This is the fastest way to do it without having to check the status reports.
const dwell = '%wait ; Wait for the planner to empty';
const ok = this.sender.load(name, gcode + '\n' + dwell, context);
const ok = this.sender.load(name, gcode + '\n' + dwell, null, context);
if (!ok) {
callback(new Error(`Invalid G-code: name=${name}`));
return;
Expand Down
2 changes: 1 addition & 1 deletion src/server/controllers/Smoothie/SmoothieController.js
Original file line number Diff line number Diff line change
Expand Up @@ -1023,7 +1023,7 @@ class SmoothieController {
// be no queued motions, as long as no more commands were sent after the G4.
// This is the fastest way to do it without having to check the status reports.
const dwell = '%wait ; Wait for the planner to empty';
const ok = this.sender.load(name, gcode + '\n' + dwell, context);
const ok = this.sender.load(name, gcode + '\n' + dwell, null, context);
if (!ok) {
callback(new Error(`Invalid G-code: name=${name}`));
return;
Expand Down
2 changes: 1 addition & 1 deletion src/server/controllers/TinyG/TinyGController.js
Original file line number Diff line number Diff line change
Expand Up @@ -1123,7 +1123,7 @@ class TinyGController {
// be no queued motions, as long as no more commands were sent after the G4.
// This is the fastest way to do it without having to check the status reports.
const dwell = '%wait ; Wait for the planner to empty';
const ok = this.sender.load(name, gcode + '\n' + dwell, context);
const ok = this.sender.load(name, gcode + '\n' + dwell, null, context);
if (!ok) {
callback(new Error(`Invalid G-code: name=${name}`));
return;
Expand Down
Loading

0 comments on commit 81d859b

Please sign in to comment.