Running a Custom Driver

You can configure the SmartServer to start a custom driver automatically on startup.  As described in Custom Driver File Locations, example.conf configures the example custom driver to run as a service.  For development and debugging, you can manually run the example custom driver from the console to monitor the execution flow and see the callback activity.  To run the example custom driver manually follow these steps:

  1. Using a console application like PuTTY to connect to the SmartServer.

  2. Navigate to the /var/apollo/data/example/ directory.

  3. Type ‘sudo ./example’ to start up the example custom driver.

The above console output to the console indicating that the IdiStart() function was called, that it returned successfully, and that the example thread was launched.  The console also reports the IDL internal version number.  You can stop the example customer driver at any time within the console by typing ^C (Control-C).  To view the console feedback while the example driver runs, leave the driver application running and the console application open while working with the CMS.

Before loading the device type definition file (exampledevice.dtd) into the CMS, copy the example.conf device interface (XIF) to the /var/apollo/data/example/res/ directory as described in Custom Driver File Locations.  With the IDL example driver running, import the exampledevice.dtd using the Import/Export button ().

With SmartServer 3.5 and higher, importing and exporting SmartServer IoT configuration files is available with the Import/Export button (). With SmartServer 2.7 Update 1 to 3.5, the Settings button () enables you to edit the dashboard, as well as to import or export SmartServer IoT configuration files. With SmartServer 3.6 and prior, you can also use the Import Device Types button () on the Device Types widget to load device files. 

Once the import is finished, the exampledevice will appear in the Device Types widget.

Use the Devices widget to create a new device that uses this custom driver type and has the following parameters:

  • Name = ExampleDevice
  • UID - 0xF602
  • Integration method = Manual assignment
  • Driver = example
  • Device Type = exampledevice

The action of creating a device that uses this example driver triggers IDL to call the dev_create_cb() callback function in example.cpp that was registered by the example driver code with the IDL library in main.cpp:  IdlDevCreateCallbackSet(idl, dev_create_cb);

This also generates output in the console from the running custom driver application:

As you provision devices, de-provision devices, delete devices, read / write data points (and so on) that use this custom driver, the sample driver will output information to the console as these selected callback functions are triggered by IDL:

When running the example custom driver explicitly in the console, de-provision and delete devices you create that use this driver before terminating the custom driver application in the console.