Copyright (C) 2023, Axis Communications AB, Lund, Sweden. All Rights Reserved.
This repository contains the source code to build a small prototype ACAP version 3 application that exports events from AXIS Object Analytics (AOA) over Modbus using libmodbus. The application can be run in either server or client mode, meaning two Axis devices can be used to showcase it.
Note
The purpose of this repo is to serve as boilerplate code and keep things simple, hence it uses basic Modbus/TCP without TLS and such.
The build step creates eap
(embedded application package) packages that can
then be deployed on the target Axis device e.g. via the device's web UI.
For more information about the eap
files, their content, and other ways to
deploy, please see the
ACAP Developer Guide.
# With the environment initialized, use:
acap-build .
The handling of this is integrated in the Makefile, so if you have
Docker and make
on your computer all you need to do is:
make dockerbuild
or perhaps build in parallel:
make -j dockerbuild
If you do have Docker but no make
on your system:
# 32-bit ARM, e.g. ARTPEC-6- and ARTPEC-7-based devices
DOCKER_BUILDKIT=1 docker build --build-arg ARCH=armv7hf -o type=local,dest=. .
# 64-bit ARM, e.g. ARTPEC-8-based devices
DOCKER_BUILDKIT=1 docker build --build-arg ARCH=aarch64 -o type=local,dest=. .
Upload the ACAP application file (the file with the .eap
extension for the
camera's architecture) through the camera's web UI: Apps->Add app
The parameter settings are found in the three vertical dots menu:
Select if the application should run in Server or Client mode and what AOA scenario's events it should subscribe to (default: Scenario 1). If you run in Client mode, also make sure you have set the right hostname/IP address for the Modbus server you want to send the events to.
Use the camera's
applications/upload.cgi
to upload the ACAP application file (the file with the .eap
extension for the
camera's architecture):
curl -k --anyauth -u root:<password> \
-F packfil=@Modbus_Prototype_<version>_<architecture>.eap \
https://<camera hostname/ip>/axis-cgi/applications/upload.cgi
To start (or stop/restart/remove) the ACAP, you can make a call like this:
curl -k --anyauth -u root:<password> \
'https://<camera hostname/ip>/axis-cgi/applications/control.cgi?package=modbusacap&action=start'
Use the camera's param.cgi to list and set the application's parameters:
The call
curl -k --anyauth -u root:<password> \
'https://<camera hostname/ip>/axis-cgi/param.cgi?action=list&group=modbusacap'
will list the current settings:
root.Modbusacap.Mode=0
root.Modbusacap.Scenario=1
root.Modbusacap.Server=172.25.75.172
If you want to set the server to e.g. 192.168.42.21:
curl -k --anyauth -u root:<password> \
'https://<camera hostname/ip>/axis-cgi/param.cgi?action=update&root.Modbusacap.Server=192.168.42.21'
The application can be run in either client mode or server mode (default),
configured with the application parameter Mode
:
In client mode, it will subscribe to
AXIS Object Analytics
(AOA) events for the AOA scenario specified in the application parameter
Scenario
(default: Scenario 1) and send the trigger status (active/inactive)
over Modbus (TCP) to the Modbus server running on the host set in the ACAP's
parameter Server
.
In server mode, it will listen for incoming TCP requests and print incoming AOA status updates to the application log.
Important
The default Modbus/TCP port 502 requires running as a privileged user. In order to run as a non-privileged user, this ACAP only allows ports in the non-privileged range 1024–65535.