369da70f2a
* format: Strip trailing whitespaces
We want to get rid of trailing whitespaces completly as they make just git
noice. Much better to start using automated tools to get rid of them once and
not getting them back again. This way git history will be cleaner and review
easier.
Commit was generated with:
pre-commit run --all-files trailing-whitespace
* format: Files should have exactly one new line end of them
It is good practice that every file has one new line. It is not now days so
mandatory but it also is not nice if file has lot of newlines end of it. We will
use pre-commit which takes automatically care about this so let's fix all.
Commit was generated with:
pre-commit run --all-files end-of-file-fixer
* format: Convert tabs to spaces
Project mostly use spaces over tabs. When mixing tabs and spaces this usually
makes formatting issues and also when changing those in commits it will make lot
of git noise. We will force spaces most of the time and use pre-commit to fix.
Commit was generated with:
pre-commit run --all-files remove-tabs
---------
Co-authored-by: Kari Argillander <kari.argillander@fidelix.com>
58 lines
1.6 KiB
C
58 lines
1.6 KiB
C
/**
|
|
* @file
|
|
* @brief BACnet shell commands for debugging and testing
|
|
* @author Steve Karg <skarg@users.sourceforge.net>
|
|
* @date May 2024
|
|
* @copyright SPDX-License-Identifier: MIT
|
|
*/
|
|
#include <stdlib.h>
|
|
#include <stdint.h>
|
|
#include <errno.h>
|
|
#include <zephyr/shell/shell.h>
|
|
/* BACnet definitions */
|
|
#include "bacnet/bacdef.h"
|
|
#include "bacnet/bacdcode.h"
|
|
#include "bacnet/bactext.h"
|
|
#include "bacnet/bacapp.h"
|
|
/* BACnet objects API */
|
|
#include "bacnet/basic/object/device.h"
|
|
/* Basic BACnet */
|
|
#include "bacnet_basic/bacnet_basic.h"
|
|
|
|
/**
|
|
* @brief List all BACnet objects in this device
|
|
* @param sh Shell
|
|
* @param argc Number of arguments
|
|
* @param argv Argument list
|
|
* @return 0 on success, negative on failure
|
|
*/
|
|
static int cmd_objects(const struct shell *sh, size_t argc, char **argv)
|
|
{
|
|
int count;
|
|
BACNET_OBJECT_TYPE object_type;
|
|
uint32_t instance;
|
|
uint32_t array_index;
|
|
bool found;
|
|
|
|
(void)argc;
|
|
(void)argv;
|
|
shell_print(sh, "List of BACnet Objects: [{");
|
|
count = Device_Object_List_Count();
|
|
for (array_index = 1; array_index <= count; array_index++) {
|
|
found = Device_Object_List_Identifier(array_index, &object_type,
|
|
&instance);
|
|
if (found) {
|
|
shell_print(sh, " \"%s-%u\"%c",
|
|
bactext_object_type_name(object_type),
|
|
instance,
|
|
(array_index == count) ? ' ' : ',');
|
|
}
|
|
}
|
|
shell_print(sh, "}] -- %d objects found", count);
|
|
|
|
return 0;
|
|
}
|
|
|
|
SHELL_SUBCMD_ADD((bacnet), objects, NULL, "list of BACnet objects", cmd_objects,
|
|
1, 0);
|