Skip to content

Raspberry.IO.GeneralPurpose.Configuration.GpioConnectionConfigurationSection

raspberry-sharp edited this page Oct 23, 2012 · 7 revisions

The GpioConnectionConfigurationSection class implements a configuration section dedicated to configuration of GPIO access.

.config File

Section definition

<section name="gpioConnection"
         type="Raspberry.IO.GeneralPurpose.Configuration.GpioConnectionConfigurationSection, Raspberry.IO.GeneralPurpose" />

Section usage

<gpioConnection 
  boardRevision="1|2|auto"
  pollInterval="duration (ms)"
  driver="type full name, assembly" />
Parameters
  • boardRevision: the revision of the board (1 or 2), or auto to detect automatically the board revision. Default is auto,
  • pollInterval: the poll interval for input pins, in milliseconds. Default value is 50ms. On Raspberry Pi, values may be lower than 1. For instance, a value of 0.1 represents a 100µs interval. Values lower than 1 millisecond imply a heavy CPU load on Raspberry Pi,
  • driver: the fully qualified name of the IGpioConnectionDriver implementation. By default, MemoryGpioConnectionDriver is used.

Sample

<configSections>
  <section name="gpioConnection" 
           type="Raspberry.IO.GeneralPurpose.Configuration.GpioConnectionConfigurationSection, Raspberry.IO.GeneralPurpose" />
</configSections>

<gpioConnection 
  pollInterval="25"
  driver="Raspberry.IO.GeneralPurpose.FileConnectionDriver, Raspberry.IO.GeneralPurpose" />

Usage in Applications

Value of driver attribute of gpioConnection section element is used by GpioConnection to load default configuration settings.

GpioConnectionConfigurationSection may also be used as follow:

IConnectionDriver driver;
var configurationSection = ConfigurationManager.GetSection("gpioConnection") as GpioConnectionConfigurationSection;
if (configurationSection != null && !string.IsNullOrEmpty(configurationSection.DriverTypeName))
  driver = (IConnectionDriver) Activator.CreateInstance(Type.GetType(configurationSection.DriverTypeName, true));
else
  driver = new MemoryConnectionDriver();