Module: gpio-mock

RPi GPIO mock framework.

Author:
  • Oscar Djupfeldt
Source:
See:

Methods

(inner) addDS18B20(id, sensor)

Adds a new simulated DS18B20 digital thermometer.

Parameters:
Name Type Description
id string

The id of the thermometer, must be unique

sensor object

Thermometer description

Properties
Name Type Description
behavior string

Defines how the thermometer behaves. Should be either 'static', 'external' or 'function'. 'static' continuously resets the w1_slave file to indicate the temperature provided in sensor.temperature. 'external' sets the initial value to the temperature provided in sensor.temperature, but makes no further changes to w1_slave, allowing for external programs to change the value. 'function' executes the function provided in sensor.temperature continuously.

temperature string

Defines the initial or static temperature, or a function returning the temperature. Values should be 1000 * degrees celcius, no decimals. If sensor.behavior is set to 'function' a function must be provided here, it should return a string representing the temperature, following the same pattern as if set to a fixed value.

Source:

(inner) start(mockLocation, callback)

Initializes the framework. Calling this function will override any call to fs where the path starts with either /sys/class/gpio or /sys/bus/w1/devices. By default the overrides are ./sys/class/gpio and ./sys/bus/w1/devices.

Parameters:
Name Type Description
mockLocation string

If a value is passed, this is prepended to the real path to form the new mock path

callback function

Called when start is finished

Source:

(inner) stop()

Stops the framework. Calling this function will reset fs to default.

Source: