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

  1. Navigate to the Broker directory.
  2. Open or create the file config/freedm.cfg.
  3. Add factory-port=X to 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 the dgi-port option listed later.
  4. Add adapter-port=X:Y to freedm.cfg where [X,Y] specifies a range of unused port numbers that should be reserved for plug and play devices.
  5. Run PosixBroker

Device Configuration

  1. Navigate to the DeviceController directory.
  2. Copy the sample file controller.cfg.sample to controller.cfg.
  3. Change name=x in controller.cfg to any name that no other controller connecting to this DGI will have.
  4. Change host=X in controller.cfg to the hostname of the machine that will run the DGI.
  5. Change port=X in controller.cfg to the port number the device will use to initiate communication with DGI. This value must be the same as the factory-port option listed above.
  6. Copy the sample file dsp-script.txt.sample to dsp-script.txt.
  7. 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 Value creates 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 DeviceName deletes a device created with the enable command. The given device name must match a previous enable command.
  • change DeviceName Signal Value changes the value of the specified signal for a device. The given device name must match a previous enable command.
  • dieHorribly Duration freezes the script for the specified duration to emulate a network outage. The device controller will sleep for the duration of the command.
  • work Duration causes 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.