Skip to content

Commit

Permalink
Auto uppercase Gcode except commands in configurable blacklist
Browse files Browse the repository at this point in the history
Added new config setting: auto uppercase blacklist that is configurable
in the advanced option of the serial tab, with M117 included in the
default settings of the blacklist. Changed the sendCommand method in the
TerminalViewModel to auto uppercase the entire gcode command except when
gcode is in the blacklist. Updated documentation to include the default
auto uppercase blacklist command M117.

Resolves: #1026

(cherry picked from commit dbf7af1)
  • Loading branch information
agarwali authored and foosel committed Nov 3, 2017
1 parent 2fcbf49 commit 51406b7
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 5 deletions.
5 changes: 3 additions & 2 deletions AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,11 @@ date of first contribution):
* [Siim Raud](https://github.com/2ndalpha)
* ["geoporalis"](https://github.com/geoporalis)
* [Andrew Malota](https://github.com/2bitoperations)
* [Alexander Leisentritt](https://github.com/Alex9779)
* [therealbstern](https://github.com/therealbstern)
* [Ishwar Agarwal](https://github.com/agarwali)
* [Kye Hoover](https://github.com/eykrevooh)
* [Joseph Carrick](https://github.com/carricktel)
* [Alexander Leisentritt](https://github.com/Alex9779)
* [therealbstern](https://github.com/therealbstern)
* [Philipp Baum](https://github.com/philphilphil)
* [Kyle Evans](https://github.com/kevans91)
* [Javier Martínez Arrieta](https://github.com/Javierma)
Expand Down
7 changes: 6 additions & 1 deletion docs/configuration/config_yaml.rst
Original file line number Diff line number Diff line change
Expand Up @@ -855,7 +855,12 @@ Use the following settings to configure the serial connection to the printer:
# Command to send in order to initiate a handshake with the printer.
# Defaults to "M110 N0" which simply resets the line numbers in the firmware and which
# should be acknowledged with a simple "ok".
helloCommand: M110 N0
helloCommand:
- M110 N0
# Commands that should never be auto-uppercased when sent to the printer. Defaults to only M117.
autoUppercaseBlacklist:
- M117
# Whether to disconnect on errors or not
disconnectOnErrors: true
Expand Down
2 changes: 2 additions & 0 deletions src/octoprint/server/api/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ def getSettings():
"ignoreErrorsFromFirmware": s.getBoolean(["serial", "ignoreErrorsFromFirmware"]),
"disconnectOnErrors": s.getBoolean(["serial", "disconnectOnErrors"]),
"triggerOkForM29": s.getBoolean(["serial", "triggerOkForM29"]),
"autoUppercaseBlacklist": s.get(["serial", "autoUppercaseBlacklist"]),
"logPositionOnPause": s.getBoolean(["serial", "logPositionOnPause"]),
"logPositionOnCancel": s.getBoolean(["serial", "logPositionOnCancel"]),
"supportResendsWithoutOk": s.getBoolean(["serial", "supportResendsWithoutOk"]),
Expand Down Expand Up @@ -377,6 +378,7 @@ def _saveSettings(data):
if "ignoreErrorsFromFirmware" in data["serial"]: s.setBoolean(["serial", "ignoreErrorsFromFirmware"], data["serial"]["ignoreErrorsFromFirmware"])
if "disconnectOnErrors" in data["serial"]: s.setBoolean(["serial", "disconnectOnErrors"], data["serial"]["disconnectOnErrors"])
if "triggerOkForM29" in data["serial"]: s.setBoolean(["serial", "triggerOkForM29"], data["serial"]["triggerOkForM29"])
if "autoUppercaseBlacklist" in data["serial"] and isinstance(data["serial"]["autoUppercaseBlacklist"], (list, tuple)): s.set(["serial", "autoUppercaseBlacklist"], data["serial"]["autoUppercaseBlacklist"])
if "supportResendsWithoutOk" in data["serial"]: s.setBoolean(["serial", "supportResendsWithoutOk"], data["serial"]["supportResendsWithoutOk"])
if "logPositionOnPause" in data["serial"]: s.setBoolean(["serial", "logPositionOnPause"], data["serial"]["logPositionOnPause"])
if "logPositionOnCancel" in data["serial"]: s.setBoolean(["serial", "logPositionOnCancel"], data["serial"]["logPositionOnCancel"])
Expand Down
1 change: 1 addition & 0 deletions src/octoprint/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ def settings(init=False, basedir=None, configfile=None):
"disconnectOnErrors": True,
"ignoreErrorsFromFirmware": False,
"logResends": True,
"autoUppercaseBlacklist": ["M117"],
"supportResendsWithoutOk": False,
"logPositionOnPause": True,
"logPositionOnCancel": True,
Expand Down
7 changes: 5 additions & 2 deletions src/octoprint/static/js/app/viewmodels/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ $(function() {
self.serial_ignoreErrorsFromFirmware = ko.observable(undefined);
self.serial_disconnectOnErrors = ko.observable(undefined);
self.serial_triggerOkForM29 = ko.observable(undefined);
self.serial_autoUppercaseBlacklist = ko.observable(undefined);
self.serial_supportResendsWithoutOk = ko.observable(undefined);
self.serial_logPositionOnPause = ko.observable(undefined);
self.serial_logPositionOnCancel = ko.observable(undefined);
Expand Down Expand Up @@ -670,7 +671,8 @@ $(function() {
additionalPorts : function() { return commentableLinesToArray(self.serial_additionalPorts()) },
additionalBaudrates: function() { return _.map(splitTextToArray(self.serial_additionalBaudrates(), ",", true, function(item) { return !isNaN(parseInt(item)); }), function(item) { return parseInt(item); }) },
longRunningCommands: function() { return splitTextToArray(self.serial_longRunningCommands(), ",", true) },
checksumRequiringCommands: function() { return splitTextToArray(self.serial_checksumRequiringCommands(), ",", true) }
checksumRequiringCommands: function() { return splitTextToArray(self.serial_checksumRequiringCommands(), ",", true) },
autoUppercaseBlacklist: function() { return splitTextToArray(self.serial_autoUppercaseBlacklist(), ",", true) },
},
scripts: {
gcode: function() {
Expand Down Expand Up @@ -781,7 +783,8 @@ $(function() {
additionalPorts : function(value) { self.serial_additionalPorts(value.join("\n"))},
additionalBaudrates: function(value) { self.serial_additionalBaudrates(value.join(", "))},
longRunningCommands: function(value) { self.serial_longRunningCommands(value.join(", "))},
checksumRequiringCommands: function(value) { self.serial_checksumRequiringCommands(value.join(", "))}
checksumRequiringCommands: function(value) { self.serial_checksumRequiringCommands(value.join(", "))},
autoUppercaseBlacklist: function(value) { self.serial_autoUppercaseBlacklist(value.join(", "))}
},
terminalFilters: function(value) { self.terminalFilters($.extend(true, [], value)) },
temperature: {
Expand Down
4 changes: 4 additions & 0 deletions src/octoprint/static/js/app/viewmodels/terminal.js
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,12 @@ $(function() {

var re = /^([gmt][0-9]+)(\s.*)?/;
var commandMatch = command.match(re);
self.blacklist = splitTextToArray(self.settings.serial_autoUppercaseBlacklist(), ",", true);
if (commandMatch != null) {
command = commandMatch[1].toUpperCase() + ((commandMatch[2] !== undefined) ? commandMatch[2] : "");
if (self.blacklist.indexOf(commandMatch[1].toUpperCase()) < 0){
command = command.toUpperCase()
}
}

if (command) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,13 @@
<span class="help-inline">{{ _('Use this to specify which commands <strong>always</strong> need to be sent with a checksum. Comma separated list.') }}</span>
</div>
</div>
<div class="control-group" title="{{ _('Commands to not completely auto-uppercase ') }}">
<label class="control-label" for="settings-serialAutoUppercaseBlacklist">{{ _('Auto Uppercase Blacklist') }}</label>
<div class="controls">
<input type="text" class="input-block-level" id="settings-serialAutoUppercaseBlacklist" data-bind="value: serial_autoUppercaseBlacklist">
<span class="help-inline">{{ _('Use this to specify the commands that should not be automatically uppercased') }}</span>
</div>
</div>
<div class="controls">
<label class="checkbox">
<input type="checkbox" data-bind="checked: serial_triggerOkForM29" id="settings-triggerOkForM29"> {{ _('Generate additional <code>ok</code> for <code>M29</code>') }} <span class="label">{{ _('Most Marlin < v1.1.0') }}</span>
Expand Down
1 change: 1 addition & 0 deletions src/octoprint/util/comm.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@ def __init__(self, port = None, baudrate=None, callbackObject=None, printerProfi

self._long_running_commands = settings().get(["serial", "longRunningCommands"])
self._checksum_requiring_commands = settings().get(["serial", "checksumRequiringCommands"])
self._auto_uppercase_blacklist = settings().get(["serial", "autoUppercaseBlacklist"])

self._clear_to_send = CountedEvent(max=10, name="comm.clear_to_send")
self._send_queue = SendQueue()
Expand Down

0 comments on commit 51406b7

Please sign in to comment.