Ver código fonte

🚸 UUID fallback to STM32 device SN (#24759)

Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
Stuart Pittaway 1 ano atrás
pai
commit
6f68942e83
Nenhuma conta vinculada ao e-mail do autor do commit

+ 29
- 8
Marlin/src/gcode/host/M115.cpp Ver arquivo

32
   #include "../../feature/caselight.h"
32
   #include "../../feature/caselight.h"
33
 #endif
33
 #endif
34
 
34
 
35
+#if ENABLED(HAS_STM32_UID) && !defined(MACHINE_UUID)
36
+  #include "../../libs/hex_print.h"
37
+#endif
38
+
35
 //#define MINIMAL_CAP_LINES // Don't even mention the disabled capabilities
39
 //#define MINIMAL_CAP_LINES // Don't even mention the disabled capabilities
36
 
40
 
37
 #if ENABLED(EXTENDED_CAPABILITIES_REPORT)
41
 #if ENABLED(EXTENDED_CAPABILITIES_REPORT)
59
  *       the capability is not present.
63
  *       the capability is not present.
60
  */
64
  */
61
 void GcodeSuite::M115() {
65
 void GcodeSuite::M115() {
62
-  SERIAL_ECHOLNPGM(
63
-    "FIRMWARE_NAME:Marlin " DETAILED_BUILD_VERSION " (" __DATE__ " " __TIME__ ") "
64
-    "SOURCE_CODE_URL:" SOURCE_CODE_URL " "
65
-    "PROTOCOL_VERSION:" PROTOCOL_VERSION " "
66
-    "MACHINE_TYPE:" MACHINE_NAME " "
67
-    "EXTRUDER_COUNT:" STRINGIFY(EXTRUDERS) " "
66
+  SERIAL_ECHOPGM("FIRMWARE_NAME:Marlin"
67
+    " " DETAILED_BUILD_VERSION " (" __DATE__ " " __TIME__ ")"
68
+    " SOURCE_CODE_URL:" SOURCE_CODE_URL
69
+    " PROTOCOL_VERSION:" PROTOCOL_VERSION
70
+    " MACHINE_TYPE:" MACHINE_NAME
71
+    " EXTRUDER_COUNT:" STRINGIFY(EXTRUDERS)
68
     #if NUM_AXES != XYZ
72
     #if NUM_AXES != XYZ
69
-      "AXIS_COUNT:" STRINGIFY(NUM_AXES) " "
73
+      " AXIS_COUNT:" STRINGIFY(NUM_AXES)
70
     #endif
74
     #endif
71
     #ifdef MACHINE_UUID
75
     #ifdef MACHINE_UUID
72
-      "UUID:" MACHINE_UUID
76
+      " UUID:" MACHINE_UUID
73
     #endif
77
     #endif
74
   );
78
   );
75
 
79
 
80
+  // STM32UID:111122223333
81
+  #if ENABLED(HAS_STM32_UID) && !defined(MACHINE_UUID)
82
+    // STM32 based devices output the CPU device serial number
83
+    // Used by LumenPnP / OpenPNP to keep track of unique hardware/configurations
84
+    // https://github.com/opulo-inc/lumenpnp
85
+    // Although this code should work on all STM32 based boards
86
+    SERIAL_ECHOPGM(" UUID:");
87
+    uint32_t *uid_address = (uint32_t*)UID_BASE;
88
+    LOOP_L_N(i, 3) {
89
+      const uint32_t UID = uint32_t(READ_REG(*(uid_address)));
90
+      uid_address += 4U;
91
+      for (int B = 24; B >= 0; B -= 8) print_hex_byte(UID >> B);
92
+    }
93
+  #endif
94
+
95
+  SERIAL_EOL();
96
+
76
   #if ENABLED(EXTENDED_CAPABILITIES_REPORT)
97
   #if ENABLED(EXTENDED_CAPABILITIES_REPORT)
77
 
98
 
78
     // The port that sent M115
99
     // The port that sent M115

+ 3
- 0
Marlin/src/pins/stm32f4/pins_OPULO_LUMEN_REV3.h Ver arquivo

44
 
44
 
45
 // I2C MCP3426 (16-Bit, 240SPS, dual-channel ADC)
45
 // I2C MCP3426 (16-Bit, 240SPS, dual-channel ADC)
46
 #define HAS_MCP3426_ADC
46
 #define HAS_MCP3426_ADC
47
+#ifdef STM32F4
48
+  #define HAS_STM32_UID
49
+#endif
47
 
50
 
48
 //
51
 //
49
 // Servos
52
 // Servos

Carregando…
Cancelar
Salvar