Running the Multi DIO Application

You can start the Multi DIO example application as a service and optionally enable it to automatically run on boot, or you can run it from the command line. Running from the command line is useful for doing interactive testing and debugging. Running as a service is useful for setting up working networks and demonstrations.

 

To start the Multi DIO example application as a service and enable it to run on boot, enter the following command:

izot_enable dio

To stop the Multi DIO example application and disable it from running on boot, enter the following command:

izot_disable dio

To start the Multi DIO example application without changing its boot status, enter the following command:

izot_start dio

To stop the Multi DIO example application without changing its boot status, enter the following command:

izot_stop dio

To display the status of all IzoT services, enter the following command.

izot_stat

To run the Multi DIO example application from the command line, change to the Multi DIO example directory at $IZOT/izot/examples/multi_dio and enter the following command at the Linux shell prompt:

supy multi_dio.py[-D] [-d DEVICE] [-h] [-I] [-i] [-l LOG] [-m] [-n NVD] [-p PROGRAM_ID] [-v] [-r RESET_TYPE]

The following table summarizes the command-line flags and options:

  
Flag / Option Description
-C Enables debugging with the PyCharm IDE.
-D Runs the Touch Keypad example applicaiton in debug mode. The log level is increased for both the console log and the application log.
-d DEVICE Sets the device URI, e.g. uc://10.0.1.12:1628. If not specified the default URI is used.
-h Displays the available flags and options.
-I Disables ISI. Without ISI, the application requires installation by a network management tool such as the IzoT Commissioning Tool.
-i Runs the Touch Keypad without any attached I/O hardware. This is useful for running the Touch Keypad on platforms that do not have the Touch Keypad I/O hardware.
-l LOG Sets the path and filename for log files. If not specified, the default path is the Touch Keypad example directory, and the filename is 3-chan-dio.
-m Runs the Touch Keypad in demo mode. In demo mode, periodic ISI messaging is increased to speed up device and connection discovery. The result is that more bandwidth is consumed for ISI messaging provide faster discovery at the expense of less bandwidth for application data.
-n NVD Specifies the path for the non-volatile data directory. If not specified the default directory is 3-chan-dio-nvd in the Touch Keypad example directory.
-p PROGRAM_ID Specifies a program ID for this running instance of the application. PROGRAM_ID is a 16-digit hex value described in the Standard Program ID. If not specified the default program ID for the Environment Sensor example application is 9F:FF:FF:05:00:51:00:31. Specify a different program ID if you have modified the IzoT interface for the example application and you need to load a different device class file for the modified application.
-r RESET_TYPE Clears persistant data. Set RESET_TYPE to 0 to clear all persistant data; set RESET_TYPE to 1 to clear all persistant data except for the device unique ID. RESET_TYPE 1 is useful to prevent a change in unique ID which will result in a new discovery of the device by the IzoT Server.
-v Runs the Touch Keypad example applicaiton in verbose mode. The log level is increased to the maximum level for both the console log and the application log.

 

 

 

 

Once launched, the multi DIO application will toggle the state of LED 1 each time you press Button 1.  Relay 1 will also toggle since it is attached to the same output as LED 1.  The Buttons 2 and 3 will also control LEDs 2 and 3.  Button 2 will control Relay 2. There is no relay for Button 3.

 

A key feature of the IzoT Platform is the capability for IzoT-enabled devices to autonomously communicate without the use of servers or controllers. IzoT-enabled devices can periodically broadcast information about their applications and available datapoints, and can monitor these broadcasts to subscribe to datapoint updates from compatible devices. The DIO application you are running broadcasts information that informs other IzoT-enabled devices that it has a digital input that can be controlled via a datapoint, and it has a digital output that publishes the state of the digital point.

 

To optimize network traffic, one of the DIO devices in your community acts as a host for all the DIO connections. You will need to modify the application on one of your DIO devices to act as a host. To do this you just need to change the value of is_host_device to True.

is_host_device = True    # Set to True if this device is a host

Once multiple Multi DIO applications are running, and one of them is acting has a host, they will discover each other and start to form connections, creating a community of devices. Within a few minutes of starting multi_dio.py on your multiple Pis, the Multi DIO applications will connect to each other. By pressing the first pushbutton on one Pi device, you may notice that the state of LED 1 of the other Pi devices are changing.

 

You can change the number of DIO blocks on your device. By default the Multi DIO application implements three DIO blocks. To change the number of DIO blocks on your device from three to two, modify the value for DIO_COUNT in the Multi DIO Python application from "3" to "2".

DIO_COUNT = 2             # Number of DIOs; can be 1 to 7 with the PiFace