Making I/O Devices Available to Applications

I/O devices on Predix Edge OS are accessed through device files in the /dev folder. There are two types of devices: block devices and character devices. Only character devices are currently supported. A device file is exposed to the applications by creating a device configuration file. System builders typically create these configuration files.

  1. The system builder needs to create the configuration file /opt/edge-agent/device-mapping.json.
  2. Edit the file to list the devices to be made available to applications. For each device, add an entry to the device mapping list that specifies:
    • file: The device file on the Predix Edge OS that corresponds to the device that will be exposed to the applications.
    • type: The device type. As of Predix Edge 2.3.0, SERIAL is the only supported device type.
    • id: A unique, user-defined device identifier that will be used to map the application to the device.
    • description: A user-defined descriptor for the device.
    Sample device mappings file:
    {
        "devices": [
            {
                "file": "/dev/ttyS0",
                "type": "SERIAL",
                "id": "device1",
                "description": "Weight Scale"
            },
            {
                "file": "/dev/ttyS1",
                "type": "SERIAL",
                "id": "device2",
                "description": "Bar Code Reader"
            },
            {
                "file": "/dev/ttyS2",
                "type": "SERIAL",
                "id": "device3",
                "description": "Position Encoder"
            }
        ]
    }
  3. Edit the file /opt/edge-agent/agent-data.json to add the key device_mapping with the value /opt/edge-agent/device-mapping.json, as in:
    "device_mapping": "/opt/edge-agent/device_mapping.json"