From 1f5bece0dba8b18ae6e277ad75c184e8edc6dc18 Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Sat, 25 Aug 2018 16:15:35 +0200 Subject: [PATCH] check for required mmu2 firmware buildnr --- Firmware/mmu.cpp | 15 +++++++++++++++ Firmware/mmu.h | 4 ++++ 2 files changed, 19 insertions(+) diff --git a/Firmware/mmu.cpp b/Firmware/mmu.cpp index 977c3fe1..0ffccc29 100644 --- a/Firmware/mmu.cpp +++ b/Firmware/mmu.cpp @@ -23,6 +23,7 @@ extern char choose_extruder_menu(); #define MMU_HWRESET #define MMU_RST_PIN 76 +#define MMU_REQUIRED_FW_BUILDNR 81 bool mmu_enabled = false; @@ -137,6 +138,9 @@ void mmu_loop(void) { fscanf_P(uart2io, PSTR("%u"), &mmu_buildnr); //scan buildnr from buffer printf_P(PSTR("MMU => '%dok'\n"), mmu_buildnr); + bool version_valid = mmu_check_version(); + if (!version_valid) mmu_show_warning(); + else puts_P(PSTR("MMU version valid")); puts_P(PSTR("MMU <= 'P0'")); mmu_puts_P(PSTR("P0\n")); //send 'read finda' request mmu_state = -4; @@ -826,3 +830,14 @@ void extr_unload_4() change_extr(4); extr_unload(); } + +bool mmu_check_version() +{ + return (mmu_buildnr >= MMU_REQUIRED_FW_BUILDNR); +} + +void mmu_show_warning() +{ + printf_P(PSTR("MMU2 firmware version invalid. Required version: build number %d or higher."), MMU_REQUIRED_FW_BUILDNR); + kill(_i("Please update firmware in your MMU2. Waiting for reset.")); +} diff --git a/Firmware/mmu.h b/Firmware/mmu.h index 643cf29b..a24dc4cc 100644 --- a/Firmware/mmu.h +++ b/Firmware/mmu.h @@ -80,3 +80,7 @@ extern void extr_unload_1(); extern void extr_unload_2(); extern void extr_unload_3(); extern void extr_unload_4(); + +extern bool mmu_check_version(); +extern void mmu_show_warning(); +