Skip to content

Commit

Permalink
Implemented @foosel's suggestions + made the blacklist settings actua…
Browse files Browse the repository at this point in the history
…lly work [OctoPrint#1026]
  • Loading branch information
pbackx committed Oct 25, 2017
1 parent 1233eea commit d54d268
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
8 changes: 5 additions & 3 deletions src/octoprint/static/js/app/viewmodels/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,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 @@ -778,7 +779,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 Expand Up @@ -832,7 +834,7 @@ $(function() {

self.sawUpdateEventWhileSending = false;
self.sending(data == undefined || options.sending || false);

if (data == undefined) {
// we also only send data that actually changed when no data is specified
data = getOnlyChangedData(self.getLocalData(), self.lastReceivedSettings);
Expand Down
6 changes: 5 additions & 1 deletion src/octoprint/static/js/app/viewmodels/terminal.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ $(function() {
self.updateFilterRegex();
});

self.blacklist=[];
self.settings.serial_autoUppercaseBlacklist.subscribe(function(newValue) {
self.blacklist = splitTextToArray(newValue, ",", true);
});

self._reenableFancyTimer = undefined;
self._reenableUnfancyTimer = undefined;
self._disableFancy = function(difference) {
Expand Down Expand Up @@ -308,7 +313,6 @@ $(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){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@
<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>
<span class="help-inline">{{ _('Use this to specify the commands that should not be automatically uppercased. Comma seperated list.') }}</span>
</div>
</div>
<div class="controls">
Expand Down
1 change: 0 additions & 1 deletion src/octoprint/util/comm.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,6 @@ 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 d54d268

Please sign in to comment.