Giter Site home page Giter Site logo

scottmudge / octoprint-meatpack Goto Github PK

View Code? Open in Web Editor NEW
121.0 9.0 6.0 223 KB

Easy, fast, effective, and automatic g-code compression!

Home Page: https://github.com/scottmudge/OctoPrint-MeatPack

License: BSD 4-Clause "Original" or "Old" License

Python 79.82% JavaScript 17.04% Jinja 3.14%
prusa-firmware octoprint serial printer-firmwares prusa-mk3 marlin-firmware marlinfw

octoprint-meatpack's Introduction

# OctoPrint-MeatPack

Getting to the meat of g-code. Easy, fast, effective, and automatic g-code compression! MeatPack nearly doubles the effective data rate of a standard 115,200 baud-rate serial connection to 210,000 baud!

Firmware with MeatPack Support:

  • Marlin (merged Jan. 25, 2021)
  • Prusa MK2/3/3S+ - Merged/compatible as of version 3.13.0 (July 27, 2023). Please download the latest firmware here.

OctoPrint Support:

Should be compatible with any OctoPrint installation providing access to the serial_factory_hook(). According to the API documentation, this was intoruced 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.

Arc Welder Compatibility:

Because MeatPack works on a different principle than Arc Welder, it is possible to combine MeatPack with the Arc Welder: Anti-Stutter OctoPrint plugin to further compress gcode. It's as simple as installing and enabling both plugins, and to allow Arc Welder to preprocess your gcode files before starting a print.

With both plugins combined, I was able to compress a 5 MB gcode file of a cylinder (best-case scenario for Arc Welder) to 500 kB, a 10x reduction in size!

If using a Prusa MK3, I also recommend creating a local fork of the MeatPack MK3 firmware (linked above), and merging in FormalLurker's MK3 fork, which improves the quality and efficiency of the arc motion-planning feature of the MK3 firmware.

Current Features (v1.5.22)

  1. Fully working g-code compression ("MeatPack") support for compatible printer firmwares. Both Marlin and the official Prusa MK2/3/3S+ firmwares now officially support MeatPack. See the Firmware section above for which versions/build dates are compatible.

  2. Added extra data to the "State" side-bar content, updated in real time. It shows transmission statistics: image

    • "Packed Tx" - This is the actual amount of data sent over the serial connection. The data that has been packed.
    • "Total Tx" - This is the effective amount of data sent over the serial connection, after it is unpacked on the other end. Should be close to the original (though OctoPrint often adds error checking data to lines of g-code, so it will be a bit higher).
    • "Comp. Ratio" - This is the compression ratio, bascially a measure of how much bandwidth you are gaining/saving. It's the factor by which the data has been effectively shrunk.
    • "TX Rate" - This is a measure of how much data is being sent over the serial connection per second (average). Updated every ~2 seconds.
    • "Packing State"-- Lets you know if MeatPack compression is enabled or not.

    NOTE: This extra text section can be disabled in the plugin options page.

  3. A feature called "Whitespace Removal", which strips away all unnecessary whitespace from outgoing gcode on the serial port. This also allows the 'E' character to be packed in place of the ' ' space character. This effectively boosts the compression ratio down to 0.55!

  4. Added an optional feature (can be enabled in plugin settings) to play a "meatball" song on the printer after a print is completed. See the bottom of the readme why everything is "meat" themed.

Installation

UPDATE: OctoPrint has approved this plugin for the official plugin repository, so it should be available to install via the in-built plugin manager now. If you'd still rather manually install it, please follow the instructions below.

  1. Install via the OctoPrint plugin manager.

-OR-

  1. Open a terminal or console (or SSH into your Raspberry Pi if using one) and activate OctoPrint's virtual environment (Python). Typically this will be in ~/oprint/. You can activate the virtual environment by using the following command:

source ~/oprint/bin/activate

  1. After activating the OctoPrint environment, run the following command:

pip install https://github.com/scottmudge/OctoPrint-MeatPack/archive/v1.5.22.zip

  1. Restart your OctoPrint server, or restart the machine.

  2. After installation, you should see a "MeatPrint" options page, and a new "TX Statistics" section in the "State" side bar section (if connected to your printer).

Known Limitations:

  • It doesn't work with the Virtual Printer in OctoPrint. Obviously... it's not a real serial connection.

Why compress/pack G-Code? What is this?

