Skip to content

Fix Gcode serial _reports() #27794

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

Merged

Conversation

classicrocker883
Copy link
Contributor

@classicrocker883 classicrocker883 commented Apr 13, 2025

Description

Fix Gcode GcodeSuite:: _report() functions to align.
M503 gives a list of features and parameters. Some aren't inline like the others, this aims to fix that to be more uniform.

  • Before:
echo: ; Fixed-Time Motion:
echo:   M493 S0 A25.00 B30.00 D0 F0.00 H0.00 P0 K0.00
echo: ; Nonlinear Extrusion:
  M592 A0.00 B0.00 C1.00
echo: ; Input Shaping:
echo:   M593 X F25.00 D0.30
echo:   M593 Y F30.00 D0.25
echo: ; Hotend Idle Timeout:
  M86 B0 E0 S360 T180
echo: ; Linear Advance:
echo:   M900 K0.00
  • After:
echo: ; Fixed-Time Motion:
echo:   M493 S0 A25.00 B30.00 D0 F0.00 H0.00 P0 K0.00
echo: ; Nonlinear Extrusion:
echo:   M592 A0.00 B0.00 C1.00
echo: ; Input Shaping:
echo:   M593 X F25.00 D0.30
echo:   M593 Y F30.00 D0.25
echo: ; Hotend Idle Timeout:
echo:   M86 B0 E0 S360 T180
echo: ; Linear Advance:
echo:   M900 K0.00

Requirements

Benefits

Configurations

Related Issues

@thinkyhead
Copy link
Member

After 2.1.3 we'll investigate an alternative to all the SERIAL_ECHO rigamarole and just redirect printf to our custom serial classes.

Here's the basic trick…

int serial1_putchar(char c, FILE* stream) {
  Serial1.write(c);
  return 0;
}

FILE serial1_stdout;

void setup() {
  Serial1.begin(115200);
  fdev_setup_stream(&serial1_stdout, serial1_putchar, NULL, _FDEV_SETUP_WRITE);
  stdout = &serial1_stdout;

  printf("This goes to Serial1\n");
}

@thinkyhead thinkyhead merged commit f149e14 into MarlinFirmware:bugfix-2.1.x Apr 15, 2025
66 checks passed
@classicrocker883
Copy link
Contributor Author

Just like a typical arduino, makes sense

@thinkyhead
Copy link
Member

Just like a typical arduino, makes sense

Indeed. This would have been a great first step in the creation of Marlin, or Grbl, or Sprinter…. but it was not known by me or other contributors that reprogramming printf was possible, largely because all the Arduino documentation is written for beginners and just uses serial write directly.

We will have some special needs with our serial ports, such as sending a single printf to multiple outputs, but the conversion to printf will also allow us to specify a particular output port if we only want to use one of them.

The refactor presumes that this will end up being more memory-efficient, and we are less concerned about whether it makes printing a tiny bit slower since the main loop has a lot of leeway.

@classicrocker883
Copy link
Contributor Author

so if it it uses less memory, but prints slower, then would increasing the buffer kind of cancel that out?

EvilGremlin pushed a commit to EvilGremlin/Marlin that referenced this pull request May 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants