Skip to content
Alessandro edited this page Mar 1, 2019 · 4 revisions

Index

  1. Resetting via hardware
  2. Resetting via software (front-end)

Reset

The CoderBot can now be reset with a button via hardware and via front-end via software.
That could come in handy if the CoderBot system encounters any problem i nbooting or anything else where an hard reset is necessary to restore it to a working state.

1. Resetting via Hardware

General

Thanks to installed services (See the wiki) i've wrote, the system is able to detect a 3 seconds long button press in order to trigger the reset. The script running in background simply listens to the pin 16 and waits for a falling edge (button press).
If the button is pressed for 3 or more seconds the script performs the creation of a flag file called doreset inside the /boot folder and then forces a reboot.

The flag will be detected at reboot by the overlay system installed and a reset will be performed by wiping out the overlay partition before it will be mounted. If no reset has ever been performed, no log file will be there. That’s solved by creating one in case it doesn’t exist.

The repo i’ve been working on is system-install because the reset service must be available as part of the CoderBot system since the beginning.

Since the reboot can be performed by placing a flaga file inside /boot, in case the Coderbot system cannot be booted, the flag file could be copied inside the boot partiton accessible by connecting the sd to a computer.

2. Resetting via Software

General

Now that the reset is triggerable via hardware, i now needed to expose the reset via front end so that the user could call if via user interface using the vue.js app. Using RESTful principles i’ve defined a new route as POST method to trigger the reset, and i’ve merged the reset status with the coderbot general status. That seemed like a good idea since the vue.js app does a polling on /status route using the GET method.

The repos i’ve been working on is backed,for the definition of new routes and log file retrieval, and vue-app for the user-interfare part.

API

The API now exposes a new route /reset on POST with no parameters (defined inside the v2.yml routes definitions file). If a POST on this route is performed, a falling_edge on the corrispondent reset button pin is simualted.
In that way i’m relying on the service already running in the CoderBot system and by doing so i only have one code that triggers the reset, and that’s helpful in terms of maintainability.

The restore LOG FILE is exposed via the /status route on GET.
The method reads the log file inside /home/pi/log and returns its content. If no trigger was ever performed, the file will not be there. In that case empty log data is returned.

Vue.js app

The front end communicates with exposed routes via RESTful principles. I’ve added a section using the v-card module in order to store the log file.
Every second a GET on /status is performed retrieving a JSON file containing all CoderBot current status values.

In order to trigger the reset i’ve added a button. On click, a modal window is showed asking for the user if he wants to perform an hard reset. I’ve used a v-dialog component.
If the answer is yes the restore callback function is called and an hard reset is performed by making a POST to the /reset route with no parameters (and the modal window is closed) using the connexion plugin for vue.js (makes client-server communications easier).

The system automatically reboots itself when a reset request is sent. That’s why i didn’t implement the error response if a reset is already running. Simply because you won’t be able to access the buttons since all the interface will be hide waiting for CoderBot to go back online.

Menu