From e2856ba4f579c51c6aa58e8614f71a498e021a6c Mon Sep 17 00:00:00 2001 From: Alex Voinea Date: Tue, 21 Jul 2020 12:52:04 +0300 Subject: [PATCH 1/2] Make the serial number available to the user --- Firmware/Marlin_main.cpp | 45 +++++++++++++++------------------------- 1 file changed, 17 insertions(+), 28 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 8dbc0d84..49470ae1 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -3286,37 +3286,26 @@ void gcode_M701() */ static void gcode_PRUSA_SN() { - if (farm_mode) { - selectedSerialPort = 0; - putchar(';'); - putchar('S'); - int numbersRead = 0; - ShortTimer timeout; - timeout.start(); + uint8_t selectedSerialPort_bak = selectedSerialPort; + selectedSerialPort = 0; + putchar(';'); + putchar('S'); + int numbersRead = 0; + ShortTimer timeout; + timeout.start(); - while (numbersRead < 19) { - while (MSerial.available() > 0) { - uint8_t serial_char = MSerial.read(); - selectedSerialPort = 1; - putchar(serial_char); - numbersRead++; - selectedSerialPort = 0; - } - if (timeout.expired(100u)) break; + while (numbersRead < 19) { + while (MSerial.available() > 0) { + uint8_t serial_char = MSerial.read(); + selectedSerialPort = selectedSerialPort_bak; + putchar(serial_char); + numbersRead++; + selectedSerialPort = 0; } - selectedSerialPort = 1; - putchar('\n'); -#if 0 - for (int b = 0; b < 3; b++) { - _tone(BEEPER, 110); - _delay(50); - _noTone(BEEPER); - _delay(50); - } -#endif - } else { - puts_P(_N("Not in farm mode.")); + if (timeout.expired(100u)) break; } + selectedSerialPort = selectedSerialPort_bak; + putchar('\n'); } //! Detection of faulty RAMBo 1.1b boards equipped with bigger capacitors //! at the TACH_1 pin, which causes bad detection of print fan speed. From 2c2926882a924d1deabaf046f8a9a82eae9f3594 Mon Sep 17 00:00:00 2001 From: Alex Voinea Date: Tue, 18 Aug 2020 19:29:18 +0300 Subject: [PATCH 2/2] Don't switch unnecessarily. Also "\n" the ";S" request --- Firmware/Marlin_main.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 49470ae1..70a8f7e5 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -3287,25 +3287,23 @@ void gcode_M701() static void gcode_PRUSA_SN() { uint8_t selectedSerialPort_bak = selectedSerialPort; + char SN[20]; selectedSerialPort = 0; - putchar(';'); - putchar('S'); - int numbersRead = 0; + SERIAL_ECHOLNRPGM(PSTR(";S")); + uint8_t numbersRead = 0; ShortTimer timeout; timeout.start(); - while (numbersRead < 19) { - while (MSerial.available() > 0) { - uint8_t serial_char = MSerial.read(); - selectedSerialPort = selectedSerialPort_bak; - putchar(serial_char); + while (numbersRead < (sizeof(SN) - 1)) { + if (MSerial.available() > 0) { + SN[numbersRead] = MSerial.read(); numbersRead++; - selectedSerialPort = 0; } if (timeout.expired(100u)) break; } + SN[numbersRead] = 0; selectedSerialPort = selectedSerialPort_bak; - putchar('\n'); + SERIAL_ECHOLN(SN); } //! Detection of faulty RAMBo 1.1b boards equipped with bigger capacitors //! at the TACH_1 pin, which causes bad detection of print fan speed.