addon
Module Configuration
The addon
module lets the Alemca Agent communicate with external software.
It is meant for uncommon protocols or highly specific systems.
An addon is a Lua module that interacts with the external software through function calls, and the link between the agent and the software is handled over gRPC, providing secure and efficient communication.
Addon Configuration
The Alemca agent is configured through a YAML file.
To declare an addon, add the following section to the agent’s configuration file:
iot:
modules:
addon:
- name: can # Unique addon name (no spaces or special chars)
addonType: can # Addon type (here: CAN)
address: "127.0.0.1:50051" # IP:PORT where the addon listens
timeout: 5 # Connection timeout in seconds
useTLS: false # true = enable TLS, false = plaintext
Configuration Details
- name : | Addon instance name. Must be unique with no spaces or special characters.
- addonType : Addon type (e.g.,
can
for the CAN addon). - address :Addon address in
IP:PORT
form. - timeout :Connection timeout (seconds). The connection fails if it takes longer.
- useTLS : Whether to use TLS (
true
) or not (false
). If you enable TLS, make sure the addon accepts TLS links
Configuration Example
From Lua you can access the addon as follows.
Calls are specific to the addon type; for a CAN addon you might use:
local can = require("can")
-- Connect to the CAN addon
local ok, err = can.connect()
if not ok then
printError("Error connecting to CAN addon: " .. err)
return
end
-- Get parsed DBC data (list of messages and signals)
local resp, err = can.call("GetDBCData")
--[[
[{
"id" = 1,
"name" = 2,
"dlc" = 3,
"signals" = [{
"name" = 1,
"startBit" = 2,
"length" = 3,
"factor" = 4,
"offset" = 5,
"isSigned" = 6,
"isIntel" = 7,
}]
}]
]]
-- Stream of CAN frames with decoded signal values
local resp, err = can.call("SubscribeFrames")
--[[
{
"id" = 1,
"name" = 2,
"dlc" = 3,
"signals" = [{
"name" = 1,
"value" = 2,
}]
}
]]
-- Latest decoded signal values from the last CAN frame
local resp, err = can.call("GetCurrentSignalValues")
--[[
[{
"id" = 1,
"name" = 2,
"dlc" = 3,
"signals" = [{
"name" = 1,
"value" = 2,
}]
}]
]]
-- Disconnect from the CAN addon
local ok, err = can.disconnect()
if not ok then
printError("Error disconnecting from CAN addon: " .. err)
return
end
Associated Lua Fields
Field | Description |
---|---|
addon.name |
Returns the addon instance name. |
addon.type |
Returns the module type (can , etc.). |