From 8e2f595c3d1f1bc4af09eb27abc83b9c135dec8f Mon Sep 17 00:00:00 2001 From: Balazs Racz Date: Thu, 22 Aug 2024 22:29:49 +0200 Subject: [PATCH] Adds factory reset handler to linux:io_board. This is necessary to initialize the username and user description fields. Without the initialization these are filled by 0xFF bytes without null termination, which is not standards compliant. --- .../io_board/targets/linux.x86/main.cxx | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/applications/io_board/targets/linux.x86/main.cxx b/applications/io_board/targets/linux.x86/main.cxx index 25e0ccb6c..414dc3e50 100644 --- a/applications/io_board/targets/linux.x86/main.cxx +++ b/applications/io_board/targets/linux.x86/main.cxx @@ -125,6 +125,23 @@ openlcb::ConfiguredProducer producer_sw2( openlcb::RefreshLoop loop( stack.node(), {&consumer_pulse1, &consumer_pulse2}); +class FactoryResetHelper : public DefaultConfigUpdateListener +{ +public: + UpdateAction apply_configuration( + int fd, bool initial_load, BarrierNotifiable *done) OVERRIDE + { + AutoNotify n(done); + return UPDATED; + } + + void factory_reset(int fd) override + { + cfg.userinfo().name().write(fd, "IO Board"); + cfg.userinfo().description().write(fd, "User description"); + } +} reset_helper; + /** Entry point to application. * @param argc number of command line arguments * @param argv array of command line arguments