Skip to content

Examples

The Dracal installer installs the service and a copy of the tutorials by default. The tutorials include multiple examples to show you how to use the service. The tutorials are located at:

C:\Program Files\Dracal\Tutorials

/usr/share/dracal/tutorials

The tutorials provide:

  • Source code: Complete tutorial source files for building yourself
  • Pre-built executables: Ready-to-run examples

Examples overview

  • example_1: Demonstrates how to check if the Dracal device service is running
  • example_2: Shows how to list available devices
  • example_3: Retrieves information about a specific device
  • example_4: Retrieves all the information from a RTD300 device

Pre-built executables

Pre-built executables are installed so you can test your installation before building. They have latest in their name (e.g., dracal-cpp-latest-example-1) to distinguish them from the ones you build, which include the version number (e.g., dracal-cpp-3.5.0-example-1).

Pre-built executables are in C:\Program Files\Dracal\Tutorials\CPP\Examples

The executables are installed in /usr/bin and are available in your $PATH, so you can run them from any directory.

Test installation

The pre-built examples are ideal for testing your installation since they work out of the box with no additional configuration.

Example 1: Check service status

C:\Program Files\Dracal\Tutorials\CPP\Examples>dracal-cpp-latest-example-1.exe

{
    "service_name": "dracal-device-service",
    "status": "ok",
    "version": {
        "major": 3,
        "minor": 5,
        "patch": 0,
        "tag": "v3.5.0-r1",
        "tweak": 0
    }
}

Dracal Device Service is running

Press enter to close this window...
$ ./dracal-cpp-latest-example-1

{
    "service_name": "dracal-device-service",
    "status": "ok",
    "version": {
        "major": 3,
        "minor": 5,
        "patch": 0,
        "tag": "v3.5.0-r1",
        "tweak": 0
    }
}

Dracal device service is running

Example 2: List available devices

C:\Program Files\Dracal\Tutorials\CPP\Examples>dracal-cpp-latest-example-2.exe 

Dracal devices found:
        VCP-BAR20-CAL with serial E23892

Press enter to close this window...
$ ./dracal-cpp-latest-example-2

Dracal devices found:
        VCP-BAR20-CAL with serial E23892

Example 3: Get device information

C:\Program Files\Dracal\Tutorials\CPP\Examples>dracal-cpp-latest-example-3.exe

First Dracal device found:
VCP-BAR20-CAL with serial E23892

Channels
        altitude                 : timestamp: 2025-12-03T18:52:29.178Z value: -2808795.75 mm
        internal_temperature     : timestamp: 2025-12-03T18:52:29.178Z value: 25.34 °C
        pressure                 : timestamp: 2025-12-03T18:52:29.178Z value: 139.94 kPa

Press enter to close this window...
$ ./dracal-cpp-latest-example-3

First Dracal device found:
VCP-BAR20-CAL with serial E23892

Channels
        altitude                 : timestamp: 2025-12-03T18:52:29.178Z value: -2808795.75 mm
        internal_temperature     : timestamp: 2025-12-03T18:52:29.178Z value: 25.34 °C
        pressure                 : timestamp: 2025-12-03T18:52:29.178Z value: 139.94 kPa

Example 4: Get information from an RTD300 device

This example uses the RTD300, one of our most popular products.

C:\Program Files\Dracal\Tutorials\CPP\Examples>dracal-cpp-latest-example-4.exe

First Dracal RTD300 device found:
        Product: VCP-RTD300-CAL, Serial: E22377
                Temperature:
                        timestamp: 2025-12-12T01:27:54.087Z
                        value    : 120.68 °C

Press enter to close this window...
$ ./dracal-cpp-latest-example-4

First Dracal RTD300 device found:
        Product: VCP-RTD300-CAL, Serial: E22377
                Temperature:
                        timestamp: 2025-12-12T01:27:54.087Z
                        value    : 120.68 °C

Building examples

See tutorials for detailed instructions on building the tutorials yourself.

Copy tutorial files before building

You must copy the tutorial files to another directory to avoid:

  • Altering the original tutorial files
  • Permission issues when building in protected system directories

Command line examples

You can interact with the REST JSON API directly from the command line using tools like curl and jq. This is useful for testing, debugging, or building shell scripts.

