Skip to content
Start free evaluation

pdcomm::modbus::License

Class

Static functions that install license text and read the license status and this host id of the Modbus library.

class License

Declared in: #include <pdcomm/modbus/pdcomm_modbus_license.hpp>

{"action":"connect"} needs a license for the modbus module, plus modbus-security when the configuration enables Modbus/TCP Security. Without it Endpoint::call() throws std::runtime_error whose what() is the error reply with "code":"license_required"; connections that are already open keep working. Licenses installed here are merged with the PDCOMM_LICENSE (text) and PDCOMM_LICENSE_FILE (path) environment variables and pdcomm.license files. Each function runs its command on a temporary endpoint; all functions are thread-safe.

pdcomm::modbus::License::install(license_text);
std::cout << pdcomm::modbus::License::status() << '\n';

Members

hostId

Method

Returns this host id, PDH1-XXXX-XXXX-XXXX-XXXX.

static std::string hostId()

Declared in: #include <pdcomm/modbus/pdcomm_modbus_license.hpp>

Returns

The host id that host-bound licenses name.

Notes

  • Throws std::runtime_error: with "code":"host_id_unavailable" when the machine id cannot be read.

install

Method

Installs license text, replacing text installed earlier.

static void install(const std::string &text)

Declared in: #include <pdcomm/modbus/pdcomm_modbus_license.hpp>

Parameters

NameDescription
textText with one or more -----BEGIN PDCOMM LICENSE----- blocks; text outside the blocks is ignored. Empty text removes the installed text.

Notes

  • Throws std::runtime_error: whose what() is the error reply with "code":"license_invalid" when the text holds no block whose signature verifies; the previous text stays installed.

status

Method

Returns the license status as JSON.

static std::string status()

Declared in: #include <pdcomm/modbus/pdcomm_modbus_license.hpp>

Returns

The status object: host_id, build_date, sources, licenses with their verification, and modules with the state, granted and days_left of each module.

Notes

  • Throws std::runtime_error: if the status cannot be read.