Requesting Access to an I/O Device on the Host

Follow this procedure to provide an application with access to an I/O device on the host.

  1. Edit the application's manifest.json file.
  2. Add one instance of the devices key for each device you want to map to the application. The devices listed must be present in the /opt/edge-agent/device-mapping.json file.
  3. For each device specify the:
    • id: This identifier must match the one specified for the device in the /opt/edge-agent/device-mapping.json file.
    • service: The application service into which the device will be mounted.
    • file: The name of the device file in the service's container. The application will use this file to access the device (using functions such as open, close, ioctl, etc.).
    • type: The device type. As of Predix Edge 2.3.0, SERIAL is the only supported device type.
    • description: A user-defined descriptor for the device.
Sample application manifest:
{
  "manifest": {
    "name": "serial-port-readout",
    "capabilities": [
      {
        "name": "serial-port-readout",
        "version": "1.0.0",
        "handler": "unused"
      }
    ],
    "devices": [
      {
        "id": "device3",
        "service": "main",
        "file": "/dev/ttyApp",
        "type": "SERIAL",
        "description": "Input From Infinite Improbability Drive"
      }
    ]
  }
}

The application uses the device id to create the mapping between the device and the application. If a device id specified in mappings.json does not exist in the /opt/edge-agent/device-mapping.json file, or if the device is already mapped to another application (regardless of whether that application is running or not), the mapping will fail and the application will not deploy.

An application may not have access to the device files immediately after it starts. It may take up to one minute before the application is granted access. An application should loop for a while and try again if open() on the device file fails. (I.e. if the open("/dev/ttyApp", O_RDONLY) system call fails.)

When an application using a device is removed, the device is returned to the pool of available devices.