Auto uppercase Gcode except commands in configurable blacklist

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)
This commit is contained in:
Ishwar Agarwal 2016-04-30 05:32:53 +02:00 committed by Gina Häußge
parent 2fcbf49348
commit 51406b7c42
8 changed files with 29 additions and 5 deletions

View file

@ -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)

View file

@ -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

View file

@ -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"]),
@ -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"])

View file

@ -111,6 +111,7 @@ default_settings = {
"disconnectOnErrors": True,
"ignoreErrorsFromFirmware": False,
"logResends": True,
"autoUppercaseBlacklist": ["M117"],
"supportResendsWithoutOk": False,
"logPositionOnPause": True,
"logPositionOnCancel": True,

View file

@ -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);
@ -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() {
@ -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: {

View file

@ -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) {

View file

@ -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>

View file

@ -420,6 +420,7 @@ class MachineCom(object):
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()