Skip to content

Commit

Permalink
Improve documentation and log output
Browse files Browse the repository at this point in the history
This patchset improves the description of how client/server mode is
used. It also updates some log prints to make things clearer.

Change-Id: I11583812546138c4015dd3842277f797b4c7d160
Signed-off-by: Joakim Roubert <joakimr@axis.com>
  • Loading branch information
joakimr-axis committed Oct 25, 2024
1 parent a5428e9 commit c69190f
Show file tree
Hide file tree
Showing 7 changed files with 3,575 additions and 16 deletions.
36 changes: 24 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,23 +120,35 @@ curl -k --anyauth -u root:<password> \

## Usage

The application can be run in either client mode or server mode (default),
> [!IMPORTANT]
> The default Modbus/TCP port 502 requires running as a privileged user.
> In order to run as a non-privileged user, this ACAP application only allows
> ports in the non-privileged range 1024–65535.
The application can be run in either *client* mode (default) or *server* mode,
configured with the application parameter `Mode`:

In client mode, it will subscribe to
### Client mode (default)

![Camera to modbus device](images/cam_to_modbus.svg)

The application subscribes to
[AXIS Object Analytics](https://www.axis.com/products/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`.
(AOA) events for the specified scenario *(default: Scenario 1)* and sends
trigger status *(active/inactive)* over Modbus (TCP) to the server specified
in the application configuration. **This the typical use case** where the Axis
device pushes AOA events to a receiving Modbus device.

In server mode, it will listen for incoming TCP requests and print incoming
AOA status updates to the application log.
### Server mode

> [!IMPORTANT]
> The default Modbus/TCP port 502 requires running as a privileged user.
> In order to run as a non-privileged user, this ACAP application only allows
> ports in the non-privileged range 1024–65535.
![Camera to other camera](images/cam_to_cam.svg)

In server mode, the application listens for incoming TCP requests and logs AOA
status updates from a connected device running in client mode. **This mode is
useful for testing and debugging without a separate Modbus device.**
*In server mode, the application also subscribes to AOA events from its host
device, but does not send them anywhere. That is solely for easy debugging and
testing the application's subscription mechanism.*

## License

Expand Down
2,628 changes: 2,628 additions & 0 deletions images/cam_to_cam.graphml

Large diffs are not rendered by default.

41 changes: 41 additions & 0 deletions images/cam_to_cam.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
766 changes: 766 additions & 0 deletions images/cam_to_modbus.graphml

Large diffs are not rendered by default.

105 changes: 105 additions & 0 deletions images/cam_to_modbus.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
"vendor": "Axis Communications AB",
"embeddedSdkVersion": "3.0",
"runMode": "respawn",
"version": "1.2.1"
"version": "1.2.2"
},
"configuration": {
"settingPage": "config.html",
"paramConfig": [
{"name": "Mode", "type": "enum:0|Server, 1|Client", "default": "0"},
{"name": "Mode", "type": "enum:0|Server, 1|Client", "default": "1"},
{"name": "Port", "type": "int:min=1024,max=65535", "default": "5020"},
{"name": "Scenario", "type": "int:min=1,max=99", "default": "1"},
{"name": "Server", "type": "string", "default": "172.25.75.172"}
Expand Down
11 changes: 9 additions & 2 deletions modbusacap.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ static void event_callback(guint subscription, AXEvent *event, void *data)

if (ax_event_key_value_set_get_boolean(key_value_set, "active", NULL, &active, NULL))
{
LOG_I("aoa-event %s active", active ? "is" : "NOT");
LOG_I(
"aoa-event %s active (%s)",
active ? "is" : "NOT",
CLIENT == mode ? "running in client mode, passing on via Modbus"
: "running in server mode, not forwarded anywhere");
// Send event over Modbus
if (CLIENT == mode)
{
Expand All @@ -76,7 +80,10 @@ static void event_callback(guint subscription, AXEvent *event, void *data)
}
else
{
LOG_I("%s/%s: Failed to get boolean value active from event", __FILE__, __FUNCTION__);
LOG_I(
"%s/%s: Received event without boolean value 'active' (probably not a stateful event)",
__FILE__,
__FUNCTION__);
}

// Free the received event, n.b. AXEventKeyValueSet should not be freed
Expand Down

0 comments on commit c69190f

Please sign in to comment.