Skip to content

Commit

Permalink
Adds factory reset handler to linux:io_board. (#797)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
balazsracz authored Aug 22, 2024
1 parent 4ef35ba commit a7dd545
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions applications/io_board/targets/linux.x86/main.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a7dd545

Please sign in to comment.