modelBoot

File system: with no script, the microcontroller runs boot.py then main.py of a flash image copied at each simulation; main.py logs the ADC measurements (GP0) to /data/measurements.csv

Extends from Modelica.Icons.Example (Icon for runnable examples).

Information

Verification scenario 25 (see requirements.md, decision "Système de fichiers"): the file system is enabled (fsEnabled) and scriptPath is empty, so the microcontroller starts like a real board — boot.py then main.py, read at the root of the flash.

At each simulation, the image Resources/FileSystems/datalogger (fsSource) is copied into a new folder of the workspace (fsWorkspace = "." by default: the simulation folder), named mcu_datalogger_<date>_<time> — its exact path is announced in the simulation log, at the start and at the end, and Windows Explorer opens on it at the end of the simulation (fsOpenExplorer). The original image is never modified: each simulation starts again from the same state and produces the same files.

  • boot.py creates the /data folder;
  • main.py reads its settings from /config.txt, imports the DataLog module from /lib, then logs every 100 ms the voltage read by the ADC on GP0 (ramp from 0 to 3.3 V) to /data/measurements.csv;
  • it finally checks itself (file read-back, os.listdir, os.stat, attempt to escape the flash through ../..) and lights led1 (GP1) if everything is as expected.

To run it on your own files: point fsSource to a folder containing boot.py/main.py, and possibly fsWorkspace to the folder where the copies should go. Variant with a script instead of main.py: Examples.FileSystem.Script.

Components

TypeNameDefaultDescription
MCUmcuempty scriptPath: boot.py then main.py of the image Resources/FileSystems/datalogger; copy created in the simulation folder (fsWorkspace = "." by default), opened in Explorer at the end of the simulation
Modelica.Electrical.Analog.Basic.Groundground
Modelica.Electrical.Analog.Sources.RampVoltagerampvoltage measured by the ADC (GP0): ramp from 0 to 3.3 V in 1 s
Modelica.Electrical.Analog.Basic.Resistorr1limits the current of led1 (GP1)
MicroPythonMCU.Peripherals.LEDled1GP1: self-check of main.py passed