View Source DtsBuddy.Diagnostic (dts_buddy v0.1.0)

Runs an overlay through the compilation and loading cycle, then proceeds to check if there really is the expected outcome on the header.

To run a diagnostic cycle, you should call run_diagnostic/1, passing a reader function as an argument. This is so that we do not directly depend on Circuits.GPIO as this is not strictly needed to use DtsBuddy.

Example use, succeeding :

iex> {:ok, gpio} = Circuits.GPIO.open("GPIO12", :input)
{:ok, %Circuits.GPIO.CDev{}}
iex> reader = fn () -> Circuits.GPIO.read(gpio)
#Function<>
iex> DtsBuddy.Diagnostic.run_diagnostic(reader)
[DtsBuddy.Diagnostic] Running system checks
[DtsBuddy.Diagnostic] All system checks passed
[DtsBuddy.Diagnostic] Loading a sample overlay
[DtsBuddy.Diagnostic] Sampling GPIO with the user-supplied reader function for ~5 seconds
[DtsBuddy.Diagnostic] Behavior of the activated GPIO looks correct with 5 LOW samples and 5 HIGH samples
[DtsBuddy.Diagnostic] Unloading overlay testled
[DtsBuddy.Diagnostic] Everything looks OK
:ok

Example use, failing :

iex> {:ok, gpio} = Circuits.GPIO.open("GPIO12", :input)
{:ok, %Circuits.GPIO.CDev{}}
iex> reader = fn () -> Circuits.GPIO.read(gpio)
#Function<>
iex> DtsBuddy.Diagnostic.run_diagnostic(reader)
[DtsBuddy.Diagnostic] Running system checks
[DtsBuddy.Diagnostic] Device tree compiler is missing on the system.
[DtsBuddy.Diagnostic] All tests did not pass. Please refer to the above logs for further details.
:error

Summary

Functions

Gathers samples to check the actual behavior of the LED overlay by sampling GPIO roughly every 100ms. Output should be a list of 1 and 0s.

Checks if the samples collected by the reader function look correct, in the sense that there was enough variation of output in the given time. An erratic GPIO would currently look correct if it was checked by this function though.

Functions

Link to this function

gather_samples(reader_fn)

View Source
@spec gather_samples(fun()) :: [integer()]

Gathers samples to check the actual behavior of the LED overlay by sampling GPIO roughly every 100ms. Output should be a list of 1 and 0s.

@spec valid_samples(any()) :: :error | :ok

Checks if the samples collected by the reader function look correct, in the sense that there was enough variation of output in the given time. An erratic GPIO would currently look correct if it was checked by this function though.