It's been often reported that using OctoPrint's serial interface can often cause performance bottlenecks for printer firmware. Many popular printers (e.g., Prusa's MK3) are limited to ~115200 baud. For many simple prints, this works fine. But for prints with numerous, small, or quickly-traversed curves, this can pose a problem.

In g-code, these many small curves are broken down into very short line-segments. These line segments are each described as cartesian points, for instance:

...
G1 X125.824 Y95.261 E0.00907
G1 X125.496 Y95.249 E0.01145
G1 X123.181 Y92.934 E0.11420
...

All this text might describe only a couple hundred microns of travel. When printing at higher speeds, you can see how much text actually needs to be transferred over the serial connection.

This can cause stuttering or other issues while printing, leading to sub-par print quality.

There have been a few attempts to get around this problem in the past. One example, Arc Welder, replaces these linear line segments with close-approximate arc equivalents (radians + radius). This does solve the problem of reducing g-code size, but not all printer firmwares are compatible with these arc-type g-codes, and it is left up to the printer firmware to linearize these arcs back into cartesian line segments. Not all firmwares do this well, and often the firmware CPU can be bogged down with this costly computation.

So what does MeatPack do?

MeatPack takes a different approach. Instead of modifying the g-code or replacing commands, it insteads uses a more efficient way of transferring the data from PC/Host to Firmware.

G-code at its core is a fairly simple language, which uses a restricted alphabet. There are only a few characters which are actually being used to represent a vast majority of g-code -- numbers, decimal point, a few letters ('G', 'M', 'E', etc.), and other utilitiy characters (newline, space, etc.).

I performed a basic histographic analysis of about a dozen g-code files, and found that ~93% of all g-code uses the same 15 characters! And yet we are using characters sized to fit a potential 256-character alphabet!

So what MeatPack does is get to the meat of the g-code! At its core, MeatPack is dynamically packing 2 characters into a single 8-bits/1-byte, effectively doubling data density. Using a lookup table, MeatPack is able to represent any character from the list of the 15-most-common found in g-code with only 4-bits.

Why only 15-most common if 4-bits allows 16 possible characters? Well I also needed a way to send full-width characters in the event that any character does not fall into the list of the 15-most common. So the 16th permutation (0b1111) is used as a flag to tell the unpacker that it should expect a full-width character at some point.

MeatPack also provides for a rudimentary communication/control layer by using a special character (0xFF) sent in a specific sequence. 0XFF is virtually never found naturally in g-code, so it is can be considered a reserved character.

How does it work?

Here is an example. Take the following "G1" command.

G1 X113.214 Y91.45 E1.3154

Unpacked, it is sent as distinct bytes (B):

(G) (1) ( ) (X) (1) (1) (3) (.) (2) (1) (4) ( ) (Y) (9) (1) (.) (4) (5) ( ) (E) (1) (.) (3) (1) (5) (4) (\n)

In total, 27 bytes.

It is effectively packed as the following -- note that parenthetical groups (XX) indicate that the contents are packed as a single byte:

(G1) ( X) (11) (3.) (21) (4 ) (9#)* (Y) (1.) (45) (# )* (E) (1.) (31) (54) (\n)

or with "Whitespace Removal" active:

(G1) (X1) (13) (.2) (14) (9#) (Y) (1.) (45) (E1) (.3) (15) (4\n)

* these bytes don't show character order, but bit order. Higher order bits on left, lower order bits on right. See below. The other characters are sequential and only show how they are paired in bytes.

So 16 bytes in this example (13 bytes with Whitespace Removal active). This is on-par or better than binary packing. With whitespace removal active, the packed command is less than half the size of the original command.

The packer reorders some characters if the full width character is surrounded by packable characters. The # here is a flag (0b1111) which tells the unpacker where the following full width character should go.

In this way, 4 bits aren't wasted telling the packer that only one full width character is coming up. 0xFF (0b11111111) tells the unpacker that the next 2 bytes are full width.

If 0b1111 is in the lower 4 bits, the full width character is immediately following, and the packed character in the upper 4 bits goes after the full width character. If it's in the higher 4 bits, the full width character goes after the character packed in the lower 4 bits. And if both upper and lower 4 bits are set to 1111, the next 2 characters are full width.

This minor reordering is undone in the unpacking stage in the firmware. A little more complex, but it allows slightly more data to be packed.

This is also why the command sequence is 2 0xFF bytes in a row, followed by a command byte. If packing is enabled, 0xFF means the next character is some standard ASCII character (or at the very least not 0xFF), so 2 0xFF bytes in a row would never occur naturally except in these control/command sequences. And if packing is disabled, 0xFF is an invalid g-code character (the Prusa firmware even discards all bytes higher than 127U). This command signal preamble can be increased to 3 or more 0xFF bytes if some firmwares tend to have these bytes in error more frequently. But from what I've seen, it's generally 0x0 or null bytes which are received or sent in error. For instance, in noisy or unshielded connections.

Why "Meat"?

My cat's name is Meatball, I thought it sounded fun.

Obligatory cat photo:

photo

License

MeatPack is licensed under 4-Clause BSD:

Copyright (c) 2023 Scott Mudge. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

  3. All advertising materials mentioning features or use of this software must display the following acknowledgement: This product includes software developed by the organization.

  4. Neither the name of the copyright holder nor the names the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY COPYRIGHT HOLDER "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDER BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

octoprint-meatpack's People

Contributors

cp2004 avatar scottmudge avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

octoprint-meatpack's Issues

Javascript console errors during loading

I'm not having any issues with Meatpack so far, but I noticed that it always throws some errors when loading:
image

I'm not sure if that affects performance or the functioning anyhow.

Can't connect to printer with Marlin built after 25/01/2021

Hi! I'm using the firmware from the Marlin Firmware Service, built on 26/01/2021 on my Ender3v2 with BLTouch. (The service builtds the the bugfix-2.0 branch daily)

After installing MeatPack, connection attempts to my printer fail. This issue can be fixed by disabling MeatPack.
As far as I understand (based on the readme), this should work, although I couldn't find the merged PR.

I suspect that this is due to the compression not being compatible with the firmware. Hopefully it's temporary, just wanted to let you know that others might be encountering the same issue.

Thanks for the plugin!

BSD 4-clause is GPL-incomatible

Spurred by prusa3d/libbgcode#24 I wanted to open an issue here and notify you that the change from AGPL to BSD 4-clause unfortunately introduced an incompatibility with GPL-code, as outlined by the FSF here: https://www.gnu.org/licenses/license-list.html#OriginalBSD

FSF themselves recommends using eg. Apache 2.0 instead or the MIT / X11 / Expat license.

On top of that there's nowadays the Blue Oak License that aims to bring the best of the best from all of them (the result of a work of evaluating most permissive licenses and ranking them)

Related change: dd8776e

Error Marlin\src\feature\meatpack.cpp:48:1: error: stray '@' in program compiling Marlin2

I've tried to compile adding a
#define MEATPACK
command line into config.h and adding meatpack.h and meatpack.cpp into the src/features folder but i get this error.
It seems that PlatformIO doen't like @
maybe it's a stupid question but i don't know how to fix it (attention newbie onlne!)
meatpack.h and .cpp was merely capied and paste into new files into the folder mentioned above.

RFC2217 & raw TCP connections don't work with MeatPack

Octoprint 1.8.7 with MeatPack connecting to raw TCP socket://192.168.1.200:5000 - fails with:

2023-04-07 19:44:14,663 - octoprint.util.comm - ERROR - Unexpected error while connecting to serial port socket://192.168.1.200:5000, baudrate 115200 from hook meatpack: SerialException: '[Errno 2] could not open port socket://192.168.1.200:5000: [Errno 2] No such file or directory: 'socket://192.168.1.200:5000'' @ comm.py:_open_serial:3832
Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/serial/serialposix.py", line 322, in open
    self.fd = os.open(self.portstr, os.O_RDWR | os.O_NOCTTY | os.O_NONBLOCK)
FileNotFoundError: [Errno 2] No such file or directory: 'socket://192.168.1.200:5000'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/octoprint/util/comm.py", line 3832, in _open_serial
    serial_obj = factory(
  File "/usr/lib/python3.10/site-packages/octoprint/util/__init__.py", line 1688, in wrapper
    return f(*args, **kwargs)
  File "/usr/lib/python3.10/site-packages/OctoPrint_MeatPack/__init__.py", line 64, in serial_factory_hook
    self._serial_obj.open()
  File "/usr/lib/python3.10/site-packages/serial/serialposix.py", line 325, in open
    raise SerialException(msg.errno, "could not open port {}: {}".format(self._port, msg))

Same issue in vanilla Octoprint was solved in plugin OctoPrint-Network-Printing
The fix could be to open ports named like :// with serial.serial_for_url() instead of serial.open() in serial_factory_hook.

Anyone would benefit from this improvement?
Low prio for me now - BufferBuddy helped me enough with latency issues.

Jan

No settings or TX statistics

The title says it all. MeatPack shows up as an installed plugin, but there is no options page nor statistics visible in the web interface. I've installed the plugin twice and rebooted the Pi and printer. What could have gone wrong here? Anyone else with the same issue?

System info:

  • Raspberry Pi Zero W Rev 1.1
  • Prusa MK3S with MeatPack-firmware 3.9.3
  • Octoprint version 1.5.2
  • MeatPack 1.2.11

Suggestion / Comment: Pre-process files rather than compressing on the fly

While reading the description of this plugin, one thing that occurred to me is that this plugin is directly in the path for every serial send (unless I misunderstood). While the compression itself may take very little CPU, having something else "in the way" could be the source of problems (see DisplayLayerProgress's github for issues about layers shift as an example of something that gets called often potentially being a problem). Some folks have a lot of things running on their RPi, and it's not exactly a real time OS.

Instead of processing the g-code stream live, you could do it beforehand, similar to how ArcWelder does it. With ArcWelder, the output file can overwrite the original, or just create a new file.

[Enhancement] Dynamic size display adjustment

Hi! I have some code you might be able to use to improve the UI display a tiny bit. Check out this code to adjust the units (b, kB, MB, GB, etc..) based on the supplied size in bytes and precision. If it's not something you want/need, that's fine, but I thought you might be interested.

Anyway, I like your plugin, and am hoping your PR gets accepted. If you can't get it into the prusa code, I think you should try the Marlin github. Seems like a no brainer.

Windows binary like ArcWelder.

I use ArcWelder binary in Simplify3d to process the gcode generated by the slicer.
Is there a way to have that feature with Meatpack?
Thankyou so much for your time!

Specification

it might be worthwhile to write down the specification of the format, as it's being used by e.g. prusa's binary gcode format

can't connect to ender 3 v2 with meatpack plugin installed

I'm running octoprint Version 1.5.3 on octopi Version 0.17.0, running on Raspberry Pi 4 Model B Rev 1.2. When I install meatpack 1.5.14 I can't connect to the printer via USB anymore. I have tried disabling the gcode compression and whitespace options. I've also tried with a marlin firmware version from https://marlin.crc.id.au/firmware/Ender%203%20V2%20-%20v4.2.7%20Board%20-%20BLTouch/ .. If I use the previous version without meatpack or the new version with meatpack both have the same problem. If the plugin is installed for meatpack I can't connect to the printer. If I remove the plugin I can connect to the printer just fine. I'm connecting to /ttyUSB0 @ 115200 with no problem. RIght now I removed the plugin and using the EEPROM editor plugin for octoprint I can see the meatpack option is set to true (and was false on the previous version) .. I'll submit this and make sure I clean up the plugin (I had tried installing 1.5.9 earlier and it wasn't working.. I tried again and it installed 1.5.14 but I didn't do a fresh install.. I'll try that.)

MeatPack with Causes 175% cpu usage and crashes octoprint/serial during PID tuning

This makes the PID "fail" as you never get the terminal output values so you can put them into eeprom.

Some times octo recovers and unfreezes, but you miss the pid info as the terminal doesn't output during the high cpu usage.

With meatpack disabled PID works fine CPU never goes above 8% usage @800mhz total. Meatpack on as you can see below its CPU flogged up to 175% cpu on a single thread @1.2GHz cores.

image

When Octoprint does manage to recover the Webui is responsive but the terminal stops accepting commands/gcode so the Octoprint service has to be restarted

Not sure if its the plugin or octo but its sure giving me grief.

As a side note Printing with Meatpack on is flawless, its only when PID tuning.

here is the example of my PID tune command.

M303 C25 E-1 S60 U

Octoprint Sent to SD Card not working

I'm using the latest octoprint with meat pack plugin.

When uploading a file to sd card to my ender3v2 the resulting file contains a bunch of j

Please see attached for the meatpacked file on sd card:
CUBEAW.GCO.meatpack.txt

Is this normal? While it is upload, I do see all the lines being sent through the terminal fine. But looks like the control board doesn't uncompressed and save if to the sd card correctly.

Optimization: Simplify decimal numbers

I was looking into ways of packing better and think I've found two that would require no firmware changes.

  1. Remove the leading 0 in decimal numbers less than 1. For example 0.123 => .123.
    strtod still parses this fine so no firmware changes should be required (have not tested this). In a sample 35MB .gcode file I tried, it saved about 2% and brought output size ratio from 49.6% (MeatPack with whitespace omit) to 47.7%, because the extruder step is almost always less than 1, so it can remove a character from most G1 lines.
  2. Remove trailing 0s in decimal numbers. Remove decimals entirely if all 0s. For example: 0.120 => 0.12, 1.00 => 1
    Less common, but it brought the output size down to 46.8%

So overall 2.8% additional packing with (in theory) no firmware changes. Not bad?

If you think this is worth pursuing I could send you a PR. Or feel free to take the suggestions and implement :-)

Longest command byte count

Since this plugin effectively reduces the per-line byte count, it would be useful to figure out how many bytes are required to hold the longest possible valid compressed Gcode command; that way receive buffers can be sized appropriately on the printer. e.g. marlin's MAX_CMD_SIZE

[Bug] Print fails to start

Everything has been going along perfectly. Merrily printing along using both Arc Welder and MeatPack, which between the two give me over 70%-90% compression of data going over the serial port, and has virtually eliminated zits, blobs, and stutters, even at 250mm/sec during a self-designed torture test.

Now, I ran into a file that won't start printing after being converted by Arc Welder. It loads, converts, saves, will load in OP as the active file (conversion by Arc Welder, that is), but clicking on "Print" causes it to do the first step of printing (heating, then the Dashboard changes to show the Gcode % and layer % of "0," the terminal shows "Printing..") but the head never moves and no print ever actually starts. After removing the AW header and the M117 Layer Indicator lines and doing a compare on the files shows no difference up to the point where the actual printing code starts. Attempting to print the unconverted file works fine. Disabling Meatpack allows the ArcWelded file to print fine.

I've attached the raw file and the converted file. Unfortunately, I can't attach a serial log for the time(s) it would not print when MeatPack was enabled, because by the time I turned on Serial logging, I had disabled MP and the print started fine, and I don't want to cancel it at this time.

image

Archive.zip

Error Loading MeatPack plugin

Hello - having issues trying to load the MeatPack Plugin into OctoPrint after installing via terminal approach, per the documentation provided. I am using a Raspberry Pi Zero W, and my printer is a Prusa i3 MK3S.

I am able to successfully instal the plugin, but after rebooting OctoPrint I am receiving the following errors:

2021-01-26 16:32:07,610 - octoprint.plugin.core - ERROR - Error loading plugin meatpack File "/home/pi/oprint/local/lib/python2.7/site-packages/OctoPrint_MeatPack/__init__.py", line 10, in <module> from OctoPrint_MeatPack.packing_serial import PackingSerial File "/home/pi/oprint/local/lib/python2.7/site-packages/OctoPrint_MeatPack/packing_serial.py", line 24
Thanks for your help.

Keeps disconecting during prints

It couldn't connect to the printer at first but after manually setting the port and the baudrate now I can connect to it, but it keeps disconnecting from time to time also during prints...

OctoPrint unable to connect to printer when plug-in is enabled

I have an Ender 3 Pro with SKR BTT Mini E3 v1.2, OctoPi v0.18 (RPi-4) fully up to date, MeatPack plug-in v 1.5.21. My fork of Marlin can be found here https://github.com/Taomyn/Marlin

Compiled latest bugfix as I found tonight including enabling MeatPack.

When enabled OctoPrint will not connect to the printer, disable it and OctoPrint is working fine. Some log data below, let me know if I can provide anything else.

Excerpt from OctoPrint log:

2021-01-28 20:03:25,462 - octoprint.util.comm - INFO - Changing monitoring state from "Offline" to "Detecting serial connection"
2021-01-28 20:03:25,482 - octoprint.util.comm - INFO - Serial detection: Performing autodetection with 2 port/baudrate candidates: /dev/ttyACM0@250000, /dev/ttyS0@250000
2021-01-28 20:03:25,482 - octoprint.util.comm - INFO - Serial detection: Trying port /dev/ttyACM0, baudrate 250000
2021-01-28 20:03:25,483 - octoprint.plugins.meatpack - INFO - [Serial]: Cannot query packing state -- port not open.
2021-01-28 20:03:25,484 - octoprint.plugins.meatpack - INFO - [Serial]: Cannot query packing state -- port not open.
2021-01-28 20:03:25,507 - octoprint.util.comm - INFO - Serial detection: Handshake attempt #1 with timeout 2.0s
2021-01-28 20:03:25,511 - octoprint.util.comm - INFO - M110 detected, setting current line number to 0
2021-01-28 20:03:27,721 - octoprint.util.comm - INFO - Serial detection: Handshake attempt #2 with timeout 2.0s
2021-01-28 20:03:27,726 - octoprint.util.comm - INFO - M110 detected, setting current line number to 0
2021-01-28 20:03:29,753 - octoprint.util.comm - INFO - Serial detection: Handshake attempt #3 with timeout 2.0s
2021-01-28 20:03:29,757 - octoprint.util.comm - INFO - M110 detected, setting current line number to 0
2021-01-28 20:03:32,753 - octoprint.util.comm - INFO - Serial detection: Trying port /dev/ttyS0, baudrate 250000
2021-01-28 20:03:32,763 - octoprint.util.comm - ERROR - Unexpected error while connecting to serial port /dev/ttyS0, baudrate 250000 from hook meatpack: SerialException: 'Could not configure port: (5, 'Input/output error')' @ comm.py:_open_serial:3670
Traceback (most recent call last):
  File "/home/pi/oprint/lib/python3.7/site-packages/serial/serialposix.py", line 398, in _reconfigure_port
    orig_attr = termios.tcgetattr(self.fd)
termios.error: (5, 'Input/output error')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/pi/oprint/lib/python3.7/site-packages/octoprint/util/comm.py", line 3670, in _open_serial
    settings().getFloat(["serial", "timeout", "connection"]),
  File "/home/pi/oprint/lib/python3.7/site-packages/octoprint/util/__init__.py", line 1890, in wrapper
    return f(*args, **kwargs)
  File "/home/pi/oprint/lib/python3.7/site-packages/OctoPrint_MeatPack/__init__.py", line 52, in serial_factory_hook
    self._serial_obj.port = str(port)
  File "/home/pi/oprint/lib/python3.7/site-packages/serial/serialutil.py", line 276, in port
    self.open()
  File "/home/pi/oprint/lib/python3.7/site-packages/serial/serialposix.py", line 332, in open
    self._reconfigure_port(force_update=True)
  File "/home/pi/oprint/lib/python3.7/site-packages/serial/serialposix.py", line 401, in _reconfigure_port
    raise SerialException("Could not configure port: {}".format(msg))
serial.serialutil.SerialException: Could not configure port: (5, 'Input/output error')
2021-01-28 20:03:32,802 - octoprint.util.comm - INFO - Serial detection: Could not open port /dev/ttyS0, baudrate 250000, skipping
2021-01-28 20:03:32,802 - octoprint.util.comm - INFO - Changing monitoring state from "Detecting serial connection" to "Error: No more candidates to test, and no working port/baudrate combination detected."
2021-01-28 20:03:32,804 - octoprint.util.comm - INFO - Changing monitoring state from "Error: No more candidates to test, and no working port/baudrate combination detected." to "Offline (Error: No more candidates to test, and no working port/baudrate combination detected.)"
2021-01-28 20:03:32,811 - octoprint.plugins.printoid - INFO - //// Send alert to Printoid: 'printer-error' with value Error: No more candidates to test, and no working port/baudrate combination detected. (mydomain)
2021-01-28 20:03:33,180 - octoprint.plugins.printoid - INFO - //// Send alert to Printoid: 'printer-error' with value Error: No more candidates to test, and no working port/baudrate combination detected. (mydomain)

Serial.log - failing

2021-01-28 20:02:47,456 - serial.log is currently not enabled, you can enable it via Settings > Serial Connection > Log communication to serial.log
2021-01-28 20:03:25,445 - serial.log is currently not enabled, you can enable it via Settings > Serial Connection > Log communication to serial.log
2021-01-28 20:08:08,102 - serial.log is currently not enabled, you can enable it via Settings > Serial Connection > Log communication to serial.log
2021-01-28 20:10:42,155 - Enabling serial logging
2021-01-28 20:10:52,495 - Changing monitoring state from "Offline" to "Detecting serial connection"
2021-01-28 20:10:52,531 - Performing autodetection with 2 port/baudrate candidates: /dev/ttyACM0@250000, /dev/ttyS0@250000
2021-01-28 20:10:52,531 - Trying port /dev/ttyACM0, baudrate 250000
2021-01-28 20:10:52,549 - Handshake attempt #1 with timeout 2.0s
2021-01-28 20:10:52,552 - Connected to: PackingSerial<id=0xa8c07a70, open=True>(port='/dev/ttyACM0', baudrate=250000, bytesize=8, parity='N', stopbits=1, timeout=2.0, xonxoff=False, rtscts=False, dsrdtr=False), starting monitor
2021-01-28 20:10:52,554 - Send: N0 M110 N0*125
2021-01-28 20:10:53,141 - Recv: Not SD printing
2021-01-28 20:10:54,132 - Recv:  T:21.87 /0.00 B:34.17 /0.00 @:0 B@:0
2021-01-28 20:10:54,142 - Recv: Not SD printing
2021-01-28 20:10:55,143 - Recv: Not SD printing
2021-01-28 20:10:55,144 - Handshake attempt #2 with timeout 2.0s
2021-01-28 20:10:55,157 - Send: N0 M110 N0*125
2021-01-28 20:10:56,131 - Recv:  T:20.94 /0.00 B:34.17 /0.00 @:0 B@:0
2021-01-28 20:10:56,142 - Recv: Not SD printing
2021-01-28 20:10:57,142 - Recv: Not SD printing
2021-01-28 20:10:58,131 - Recv:  T:21.25 /0.00 B:34.14 /0.00 @:0 B@:0
2021-01-28 20:10:58,139 - Handshake attempt #3 with timeout 2.0s
2021-01-28 20:10:58,147 - Send: N0 M110 N0*125
2021-01-28 20:10:58,150 - Recv: Not SD printing
2021-01-28 20:10:59,143 - Recv: Not SD printing
2021-01-28 20:11:00,131 - Recv:  T:21.41 /0.00 B:34.17 /0.00 @:0 B@:0
2021-01-28 20:11:00,143 - Recv: Not SD printing
2021-01-28 20:11:00,145 - Trying port /dev/ttyS0, baudrate 250000
2021-01-28 20:11:00,156 - Unexpected error while connecting to serial port /dev/ttyS0, baudrate 250000 from hook meatpack: SerialException: 'Could not configure port: (5, 'Input/output error')' @ comm.py:_open_serial:3670
2021-01-28 20:11:00,192 - Could not open port /dev/ttyS0, baudrate 250000, skipping
2021-01-28 20:11:00,193 - Changing monitoring state from "Detecting serial connection" to "Error: No more candidates to test, and no working port/baudrate combination detected."
2021-01-28 20:11:00,194 - Changing monitoring state from "Error: No more candidates to test, and no working port/baudrate combination detected." to "Offline (Error: No more candidates to test, and no working port/baudrate combination detected.)"
2021-01-28 20:11:00,195 - Connection closed, closing down monitor
2021-01-28 20:11:07,075 - Disabling serial logging

Serial.log - working

2021-01-28 20:22:37,140 - Changing monitoring state from "Offline" to "Detecting serial connection"
2021-01-28 20:22:37,760 - Performing autodetection with 2 port/baudrate candidates: /dev/ttyACM0@250000, /dev/ttyS0@250000
2021-01-28 20:22:37,761 - Trying port /dev/ttyACM0, baudrate 250000
2021-01-28 20:22:37,762 - Connecting to port /dev/ttyACM0, baudrate 250000
2021-01-28 20:22:37,868 - Handshake attempt #1 with timeout 2.0s
2021-01-28 20:22:37,893 - Connected to: Serial<id=0xa8b76910, open=True>(port='/dev/ttyACM0', baudrate=250000, bytesize=8, parity='N', stopbits=1, timeout=2.0, xonxoff=False, rtscts=False, dsrdtr=False), starting monitor
2021-01-28 20:22:37,895 - Send: N0 M110 N0*125
2021-01-28 20:22:37,931 - Recv: ok WNÂ…0g P31 B31
2021-01-28 20:22:37,978 - Changing monitoring state from "Detecting serial connection" to "Operational"
2021-01-28 20:22:38,036 - Send: N0 M110 N0*125
2021-01-28 20:22:38,116 - Recv: ok WNÂ…0g P31 B31
2021-01-28 20:22:38,118 - Send: N1 M115*39
2021-01-28 20:22:38,155 - Recv: FIRMWARE_NAME:Marlin v2.0.x (Jan 28 2021 19:53:47) SOURCE_CODE_URL:github.com/MarlinFirmware/Marlin PROTOCOL_VERSION:1.0 MACHINE_TYPE:Ender-3 Pro EXTRUDER_COUNT:1 UUID:

Checksum errors when using Remove All Whitespace ("G" Commands Only)

When this option is enabled, the checksum for commands fails - I believe because the spaces have been removed, the checksums need to be updated to reflect this.

Built with:

#define MEATPACK
#define MEATPACK_LOOKUP_TABLE

Octoprint terminal log:

Changing monitoring state from "Operational" to "Starting"
Send: N0 M110 N0*125
Recv: ok N0 P15 B3
Send: N1 G28 O*125
[...]
Printer seems to support the busy protocol, will adjust timeouts and set busy interval accordingly
[...]
Recv: X:151.00 Y:115.00 Z:11.80 E:0.00 Count X:12080 Y:9200 Z:4720
Recv: ok N1 P15 B3
Send: N2 M113 S2*99
Recv: ok N2 P15 B3
Send: N3 G29 O*126
[...]
Recv: Bilinear Leveling Grid:
Recv:       0      1      2      3      4
Recv:  0 +0.082 +0.075 +0.053 +0.058 +0.058
Recv:  1 +0.025 +0.048 +0.020 +0.013 +0.030
Recv:  2 +0.028 +0.025 +0.020 +0.005 +0.023
Recv:  3 +0.038 +0.035 +0.020 +0.015 +0.028
Recv:  4 +0.055 +0.055 +0.045 +0.035 +0.045
Recv: 
Recv: X:220.00 Y:220.00 Z:11.80 E:0.00 Count X:17600 Y:17600 Z:4720
Recv: ok N3 P15 B3
Send: N4 M500*34
[...]
Recv: ok N4 P15 B3
Send: N5 M420 S1*98
Recv: echo:Bed Leveling ON
Recv: echo:Fade Height 10.00
Recv: ok N5 P15 B3
Changing monitoring state from "Starting" to "Printing"
Send: N6 M201 X500 Y500 Z100 E5000*12
[...]
Recv: Error:checksum mismatch, Last Line: 5
Recv: Resend: 6
Recv: ok N2 P15 B4
Send: N6 M201 X500 Y500 Z100 E5000*12
Recv: Error:checksum mismatch, Last Line: 5
Recv: Resend: 6
Recv: ok N2 P15 B4
Send: N6 M201 X500 Y500 Z100 E5000*12
Recv: Error:checksum mismatch, Last Line: 5
Recv: Resend: 6
Recv: ok N2 P15 B4
Send: N6 M201 X500 Y500 Z100 E5000*12
Recv: Error:checksum mismatch, Last Line: 5
Recv: Resend: 6
Recv: ok N2 P15 B4
Send: N6 M201 X500 Y500 Z100 E5000*12
Recv: Error:checksum mismatch, Last Line: 5
Recv: Resend: 6
Recv: ok N2 P15 B4
Send: N6 M201 X500 Y500 Z100 E5000*12
Recv: Error:checksum mismatch, Last Line: 5
Recv: Resend: 6
Recv: ok N2 P15 B4
Send: N6 M201 X500 Y500 Z100 E5000*12
Recv: Error:checksum mismatch, Last Line: 5
Recv: Resend: 6
Recv: ok N2 P15 B4
Send: N6 M201 X500 Y500 Z100 E5000*12
Recv: Error:checksum mismatch, Last Line: 5
Recv: Resend: 6
Recv: ok N2 P15 B4
Send: N6 M201 X500 Y500 Z100 E5000*12
Recv: Error:checksum mismatch, Last Line: 5
Recv: Resend: 6
Recv: ok N2 P15 B4
Send: N6 M201 X500 Y500 Z100 E5000*12
Recv: Error:checksum mismatch, Last Line: 5
Recv: Resend: 6
Recv: ok N2 P15 B4
Send: N6 M201 X500 Y500 Z100 E5000*12
Recv: Error:checksum mismatch, Last Line: 5
Recv: Resend: 6
Printer keeps requesting line 6 again and again, communication stuck
Changing monitoring state from "Printing" to "Error: Printer keeps requesting line 6 again and again, communication stuck"
Send: M112
Send: N7 M112*38
Send: N8 M104 T0 S0*41
Send: N9 M140 S0*108
Changing monitoring state from "Error: Printer keeps requesting line 6 again and again, communication stuck" to "Offline (Error: Printer keeps requesting line 6 again and again, communication stuck)"
Connection closed, closing down monitor
Closing down send loop

Javascript/console errors

I see a lot of these:

packed_core.js?2d5b3bfb:1186 Error calling onStartup on view model MeatPackViewModel : TypeError: Cannot set properties of null (setting 'innerHTML')
    at MeatPackViewModel.self.updateAllText (http://localhost:5000/static/webassets/packed_plugins.js?34f3337b:6779:88)
    at MeatPackViewModel.self.onStartup.self.onUserLoggedIn (http://localhost:5000/static/webassets/packed_plugins.js?34f3337b:6765:26)
    at callViewModelIf (http://localhost:5000/static/webassets/packed_core.js?2d5b3bfb:1185:126)
    at http://localhost:5000/static/webassets/packed_core.js?2d5b3bfb:1179:138
    at Pn (http://localhost:5000/static/webassets/packed_libs.js?1fe9f29c:30:530)
    at Function.<anonymous> (http://localhost:5000/static/webassets/packed_libs.js?1fe9f29c:51:66)
    at callViewModelsIf (http://localhost:5000/static/webassets/packed_core.js?2d5b3bfb:1179:95)
    at callViewModels (http://localhost:5000/static/webassets/packed_core.js?2d5b3bfb:1178:56)
    at fetchSettings (http://localhost:5000/static/webassets/packed_core.js?2d5b3bfb:1252:282)
    at sentryWrapped (http://localhost:5000/static/webassets/packed_core.js?2d5b3bfb:630:45619)

It's this line: https://github.com/scottmudge/OctoPrint-MeatPack/blob/master/OctoPrint_MeatPack/static/js/meatpack.js#L150
I think you need to move the updates of the UI into the onAllBound

packed_core.js?2d5b3bfb:1248 Could not bind view model MeatPackViewModel to target #meatpack_total_tx_string : Error: You cannot apply bindings multiple times to the same element.
    at p (http://localhost:5000/static/webassets/packed_libs.js?1fe9f29c:131:3221)
    at k (http://localhost:5000/static/webassets/packed_libs.js?1fe9f29c:131:2747)
    at Object.a.vc (http://localhost:5000/static/webassets/packed_libs.js?1fe9f29c:132:3231)
    at http://localhost:5000/static/webassets/packed_core.js?2d5b3bfb:1247:8
    at Pn (http://localhost:5000/static/webassets/packed_libs.js?1fe9f29c:30:530)
    at Function.<anonymous> (http://localhost:5000/static/webassets/packed_libs.js?1fe9f29c:51:66)
    at http://localhost:5000/static/webassets/packed_core.js?2d5b3bfb:1242:26
    at Pn (http://localhost:5000/static/webassets/packed_libs.js?1fe9f29c:30:530)
    at Function.<anonymous> (http://localhost:5000/static/webassets/packed_libs.js?1fe9f29c:51:66)
    at bindViewModels (http://localhost:5000/static/webassets/packed_core.js?2d5b3bfb:1233:106)
    at sentryWrapped (http://localhost:5000/static/webassets/packed_core.js?2d5b3bfb:630:45619)

Not sure about this one

Phantom printing

Hi,

This might come from a misconfiguration somewhere but I'm running out of options.
Flashed my Sidewinder X1 with Meatpack enabled, the flashing process went OK I think

When printing without Meatpack enable din Octoprint, everything is good.
When I enable Meatpack in Octoprint, the print seems to start in octoprint but the printer itself stay still.
I disabled Arc Wielder as there seems to be a compatibility issues between it and Meatpack but it changed nothing.

Slicing in Cura or Prusa neither changes the issue.

The strange thing is that you can see in Octoprint the layer move, the virtual LCD tells you what should happen in the correct order, the GCODE viewer moves and progress, but the TX Statistics stays at 0 and don't move...

Would that mean something is wrong in my firmware flashing ? How can I check that ?

Best regards

J.

Move MeatPack stats into a sidebar tab

Meatpack is awesome, thanks for developing the plugin! It's made a huge difference for my printer.

I'd like to suggest using the approach that BufferBuddy uses to display information in the sidebar. Instead of adding lines to the State tab, it creates it own tab containing it's connection information. I like being able to keep an eye on MeatPack, but it seems sorta out-of-place where it's currently sitting between two blocks of print information.

Here's the tab that BufferBuddy adds to the sidebar.

image

image

Thanks for your consideration!

VIRTUAL printer broken after installing MeatPack plugin

MeatPack overrides serial port opening (could it not do that?) which causes Virtual Printer (available by default in any OctoPrint installation) to be broken:

2023-04-18 07:57:53,271 - octoprint.util.comm - ERROR - Unexpected error while connecting to serial port VIRTUAL, baudrate 115200 from hook meatpack: SerialException: '[Errno 2] could not open port VIRTUAL: [Errno 2] No such file or directory: 'VIRTUAL'' @ comm.py:_open_serial:3916
Traceback (most recent call last):
  File "..../OctoPrint/venv/share/python3.10/site-packages/serial/serialposix.py", line 322, in open
    self.fd = os.open(self.portstr, os.O_RDWR | os.O_NOCTTY | os.O_NONBLOCK)
FileNotFoundError: [Errno 2] No such file or directory: 'VIRTUAL'

Illustration Suggestion

Could you possibly please give a few examples of before and after gcodes? It's faster to understand what you are doing by just seeing the direct result than by tryna read code to understand what is happening. Picture's worth a thousand words as they say.

possible issue with M0 in octoprint and meatpack

i did some testing and it seems that when using mwatpack in octoprint, I can't use the m0 command properly. I end up being stuck in a wait loop and need to restart my printer manually, since I don't have an LCD. disabling meatpack solved the issue, so I guess it is the culprit

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.