From 24ac040eacc52e6e8a303e7ffec36d2da51337f3 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 16 Sep 2022 14:56:49 -0500 Subject: [PATCH] tweak, move --- Marlin/src/gcode/host/M115.cpp | 65 ++++++++++++++-------------------- 1 file changed, 26 insertions(+), 39 deletions(-) diff --git a/Marlin/src/gcode/host/M115.cpp b/Marlin/src/gcode/host/M115.cpp index f4f28258149e6..e9dd5778e6dfc 100644 --- a/Marlin/src/gcode/host/M115.cpp +++ b/Marlin/src/gcode/host/M115.cpp @@ -63,20 +63,38 @@ * the capability is not present. */ void GcodeSuite::M115() { - SERIAL_ECHOLNPGM( - "FIRMWARE_NAME:Marlin " DETAILED_BUILD_VERSION " (" __DATE__ " " __TIME__ ") " - "SOURCE_CODE_URL:" SOURCE_CODE_URL " " - "PROTOCOL_VERSION:" PROTOCOL_VERSION " " - "MACHINE_TYPE:" MACHINE_NAME " " - "EXTRUDER_COUNT:" STRINGIFY(EXTRUDERS) " " + SERIAL_ECHOPGM("FIRMWARE_NAME:Marlin" + " " DETAILED_BUILD_VERSION " (" __DATE__ " " __TIME__ ")" + " SOURCE_CODE_URL:" SOURCE_CODE_URL + " PROTOCOL_VERSION:" PROTOCOL_VERSION + " MACHINE_TYPE:" MACHINE_NAME + " EXTRUDER_COUNT:" STRINGIFY(EXTRUDERS) #if NUM_AXES != XYZ - "AXIS_COUNT:" STRINGIFY(NUM_AXES) " " + " AXIS_COUNT:" STRINGIFY(NUM_AXES) #endif #ifdef MACHINE_UUID - "UUID:" MACHINE_UUID + " UUID:" MACHINE_UUID #endif ); + // STM32UID:111122223333 + #if MB(INDEX_REV03) && defined(STM32F4) + // STM32 based devices output the CPU device serial number + // Used by LumenPnP / OpenPNP to keep track of unique hardware/configurations + // https://github.com/opulo-inc/lumenpnp + // Although this code should work on all STM32 based boards + SERIAL_ECHOPGM(" STM32UID:"); + uint32_t *uid_address = (uint32_t*)UID_BASE; + LOOP_L_N(i, 3) { + const uint32_t UID = uint32_t(READ_REG(*(uid_address))); + uid_address += 4U; + for (int B = 24; B >= 0; B -= 8) print_hex_byte(UID >> B); + print_hex_long(UID); + } + #endif + + SERIAL_EOL(); + #if ENABLED(EXTENDED_CAPABILITIES_REPORT) // The port that sent M115 @@ -196,37 +214,6 @@ void GcodeSuite::M115() { // CONFIG_EXPORT cap_line(F("CONFIG_EXPORT"), ENABLED(CONFIGURATION_EMBEDDING)); - - - - #if MB(INDEX_REV03) - #ifdef STM32F4 - //STM32 based devices, output the CPU device serial number - //Used by LumenPnP / OpenPNP to keep track of unique hardware/configurations - //https://github.com/opulo-inc/lumenpnp - //Although this code should work on all STM32 based boards - - SERIAL_ECHOPGM("Cap:"); - SERIAL_ECHOF(F("STM32UID")); - SERIAL_CHAR(':'); - - uint32_t * uid_address=(uint32_t *)UID_BASE; - for (int loop = 0; loop <3; loop++ ) { - - uint32_t UID; - UID = (uint32_t)(READ_REG(*(uid_address))); - uid_address+=4U; - - // Output the 32bit value as HEX characters - for (int B = 24; B >= 8; B -= 8) { - print_hex_byte(UID >> B); - } - print_hex_byte(UID); - } - SERIAL_EOL(); - #endif - #endif - // Machine Geometry #if ENABLED(M115_GEOMETRY_REPORT) const xyz_pos_t bmin = { 0, 0, 0 },