Fix failure on commands ending on whitespace #75
Loading…
Reference in New Issue
No description provided.
Delete Branch "esavkin/thermostat:63-fix-pid-error"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Probably worth implementing proper command checker.
Closes #63
Shouldn't this be fixed on the firmware side instead to make writing clients (or manual use) easier?
I think it's better to keep both soulutions, since it is also covered by tests now:
Fix client fail on commands ending on whitespaceto Fix failure on commands ending on whitespace@ -555,0 +565,4 @@
assert_eq!(command, command_w);
command
}};
}
Testing once for a command that ends with withespace is enough.
No, before this change different commands had different reaction on ending whitespace(s)
@ -24,3 +24,3 @@
def _command(self, *command):
self._socket.sendall((" ".join(command) + "\n").encode('utf-8'))
self._socket.sendall(((" ".join(command)).strip() + "\n").encode('utf-8'))
If the firmware accepts whitespace at the end this is unnecessary. Remove.
@ -537,0 +535,4 @@
postfilter,
value(Ok(Command::Dfu), tag("dfu")),
))(input)?;
let (input, _) = end(input)?;
Does this still work with two whitespace characters at the end?
And please add an explanation in code comments.
Yes, as shown in test cases, it accepts multiple whitespaces
081b461e31
to7d2be841c2
@ -555,0 +558,4 @@
extern crate format_bytes;
use format_bytes::format_bytes;
macro_rules! check_ending_whitespace {
This makes it sound like it only checks something about whitespace, and says nothing about parsing and returning the result.
I think it is better now
7d2be841c2
tod566cca7e0
@ -555,0 +558,4 @@
extern crate format_bytes;
use format_bytes::format_bytes;
macro_rules! parse_with_trailing_whitespaces {
Still misleading. Makes it sound like it all it does is add whitespaces and then parse.
parse_with_trailing_whitespaces_and_check_equality?
I think 7 words is too much, and still it is a bit confusing
parse_chkwhitespace or similar
d566cca7e0
to34a38b5ae9
@ -555,0 +558,4 @@
extern crate format_bytes;
use format_bytes::format_bytes;
macro_rules! parse_chkwhitespace {
I remain unconvinced that checking every command and every command plus whitespace is necessary. Just like the code only deals with the trailing whitespace in only one place and not separately for every command.
I suggest adding just one test that parses one or a few commands and then the same with various whitespaces at the end.
Also helps keep each test doing only one thing.
Before this PR, there was an indiscriminative difference between each command, so for some of the commands this test would pass, while other commands would be obviously wrong. And leaving this test only for one command would not guarantee other's commands would work. So this is why I would like to check every command - this will also help to prevent further regresions.
Moreover, these tests do not cost much of the resources.
Why is that?
This is not my impression from a quick read of the parsing code.
Some commands have trailing-whitespace handling initially, some - don't. So probably it worths removing these in commands that have it
Right, then a pass of cleanup sounds appropriate.
34a38b5ae9
to7015538b43
Step 1:
From your project repository, check out a new branch and test the changes.Step 2:
Merge the changes and update on Gitea.