Plug and play configuration - FREEDM-DGI/FREEDM GitHub Wiki
This document describes how to configure FREEDM to use plug and play devices. Plug and play devices are under development in the PlugNPlay branch, and so this tutorial applies to that branch of code.
DGI Configuration
- Navigate to the
Brokerdirectory. - Open or create the file
config/freedm.cfg. - Add
factory-port=Xto freedm.cfg where X is the port number plug and play devices will use for their initial communication with DGI. This value must be the same as thedgi-portoption listed later. - Add
adapter-port=X:Yto freedm.cfg where [X,Y] specifies a range of unused port numbers that should be reserved for plug and play devices. - Run
PosixBroker
Device Configuration
- Navigate to the
DeviceControllerdirectory. - Copy the sample file
controller.cfg.sampletocontroller.cfg. - Change
name=xin controller.cfg to any name that no other controller connecting to this DGI will have. - Change
host=Xin controller.cfg to the hostname of the machine that will run the DGI. - Change
port=Xin controller.cfg to the port number the device will use to initiate communication with DGI. This value must be the same as thefactory-portoption listed above. - Copy the sample file
dsp-script.txt.sampletodsp-script.txt. - Run
./controller.py
DSP Script Explanation
The file dsp-script.txt controls the behavior of the plug and play device. This script allows the device controller to enable new devices, disable old devices, change the value of current devices, and emulate network outage. The script consists of a sequence of commands followed by a work statement.
enable DeviceType DeviceName Signal Valuecreates a new device of the specified type identified within the script by the given name. All new devices must have some set of initial values for each of their associated signals.disable DeviceNamedeletes a device created with the enable command. The given device name must match a previous enable command.change DeviceName Signal Valuechanges the value of the specified signal for a device. The given device name must match a previous enable command.dieHorribly Durationfreezes the script for the specified duration to emulate a network outage. The device controller will sleep for the duration of the command.work Durationcauses the script to execute with the current settings for the specified duration. Unlike the dieHorribly command, the work command causes the controller to send heartbeat messages and data values to DGI to simulate a plug and play device.
By default, the device controller will politely disconnect from the DGI and then end its process upon reaching the end of its script. To avoid this behavior, add the command work forever to the end of the script.