Skip to content

Improve text gcode PNG streaming#5140

Open
dunkmann00 wants to merge 5 commits intoprusa3d:masterfrom
dunkmann00:prusalink-plaintext-icon-2
Open

Improve text gcode PNG streaming#5140
dunkmann00 wants to merge 5 commits intoprusa3d:masterfrom
dunkmann00:prusalink-plaintext-icon-2

Conversation

@dunkmann00
Copy link

This PR replaces #3954, my previous attempt at solving this issue.

This PR aims to implement a more efficient means of reading a plain text gcode file for the PNG image data. The current approach will iterate through MAX_SEARCH_LINES (which is set to 2048) of lines at the start of the gcode file. Since the png image is placed at the end of the image section by Prusaslicer with the default profiles, sometimes the start of a valid image is after that max search length. This results in nothing getting returned when queried by Prusalink (and maybe Prusaconnect, still haven't tried it 😅) even though it does exist in the gcode file.

With this PR, the following happens:

  1. Search for the beginning line of an image, similar to now.*
  2. If the image satisfies the request, success, return the same as is done now.
  3. If not, since the byte size of the image is known, calculate how many bytes of text that is and skip ahead by that amount. Jumping forward like this eliminates the need to parse each and every line of an image.
  4. Repeat

*The difference with this approach is it isn't necessary to cap the search at a max number of lines, it can be capped at a max number of lines since the beginning line of an image has been found.

I know the team is probably very busy and this is a low priority. I just periodically return to this issue whenever I'm printing something and the thumbnail shows me that question mark. This time I had an idea I thought was an improvement of the more simple approach in the original PR so I figured I'd try it out. In some way this may even be slightly more efficient than the current approach!

Whether this is approved or not, or even reviewed or not, still love my Prusa printer and thanks for all the hard work!

@dunkmann00 dunkmann00 changed the title Improve regular gcode PNG streaming Improve text gcode PNG streaming Feb 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant