diff --git a/Marlin/src/feature/ethernet.cpp b/Marlin/src/feature/ethernet.cpp index 9b022b4e17..cdf176f832 100644 --- a/Marlin/src/feature/ethernet.cpp +++ b/Marlin/src/feature/ethernet.cpp @@ -172,4 +172,46 @@ void MarlinEthernet::check() { } } +void say_ethernet() { SERIAL_ECHOPGM(" Ethernet "); } + +void MarlinEthernet::ETH0_report(const bool forReplay/*=true*/) { + say_ethernet(); + SERIAL_ECHO_TERNARY(ethernet.hardware_enabled, "port ", "en", "dis", "abled.\n"); + if (ethernet.hardware_enabled) { + say_ethernet(); + SERIAL_ECHO_TERNARY(ethernet.have_telnet_client, "client ", "en", "dis", "abled.\n"); + } + else + SERIAL_ECHOLNPGM("Send 'M552 S1' to enable."); +} + +void MarlinEthernet::MAC_report(const bool forReplay/*=true*/) { + if (!forReplay) SERIAL_ECHO_START(); + SERIAL_ECHOPGM("MAC: "); + if (ethernet.hardware_enabled) { + uint8_t mac[6]; + Ethernet.MACAddress(mac); + for (uint8_t i = 0; i < 6; ++i) { + if (mac[i] < 0x10) SERIAL_CHAR('0'); + SERIAL_PRINT(mac[i], PrintBase::Hex); + if (i < 5) SERIAL_CHAR(':'); + } + } + else + SERIAL_ECHOPGM("Disabled"); + SERIAL_EOL(); +} + +// Display current values when the link is active, +// otherwise show the stored values +void MarlinEthernet::ip_report(const uint16_t cmd, FSTR_P const post, const IPAddress &ipo, const bool forReplay/*=true*/) { + if (!forReplay) SERIAL_ECHO_START(); + SERIAL_ECHO(F(" M"), cmd, C(' ')); + for (uint8_t i = 0; i < 4; ++i) { + SERIAL_ECHO(ipo[i]); + if (i < 3) SERIAL_CHAR('.'); + } + SERIAL_ECHOLN(F(" ; "), post); +} + #endif // HAS_ETHERNET diff --git a/Marlin/src/feature/ethernet.h b/Marlin/src/feature/ethernet.h index 70a58efce7..7aa364fc3c 100644 --- a/Marlin/src/feature/ethernet.h +++ b/Marlin/src/feature/ethernet.h @@ -25,6 +25,8 @@ #include #endif +#include "../HAL/shared/Marduino.h" + // Teensy 4.1 uses internal MAC Address class MarlinEthernet { @@ -34,6 +36,10 @@ class MarlinEthernet { static EthernetClient telnetClient; static void init(); static void check(); + + static void ETH0_report(const bool forReplay=true); + static void MAC_report(const bool forReplay=true); + static void ip_report(const uint16_t cmd, FSTR_P const post, const IPAddress &ipo, const bool forReplay=true); }; extern MarlinEthernet ethernet; diff --git a/Marlin/src/gcode/config/M200-M205.cpp b/Marlin/src/gcode/config/M200-M205.cpp index a0466fbeab..a55813aeae 100644 --- a/Marlin/src/gcode/config/M200-M205.cpp +++ b/Marlin/src/gcode/config/M200-M205.cpp @@ -78,10 +78,10 @@ TERN_(MARLIN_SMALL_BUILD, return); if (!forReplay) { - report_heading(forReplay, F(STR_FILAMENT_SETTINGS), false); + report_heading(false, F(STR_FILAMENT_SETTINGS), false); if (!parser.volumetric_enabled) SERIAL_ECHOPGM(" (Disabled):"); SERIAL_EOL(); - report_echo_start(forReplay); + report_echo_start(false); } #if EXTRUDERS == 1 @@ -231,7 +231,7 @@ void GcodeSuite::M203_report(const bool forReplay/*=true*/) { #if ENABLED(DISTINCT_E_FACTORS) for (uint8_t i = 0; i < E_STEPPERS; ++i) { - if (!forReplay) SERIAL_ECHO_START(); + report_echo_start(forReplay); SERIAL_ECHOLNPGM_P( PSTR(" M203 T"), i , SP_E_STR, VOLUMETRIC_UNIT(planner.settings.max_feedrate_mm_s[E_AXIS_N(i)]) diff --git a/Marlin/src/gcode/feature/network/M552-M554.cpp b/Marlin/src/gcode/feature/network/M552-M554.cpp index 9a09a973c8..fc965fc3bd 100644 --- a/Marlin/src/gcode/feature/network/M552-M554.cpp +++ b/Marlin/src/gcode/feature/network/M552-M554.cpp @@ -28,44 +28,6 @@ #include "../../../core/serial.h" #include "../../gcode.h" -void say_ethernet() { SERIAL_ECHOPGM(" Ethernet "); } - -void ETH0_report() { - say_ethernet(); - SERIAL_ECHO_TERNARY(ethernet.hardware_enabled, "port ", "en", "dis", "abled.\n"); - if (ethernet.hardware_enabled) { - say_ethernet(); - SERIAL_ECHO_TERNARY(ethernet.have_telnet_client, "client ", "en", "dis", "abled.\n"); - } - else - SERIAL_ECHOLNPGM("Send 'M552 S1' to enable."); -} - -void MAC_report() { - uint8_t mac[6]; - if (ethernet.hardware_enabled) { - Ethernet.MACAddress(mac); - SERIAL_ECHOPGM(" MAC: "); - for (uint8_t i = 0; i < 6; ++i) { - if (mac[i] < 16) SERIAL_CHAR('0'); - SERIAL_PRINT(mac[i], PrintBase::Hex); - if (i < 5) SERIAL_CHAR(':'); - } - } - SERIAL_EOL(); -} - -// Display current values when the link is active, -// otherwise show the stored values -void ip_report(const uint16_t cmd, FSTR_P const post, const IPAddress &ipo) { - SERIAL_CHAR('M'); SERIAL_ECHO(cmd); SERIAL_CHAR(' '); - for (uint8_t i = 0; i < 4; ++i) { - SERIAL_ECHO(ipo[i]); - if (i < 3) SERIAL_CHAR('.'); - } - SERIAL_ECHOLN(F(" ; "), post); -} - /** * M552: Set IP address, enable/disable network interface * @@ -92,13 +54,13 @@ void GcodeSuite::M552() { } } const bool nopar = !seenS && !seenP; - if (nopar || seenS) ETH0_report(); + if (nopar || seenS) ethernet.ETH0_report(); if (nopar || seenP) M552_report(); } -void GcodeSuite::M552_report() { +void GcodeSuite::M552_report(const bool forReplay/*=true*/) { TERN_(MARLIN_SMALL_BUILD, return); - ip_report(552, F("ip address"), Ethernet.linkStatus() == LinkON ? Ethernet.localIP() : ethernet.ip); + ethernet.ip_report(552, F("ip address"), Ethernet.linkStatus() == LinkON ? Ethernet.localIP() : ethernet.ip, forReplay); } /** @@ -111,9 +73,9 @@ void GcodeSuite::M553() { M553_report(); } -void GcodeSuite::M553_report() { +void GcodeSuite::M553_report(const bool forReplay/*=true*/) { TERN_(MARLIN_SMALL_BUILD, return); - ip_report(553, F("subnet mask"), Ethernet.linkStatus() == LinkON ? Ethernet.subnetMask() : ethernet.subnet); + ethernet.ip_report(553, F("subnet mask"), Ethernet.linkStatus() == LinkON ? Ethernet.subnetMask() : ethernet.subnet, forReplay); } /** @@ -126,9 +88,9 @@ void GcodeSuite::M554() { M554_report(); } -void GcodeSuite::M554_report() { +void GcodeSuite::M554_report(const bool forReplay/*=true*/) { TERN_(MARLIN_SMALL_BUILD, return); - ip_report(554, F("gateway"), Ethernet.linkStatus() == LinkON ? Ethernet.gatewayIP() : ethernet.gateway); + ethernet.ip_report(554, F("gateway"), Ethernet.linkStatus() == LinkON ? Ethernet.gatewayIP() : ethernet.gateway, forReplay); } #endif // HAS_ETHERNET diff --git a/Marlin/src/gcode/feature/nonlinear/M592.cpp b/Marlin/src/gcode/feature/nonlinear/M592.cpp index 2fc02133ec..77a6258ddc 100644 --- a/Marlin/src/gcode/feature/nonlinear/M592.cpp +++ b/Marlin/src/gcode/feature/nonlinear/M592.cpp @@ -29,7 +29,7 @@ void GcodeSuite::M592_report(const bool forReplay/*=true*/) { TERN_(MARLIN_SMALL_BUILD, return); - report_heading(forReplay, F(STR_NONLINEAR_EXTRUSION)); + report_heading_etc(forReplay, F(STR_NONLINEAR_EXTRUSION)); SERIAL_ECHOLNPGM(" M592 A", stepper.ne.A, " B", stepper.ne.B, " C", stepper.ne.C); } diff --git a/Marlin/src/gcode/feature/pause/M603.cpp b/Marlin/src/gcode/feature/pause/M603.cpp index fcc042f58e..fd8a779ae0 100644 --- a/Marlin/src/gcode/feature/pause/M603.cpp +++ b/Marlin/src/gcode/feature/pause/M603.cpp @@ -64,7 +64,6 @@ void GcodeSuite::M603_report(const bool forReplay/*=true*/) { TERN_(MARLIN_SMALL_BUILD, return); report_heading(forReplay, F(STR_FILAMENT_LOAD_UNLOAD)); - #if EXTRUDERS == 1 report_echo_start(forReplay); SERIAL_ECHOPGM(" M603 L", LINEAR_UNIT(fc_settings[0].load_length), " U", LINEAR_UNIT(fc_settings[0].unload_length), " ;"); diff --git a/Marlin/src/gcode/feature/trinamic/M569.cpp b/Marlin/src/gcode/feature/trinamic/M569.cpp index 06a4992ceb..99bbf6ed35 100644 --- a/Marlin/src/gcode/feature/trinamic/M569.cpp +++ b/Marlin/src/gcode/feature/trinamic/M569.cpp @@ -160,7 +160,7 @@ void GcodeSuite::M569_report(const bool forReplay/*=true*/) { report_heading(forReplay, F(STR_DRIVER_STEPPING_MODE)); auto say_M569 = [](const bool forReplay, FSTR_P const etc=nullptr, const bool eol=false) { - if (!forReplay) SERIAL_ECHO_START(); + report_echo_start(forReplay); SERIAL_ECHOPGM(" M569 S1"); if (etc) SERIAL_ECHO(C(' '), etc); if (eol) SERIAL_EOL(); diff --git a/Marlin/src/gcode/gcode.h b/Marlin/src/gcode/gcode.h index 911820ee7b..706a7387db 100644 --- a/Marlin/src/gcode/gcode.h +++ b/Marlin/src/gcode/gcode.h @@ -1137,11 +1137,11 @@ private: #if HAS_ETHERNET static void M552(); - static void M552_report(); + static void M552_report(const bool forReplay=true); static void M553(); - static void M553_report(); + static void M553_report(const bool forReplay=true); static void M554(); - static void M554_report(); + static void M554_report(const bool forReplay=true); #endif #if HAS_STEALTHCHOP diff --git a/Marlin/src/gcode/probe/M423.cpp b/Marlin/src/gcode/probe/M423.cpp index 7ab887eb64..17941d64f3 100644 --- a/Marlin/src/gcode/probe/M423.cpp +++ b/Marlin/src/gcode/probe/M423.cpp @@ -88,10 +88,11 @@ void GcodeSuite::M423() { void GcodeSuite::M423_report(const bool forReplay/*=true*/) { TERN_(MARLIN_SMALL_BUILD, return); - report_heading(forReplay, F("X-Twist Correction")); + report_heading_etc(forReplay, F("X-Twist Correction")); SERIAL_ECHOLNPGM(" M423 A", xatc.start, " I", xatc.spacing); for (uint8_t x = 0; x < XATC_MAX_POINTS; ++x) { const float z = xatc.z_offset[x]; + report_echo_start(forReplay); SERIAL_ECHOPGM(" M423 X", x, " Z"); serial_offset(isnan(z) ? 0 : z); SERIAL_EOL(); diff --git a/Marlin/src/gcode/temp/M86_M87.cpp b/Marlin/src/gcode/temp/M86_M87.cpp index 502052e87b..442d325c56 100644 --- a/Marlin/src/gcode/temp/M86_M87.cpp +++ b/Marlin/src/gcode/temp/M86_M87.cpp @@ -37,7 +37,7 @@ void GcodeSuite::M86_report(const bool forReplay/*=true*/) { TERN_(MARLIN_SMALL_BUILD, return); hotend_idle_settings_t &c = hotend_idle.cfg; - report_heading(forReplay, F("Hotend Idle Timeout")); + report_heading_etc(forReplay, F("Hotend Idle Timeout")); SERIAL_ECHOLNPGM(" M86" #if HAS_HEATED_BED " B", c.bed_target, diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index 7062164dc9..a6714b3e6a 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -190,11 +190,6 @@ #pragma pack(push, 1) // No padding between variables -#if HAS_ETHERNET - void ETH0_report(); - void MAC_report(); -#endif - #define _EN_ITEM(N) , E##N #define _EN1_ITEM(N) , E##N:1 @@ -4210,11 +4205,11 @@ void MarlinSettings::reset() { #if HAS_ETHERNET CONFIG_ECHO_HEADING("Ethernet"); - if (!forReplay) ETH0_report(); - CONFIG_ECHO_START(); SERIAL_ECHO_SP(2); MAC_report(); - CONFIG_ECHO_START(); SERIAL_ECHO_SP(2); gcode.M552_report(); - CONFIG_ECHO_START(); SERIAL_ECHO_SP(2); gcode.M553_report(); - CONFIG_ECHO_START(); SERIAL_ECHO_SP(2); gcode.M554_report(); + if (!forReplay) ethernet.ETH0_report(false); + ethernet.MAC_report(forReplay); + gcode.M552_report(forReplay); + gcode.M553_report(forReplay); + gcode.M554_report(forReplay); #endif TERN_(HAS_MULTI_LANGUAGE, gcode.M414_report(forReplay));