Prerequisites

Install the required command-line tools:

curl: Included by default in Windows 10 (version 1803) and later. For older versions, download from curl.se

jq: Download from jqlang.github.io/jq/download and add to your PATH, or install via package manager:

winget install jqlang.jq

sudo apt update
sudo apt install curl jq

Basic Examples

Using jq filters

The -s flag in curl suppresses the progress meter for cleaner output. The jq tool uses dot notation to navigate JSON structures. Use single quotes in Ubuntu and double quotes in Windows for jq filters.

List all connected device serial numbers

curl -s http://localhost:11395/3.5.0/devices/usb | jq ".devices | keys"
curl -s http://localhost:11395/3.5.0/devices/usb | jq '.devices | keys'

Example output:

[
  "E22377"
]

Extract temperature from a RTD300 device

Get the temperature from RTD300 device with serial number E22377:

curl -s http://localhost:11395/3.5.0/devices/usb | jq ".devices.E22377.channels.temperature.value.magnitude"
curl -s http://localhost:11395/3.5.0/devices/usb | jq '.devices.E22377.channels.temperature.value.magnitude'

Example output:

121.5538101196289

Get all connected devices

curl -s http://localhost:11395/3.5.0/devices/usb | jq
curl -s http://localhost:11395/3.5.0/devices/usb | jq

Example output:

{
  "devices": {
    "E22377": {
      "channel_list": [
        "temperature"
      ],
      "channels": {
        "temperature": {
          "period_ms": 100,
          "value": {
            "magnitude": 121.5538101196289,
            "timestamp": "2025-12-12T01:48:28.714Z",
            "unit": "°C"
          }
        }
      },
      "config": {
        "protocol": {
          "usb": true,
          "vcp": true
        }
      },
      "connections": {
        "usb": {
          "address": 20,
          "bus": 2,
          "product_id": "0504",
          "vendor_id": "289B"
        },
        "vcp": null
      },
      "info": {
        "firmware_version_major": 2,
        "firmware_version_minor": 4,
        "product": "VCP-RTD300-CAL",
        "serial": "E22377",
        "vendor": "Dracal technologies inc."
      },
      "model": "VCP-RTD300-CAL/v1"
    }
  },
  "products": {
    "VCP-RTD300-CAL/v1": {
      "channels": {
        "temperature": {
          "description": "Temperature",
          "details": {
            "virtual": false
          },
          "label": "temperature",
          "type": "Temperature",
          "unit": "°C"
        }
      },
      "info": {
        "interfaces": {
          "usb": "tenkiusb",
          "vcp": "tenkivcp"
        },
        "name": "VCP-RTD300-CAL",
        "sku": "605048",
        "vendor": "Dracal technologies inc."
      },
      "model": "VCP-RTD300-CAL/v1"
    }
  }
}

Advanced Examples

Get all channel names for a device

curl -s http://localhost:11395/3.5.0/devices/usb | jq ".devices.E22377.channel_list"
curl -s http://localhost:11395/3.5.0/devices/usb | jq '.devices.E22377.channel_list'

Example output:

[
  "temperature"
]

Get the full temperature value (magnitude, unit, timestamp)

curl -s http://localhost:11395/3.5.0/devices/usb | jq ".devices.E22377.channels.temperature.value"
curl -s http://localhost:11395/3.5.0/devices/usb | jq '.devices.E22377.channels.temperature.value'

Example output:

{
  "magnitude": 121.5538101196289,
  "timestamp": "2025-12-12T01:48:28.714Z",
  "unit": "°C"
}

Get the model identifier from a device

curl -s http://localhost:11395/3.5.0/devices/usb | jq ".devices.E22377.model"
curl -s http://localhost:11395/3.5.0/devices/usb | jq '.devices.E22377.model'

Example output:

"VCP-RTD300-CAL/v1"

Get service information

curl -s http://localhost:11395/dracal-service-info | jq
curl -s http://localhost:11395/dracal-service-info | jq

Example output:

{
  "service_name": "dracal-device-service",
  "status": "ok",
  "version": {
    "major": 3,
    "minor": 5,
    "patch": 0,
    "tag": "v3.5.0-r1",
    "tweak": 0
  }
}


Use the navigation menu on the left to explore the full documentation.