Skip to content

Commit

Permalink
Version 1.5.18
Browse files Browse the repository at this point in the history
Fix whitespace removal, restricted to "G" commands only.
  • Loading branch information
scottmudge committed Jan 27, 2021
1 parent 33ffe40 commit 477d7f2
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 25 deletions.
45 changes: 23 additions & 22 deletions OctoPrint_MeatPack/meatpack.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,33 +113,34 @@ def get_command_bytes(command):

# -------------------------------------------------------------------------------
def _unified_method(line):
# If it's an "M" command, leave it unchanged.
m_idx = line.find('M')
# If it's an "G" command, then remove whitespace.
m_idx = line.find('G')
if m_idx >= 0:
# check to see if the "G" has a number after.
if 48 <= ord(line[m_idx + 1]) <= 57:
return line

# Fix case capitalization for relevant letters (only packable ones)
# It's faster to chain them together like this then make a
# separate assignment/call to replace.
if MeatPackOmitWhitespaces:
line = line.replace('e', 'E').replace('x', 'X').replace('g', 'G')
else:
line = line.replace('x', 'X').replace('g', 'G')
# Fix case capitalization for relevant letters (only packable ones)
# It's faster to chain them together like this then make a
# separate assignment/call to replace.
if MeatPackOmitWhitespaces:
line = line.replace('e', 'E').replace('x', 'X').replace('g', 'G')
else:
line = line.replace('x', 'X').replace('g', 'G')

# Strip whitespace
stripped = line.replace(' ', '')
# Strip whitespace
stripped = line.replace(' ', '')

# Check for asterisk, meaning there is a checksum we need to recompute after
# stripping whitespace out
if '*' in line:
checksum = 0
stripped = stripped.partition('*')[0]
for i, v in enumerate(stripped):
checksum ^= ord(v)
return stripped + "*" + str(checksum) + "\n"
# Check for asterisk, meaning there is a checksum we need to recompute after
# stripping whitespace out
if '*' in line:
checksum = 0
stripped = stripped.partition('*')[0]
for i, v in enumerate(stripped):
checksum ^= ord(v)
return stripped + "*" + str(checksum) + "\n"

return stripped
return stripped
else:
return line


# -------------------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ Getting to the **meat** of g-code. Easy, fast, effective, and automatic g-code c

## OctoPrint Support:

Should be compatible with any OctoPrint installation providing access to the `serial_factory_hook()`. According to the API documentation, this wasintoruced in OctoPrint version 1.2. As far as Python is concerned, version 1.5.17 should be compatible back to 2.7, but it is **highly** recommended to update to Python 3 if you have not yet done so.
Should be compatible with any OctoPrint installation providing access to the `serial_factory_hook()`. According to the API documentation, this wasintoruced in OctoPrint version 1.2. As far as Python is concerned, as of MeatPack version 1.5.17, it should be compatible back to 2.7, but it is **highly** recommended to update to Python 3 if you have not yet done so.

## Current Features (v1.5.17)
## Current Features (v1.5.18)

1. Fully working g-code compression ("MeatPack") support for compatible printer firmwares. Marlin FW now officially supprots MeatPack, but **[NOTE]** until **Prusa** approves these changes, please find builds of the official Prusa Firmware with compression support here: https://github.com/scottmudge/Prusa-Firmware-MeatPack
2. Added extra data to the "State" side-bar content, updated in real time. It shows transmission statistics:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
plugin_name = "OctoPrint-MeatPack"

# The plugin's version. Can be overwritten within OctoPrint's internal data via __plugin_version__ in the plugin module
plugin_version = "1.5.17"
plugin_version = "1.5.18"

# The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin
# module
Expand Down

0 comments on commit 477d7f2

Please sign in to comment.