Repository navigation
Conversation
Add two Printer Settings options to speed up the serial connection, both off by default and applied on the next connection. Each only takes effect if the firmware supports it. MeatPack compresses G-code on the wire. Advanced OK uses the planner and command buffer space reported in Marlin's ok replies to send more than one line at a time, limited so the firmware's receive buffer can't overflow. A dot left of the send box shows which of the two are active, and a new meatpack command queries the firmware's state. Closes kliment#1143
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds two options that speed up the serial connection to the printer. Both are under Printer Settings, off by default, and take effect on the next connection. They work separately or together, and each only applies if the firmware supports it.
Closes #1143.
MeatPack
MeatPack packs two characters from a 15 character alphabet into one byte, so G-code takes fewer bytes on the connection.
printcoresendsM115once online and only starts packing if the firmware reportsCap:MEATPACK:1.G0toG3before the checksum is worked out. Other commands keep theirs, since they may carry text. Moves uploaded to SD are stored without spaces.M108,M112,M410andM876are sent unpacked, because Marlin's emergency parser reads the serial data before it is unpacked.startline from the firmware returns the host to plain text and negotiates again.printrun/meatpack.py.Advanced OK
Printrun normally sends one line and waits for its
ok. With this option on, and on serial connections only, it sends ahead while earlier lines are still being handled, using the queue space reported by Marlin'sADVANCED_OK(ok N12 P15 B3).B.B + 1lines are outstanding, using the highestBseen, since Marlin reportsBwhile still holding the line it just finished.okwith a line number also covers earlier lines, so a lostokcorrects itself. After 30 s of silence, Printrun assumes one was lost.oklines with these fields no longer fill the console.Showing the state
meatpackcommand shows the host's state and asks the firmware for its own.printcore: newmeatpackandadvancedokcallbacks and events.Testing
Tested at 250000 baud on Marlin
bugfix-2.1.xwith the defaultBUFSIZE 4, on an MKS TinyBee (ESP32) and on a RAMPS 1.4 (ATmega2560) with aREPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLERand its SD card.Uploading to SD, a 290047 line PrusaSlicer file. Stock used firmware with neither feature, and each other row used firmware with what it needs:
Every upload finished with no errors and the expected file size. After each row, a second uploaded file was run from SD and ended at the expected position.
Printing, 3000 lines with E moves at 100 mm/s and 0.4 mm per line, so at most 250 lines per second, with firmware that has both features. Every row ended at the expected X, Y and E:
On both boards, in all four combinations, each with the expected result:
Resend: 200, recovered, correct end positionM105every second during a printM410with the emergency parser, during a long moveOther checks:
ADVANCED_OK, TinyBeeBUFSIZE 16, TinyBeeoklines in the consoleM118with spaces and punctuation, with MeatPack, TinyBeeM112during a 20 s dwell, both options, RAMPSmeatpackcommand, idle and mid-print, TinyBeeON NSP, andOFF ESPwith the option offtests/test_meatpack.pyandtests/test_advanced_ok.pyare new. They check packed lines against a Python copy of Marlin's decoder, and both features against a mocked printer, including a firmware restart, which was not run on hardware. All tests intests/pass.AI disclosure
Full disclosure: I don't know your policy on AI, so please treat this PR accordingly.
AI used: Claude Opus 5.5 (Anthropic), via Claude Code. It wrote the code and this description, and ran the tests above on @ellensp's board. @ellensp requested these features, directed the work and verified the result.