C++ Tutorials¶
This directory contains C++ tutorial examples demonstrating how to use the Dracal device service API.
Prerequisites¶
- Dracal device service version 3.5.0 or higher installed and running
- CMake 3.15 or higher
- A C++ compiler with C++11 support
Getting Started¶
The tutorials are installed by default with the Dracal installer at:
- Windows:
C:\Program Files\Dracal\Tutorials\CPP - Ubuntu:
/usr/share/dracal-utilities/examples/CPP
⚠️ Important: You must copy the tutorial files to another directory. This avoids:
- Altering the original tutorial files
- Permission issues when building in system directories (which requires Administrator privileges)
Examples Overview¶
- example_1 (
1_check_running/main.cpp): Check if the Dracal Device Service is running - example_2 (
2_device_list/main.cpp): List all available devices - example_3 (
3_get_device/main.cpp): Retrieve information about a specific device - example_4 (
4_RTD300/main.cpp): Retrieve all channels information from the first RTD300 found
Pre-Built Executables¶
Pre-built executables are installed by default so you can test your installation before building. To help differentiate them from locally built executables, the pre-built executables are named:
-
Windows:
-
dracal-cpp-latest-example-1.exe dracal-cpp-latest-example-2.exedracal-cpp-latest-example-3.exe-
dracal-cpp-latest-example-4.exe -
Ubuntu:
-
dracal-cpp-latest-example-1 dracal-cpp-latest-example-2dracal-cpp-latest-example-3dracal-cpp-latest-example-4
The executables are located by default in
- Windows:
C:\Program Files\Dracal\Tutorials\CPP\Examples - Ubuntu: in the system path
Typical Output¶
dracal-cpp-latest-example-1
{
"service_name": "dracal-device-service",
"status": "ok",
"version": {
"major": 3,
"minor": 5,
"patch": 0,
"tag": "v3.5.0",
"tweak": 0
}
}
Dracal Device Service is running
Press enter to close this window...
dracal-cpp-latest-example-2
Dracal devices found:
VCP-BAR20 with serial E20298
VCP-RTD300-CAL with serial E22377
Press enter to close this window...
dracal-cpp-latest-example-3
First Dracal device found:
VCP-BAR20 with serial E20298
Channels
altitude : timestamp: 2025-12-10T19:40:49.194Z value: 186797.94 mm
atmospheric_pressure : timestamp: 2025-12-10T19:40:49.194Z value: 99.10 kPa
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-10T19:41:03.119Z
value : 123.36 °C
Press enter to close this window...
Building the Examples¶
Step 1: Configure the Build¶
From the tutorials directory root, run:
cmake -B build -S .
Step 2: Build the Project¶
cmake --build build --config Release
Step 3: Install the Executables¶
cmake --install build
Step 4: Run the Examples¶
Run the examples from the tutorials directory root:
Windows:
.\bin\dracal-cpp-3.5.0-example-1.exe
.\bin\dracal-cpp-3.5.0-example-2.exe
.\bin\dracal-cpp-3.5.0-example-3.exe
.\bin\dracal-cpp-3.5.0-example-4.exe
Ubuntu:
./bin/dracal-cpp-3.5.0-example-1
./bin/dracal-cpp-3.5.0-example-2
./bin/dracal-cpp-3.5.0-example-3
./bin/dracal-cpp-3.5.0-example-4
Troubleshooting¶
If you encounter build issues:
- Ensure the Dracal Device Service is installed and running
- Verify CMake version:
cmake --version - Check that you have write permissions in your build directory