Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

octoprint/util/comm.py: make line number detection more robust #300

Closed
wants to merge 1 commit into from

Conversation

Projects
None yet
2 participants
@srwalter
Copy link

commented Nov 2, 2013

When the printer requests a resend, we have to determine which line
number it wants. The old logic would be confused if there was more
than one number in the line. Some version of Teacup firmware
request a resend with the format "rs N25 Expected checksum 109".
The new logic detects this format correctly.

octoprint/util/comm.py: make line number detection more robust
When the printer requests a resend, we have to determine which line
number it wants.  The old logic would be confused if there was more
than one number in the line.  Some version of Teacup firmware
request a resend with the format "rs N25 Expected checksum 109".
The new logic detects this format correctly.
@foosel

This comment has been minimized.

Copy link
Owner

commented Nov 4, 2013

I see the problem. However, the better approach would probably be to use a regex based approach (the original line is way too complicated as well). I'll have to test whether this works:

resendRegex = re.compile("(rs\s+|Resend):?\s*N?(\d+).*")
...
def _handleResendRequest(self, line):
  lineToResend = None
  match = resendRegex.match(line)
  if match is not None:
    lineToResend = int(match.group(2))
  ...

Might be a while though, the day job is getting a bit time consuming right now. Or would you like to try?

@bqhook bqhook force-pushed the foosel:devel branch from 4296b49 to 95f084f Aug 31, 2014

@foosel foosel force-pushed the foosel:devel branch from 8d64665 to ff96e2e Nov 3, 2014

foosel added a commit that referenced this pull request Mar 9, 2017

More solid parsing of line number from resends
Matches:

  * Resend:23
  * Resend:N23
  * Resend:N:23
  * rs 23
  * rs N23
  * rs N:23
  * rs N23 Expected checksum 109

Based on issue reported via PR #300
@foosel

This comment has been minimized.

Copy link
Owner

commented Mar 9, 2017

Mentioned regex based approach implemented in the above commit.

@foosel foosel closed this Mar 9, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.