Run clang-format and enable CI check for it (#755)
* pre-commit: Update and enable clang-format check There is newer version from clang-format so use that. We do not yet want 18 as that is little bit too new. * Format some thing by hand which clang-format "breaks" Clang-format will format some things little bit off in some cases. Format some things by hand so we get cleaner end result. * Run clang-format with ``` pre-commit run --all-files clang-format ``` We have already in previously checked places where clang-format does not make good format and ignored those (hopefully most of the things). --------- Co-authored-by: Kari Argillander <kari.argillander@fidelix.com>
This commit is contained in:
+12
-8
@@ -49,7 +49,8 @@ void bacnet_init(void)
|
||||
apdu_set_confirmed_handler(
|
||||
SERVICE_CONFIRMED_WRITE_PROPERTY, handler_write_property);
|
||||
/* handle communication so we can shutup when asked */
|
||||
apdu_set_confirmed_handler(SERVICE_CONFIRMED_DEVICE_COMMUNICATION_CONTROL,
|
||||
apdu_set_confirmed_handler(
|
||||
SERVICE_CONFIRMED_DEVICE_COMMUNICATION_CONTROL,
|
||||
handler_device_communication_control);
|
||||
/* start the cyclic 1 second timer for DCC */
|
||||
mstimer_set(&DCC_Timer, DCC_CYCLE_SECONDS * 1000);
|
||||
@@ -57,14 +58,17 @@ void bacnet_init(void)
|
||||
Send_I_Am(&Handler_Transmit_Buffer[0]);
|
||||
}
|
||||
|
||||
/** Static receive buffer, initialized with zeros by the C Library Startup Code. */
|
||||
/** Static receive buffer, initialized with zeros by the C Library Startup Code.
|
||||
*/
|
||||
|
||||
static uint8_t PDUBuffer[MAX_MPDU + 16 /* Add a little safety margin to the buffer,
|
||||
* so that in the rare case, the message
|
||||
* would be filled up to MAX_MPDU and some
|
||||
* decoding functions would overrun, these
|
||||
* decoding functions will just end up in
|
||||
* a safe field of static zeros. */];
|
||||
static uint8_t PDUBuffer
|
||||
[MAX_MPDU + 16 /* Add a little safety margin to the buffer,
|
||||
* so that in the rare case, the message
|
||||
* would be filled up to MAX_MPDU and some
|
||||
* decoding functions would overrun, these
|
||||
* decoding functions will just end up in
|
||||
* a safe field of static zeros. */
|
||||
];
|
||||
|
||||
void bacnet_task(void)
|
||||
{
|
||||
|
||||
+8
-10
@@ -1,10 +1,10 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright (C) 2010 Steve Karg <skarg@users.sourceforge.net>
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*********************************************************************/
|
||||
*
|
||||
* Copyright (C) 2010 Steve Karg <skarg@users.sourceforge.net>
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*********************************************************************/
|
||||
#ifndef BACNET_H
|
||||
#define BACNET_H
|
||||
|
||||
@@ -14,10 +14,8 @@
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
void bacnet_init(
|
||||
void);
|
||||
void bacnet_task(
|
||||
void);
|
||||
void bacnet_init(void);
|
||||
void bacnet_task(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
+41
-24
@@ -37,25 +37,38 @@ static uint8_t Out_Of_Service[MAX_BINARY_OUTPUTS];
|
||||
static uint8_t Polarity[MAX_BINARY_OUTPUTS];
|
||||
|
||||
/* These three arrays are used by the ReadPropertyMultiple handler */
|
||||
static const int Binary_Output_Properties_Required[] = { PROP_OBJECT_IDENTIFIER,
|
||||
PROP_OBJECT_NAME, PROP_OBJECT_TYPE, PROP_PRESENT_VALUE, PROP_STATUS_FLAGS,
|
||||
PROP_EVENT_STATE, PROP_OUT_OF_SERVICE, PROP_POLARITY, PROP_PRIORITY_ARRAY,
|
||||
PROP_RELINQUISH_DEFAULT, -1 };
|
||||
static const int Binary_Output_Properties_Required[] = {
|
||||
PROP_OBJECT_IDENTIFIER,
|
||||
PROP_OBJECT_NAME,
|
||||
PROP_OBJECT_TYPE,
|
||||
PROP_PRESENT_VALUE,
|
||||
PROP_STATUS_FLAGS,
|
||||
PROP_EVENT_STATE,
|
||||
PROP_OUT_OF_SERVICE,
|
||||
PROP_POLARITY,
|
||||
PROP_PRIORITY_ARRAY,
|
||||
PROP_RELINQUISH_DEFAULT,
|
||||
-1
|
||||
};
|
||||
|
||||
static const int Binary_Output_Properties_Optional[] = { PROP_ACTIVE_TEXT,
|
||||
PROP_INACTIVE_TEXT, -1 };
|
||||
PROP_INACTIVE_TEXT,
|
||||
-1 };
|
||||
|
||||
static const int Binary_Output_Properties_Proprietary[] = { -1 };
|
||||
|
||||
void Binary_Output_Property_Lists(
|
||||
const int **pRequired, const int **pOptional, const int **pProprietary)
|
||||
{
|
||||
if (pRequired)
|
||||
if (pRequired) {
|
||||
*pRequired = Binary_Output_Properties_Required;
|
||||
if (pOptional)
|
||||
}
|
||||
if (pOptional) {
|
||||
*pOptional = Binary_Output_Properties_Optional;
|
||||
if (pProprietary)
|
||||
}
|
||||
if (pProprietary) {
|
||||
*pProprietary = Binary_Output_Properties_Proprietary;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -63,8 +76,9 @@ void Binary_Output_Property_Lists(
|
||||
/* we simply have 0-n object instances. */
|
||||
bool Binary_Output_Valid_Instance(uint32_t object_instance)
|
||||
{
|
||||
if (object_instance < MAX_BINARY_OUTPUTS)
|
||||
if (object_instance < MAX_BINARY_OUTPUTS) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -86,8 +100,9 @@ unsigned Binary_Output_Instance_To_Index(uint32_t object_instance)
|
||||
{
|
||||
unsigned index = MAX_BINARY_OUTPUTS;
|
||||
|
||||
if (object_instance < MAX_BINARY_OUTPUTS)
|
||||
if (object_instance < MAX_BINARY_OUTPUTS) {
|
||||
index = object_instance;
|
||||
}
|
||||
|
||||
return index;
|
||||
}
|
||||
@@ -135,8 +150,8 @@ bool Binary_Output_Present_Value_Set(
|
||||
return status;
|
||||
}
|
||||
|
||||
static void Binary_Output_Polarity_Set(
|
||||
uint32_t instance, BACNET_POLARITY polarity)
|
||||
static void
|
||||
Binary_Output_Polarity_Set(uint32_t instance, BACNET_POLARITY polarity)
|
||||
{
|
||||
if (instance < MAX_BINARY_OUTPUTS) {
|
||||
if (polarity < MAX_POLARITY) {
|
||||
@@ -241,9 +256,10 @@ int Binary_Output_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata)
|
||||
break;
|
||||
case PROP_PRIORITY_ARRAY:
|
||||
/* Array element zero is the number of elements in the array */
|
||||
if (rpdata->array_index == 0)
|
||||
if (rpdata->array_index == 0) {
|
||||
apdu_len =
|
||||
encode_application_unsigned(&apdu[0], BACNET_MAX_PRIORITY);
|
||||
}
|
||||
/* if no index was specified, then try to encode the entire list */
|
||||
/* into one packet. */
|
||||
else if (rpdata->array_index == BACNET_ARRAY_ALL) {
|
||||
@@ -260,9 +276,9 @@ int Binary_Output_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata)
|
||||
&apdu[apdu_len], present_value);
|
||||
}
|
||||
/* add it if we have room */
|
||||
if ((apdu_len + len) < MAX_APDU)
|
||||
if ((apdu_len + len) < MAX_APDU) {
|
||||
apdu_len += len;
|
||||
else {
|
||||
} else {
|
||||
rpdata->error_code =
|
||||
ERROR_CODE_ABORT_SEGMENTATION_NOT_SUPPORTED;
|
||||
apdu_len = BACNET_STATUS_ABORT;
|
||||
@@ -348,8 +364,8 @@ bool Binary_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
}
|
||||
switch (wp_data->object_property) {
|
||||
case PROP_PRESENT_VALUE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_ENUMERATED);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_ENUMERATED);
|
||||
if (status) {
|
||||
priority = wp_data->priority;
|
||||
/* Command priority 6 is reserved for use by Minimum On/Off
|
||||
@@ -375,8 +391,8 @@ bool Binary_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
wp_data->error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
||||
}
|
||||
} else {
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_NULL);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_NULL);
|
||||
if (status) {
|
||||
level = BINARY_NULL;
|
||||
priority = wp_data->priority;
|
||||
@@ -400,19 +416,20 @@ bool Binary_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
}
|
||||
break;
|
||||
case PROP_OUT_OF_SERVICE:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_BOOLEAN);
|
||||
if (status) {
|
||||
Binary_Output_Out_Of_Service_Set(
|
||||
wp_data->object_instance, value.type.Boolean);
|
||||
}
|
||||
break;
|
||||
case PROP_POLARITY:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_ENUMERATED);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_ENUMERATED);
|
||||
if (status) {
|
||||
if (value.type.Enumerated < MAX_POLARITY) {
|
||||
Binary_Output_Polarity_Set(wp_data->object_instance,
|
||||
Binary_Output_Polarity_Set(
|
||||
wp_data->object_instance,
|
||||
(BACNET_POLARITY)value.type.Enumerated);
|
||||
} else {
|
||||
status = false;
|
||||
|
||||
+73
-53
@@ -45,16 +45,18 @@ static struct my_object_functions {
|
||||
read_property_function Object_Read_Property;
|
||||
write_property_function Object_Write_Property;
|
||||
rpm_property_lists_function Object_RPM_List;
|
||||
} Object_Table[] = { { OBJECT_DEVICE, NULL, /* don't init - recursive! */
|
||||
Device_Count, Device_Index_To_Instance,
|
||||
Device_Valid_Object_Instance_Number, Device_Name,
|
||||
Device_Read_Property_Local,
|
||||
Device_Write_Property_Local, Device_Property_Lists },
|
||||
} Object_Table[] = {
|
||||
{ OBJECT_DEVICE, NULL, /* don't init - recursive! */
|
||||
Device_Count, Device_Index_To_Instance,
|
||||
Device_Valid_Object_Instance_Number, Device_Name,
|
||||
Device_Read_Property_Local, Device_Write_Property_Local,
|
||||
Device_Property_Lists },
|
||||
{ OBJECT_BINARY_OUTPUT, Binary_Output_Init, Binary_Output_Count,
|
||||
Binary_Output_Index_To_Instance, Binary_Output_Valid_Instance,
|
||||
Binary_Output_Name, Binary_Output_Read_Property,
|
||||
Binary_Output_Write_Property, Binary_Output_Property_Lists },
|
||||
{ MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL } };
|
||||
Binary_Output_Index_To_Instance, Binary_Output_Valid_Instance,
|
||||
Binary_Output_Name, Binary_Output_Read_Property,
|
||||
Binary_Output_Write_Property, Binary_Output_Property_Lists },
|
||||
{ MAX_BACNET_OBJECT_TYPE, NULL, NULL, NULL, NULL, NULL, NULL, NULL }
|
||||
};
|
||||
|
||||
/* note: you really only need to define variables for
|
||||
properties that are writable or that may change.
|
||||
@@ -73,23 +75,38 @@ static char Description[MAX_DEV_DESC_LEN + 1] = "Renesas Rulz!";
|
||||
static uint32_t Database_Revision = 0;
|
||||
|
||||
/* These three arrays are used by the ReadPropertyMultiple handler */
|
||||
static const int Device_Properties_Required[] = { PROP_OBJECT_IDENTIFIER,
|
||||
PROP_OBJECT_NAME, PROP_OBJECT_TYPE, PROP_SYSTEM_STATUS, PROP_VENDOR_NAME,
|
||||
PROP_VENDOR_IDENTIFIER, PROP_MODEL_NAME, PROP_FIRMWARE_REVISION,
|
||||
PROP_APPLICATION_SOFTWARE_VERSION, PROP_PROTOCOL_VERSION,
|
||||
PROP_PROTOCOL_REVISION, PROP_PROTOCOL_SERVICES_SUPPORTED,
|
||||
PROP_PROTOCOL_OBJECT_TYPES_SUPPORTED, PROP_OBJECT_LIST,
|
||||
PROP_MAX_APDU_LENGTH_ACCEPTED, PROP_SEGMENTATION_SUPPORTED,
|
||||
PROP_APDU_TIMEOUT, PROP_NUMBER_OF_APDU_RETRIES, PROP_MAX_MASTER,
|
||||
PROP_MAX_INFO_FRAMES, PROP_DEVICE_ADDRESS_BINDING, PROP_DATABASE_REVISION,
|
||||
-1 };
|
||||
static const int Device_Properties_Required[] = {
|
||||
PROP_OBJECT_IDENTIFIER,
|
||||
PROP_OBJECT_NAME,
|
||||
PROP_OBJECT_TYPE,
|
||||
PROP_SYSTEM_STATUS,
|
||||
PROP_VENDOR_NAME,
|
||||
PROP_VENDOR_IDENTIFIER,
|
||||
PROP_MODEL_NAME,
|
||||
PROP_FIRMWARE_REVISION,
|
||||
PROP_APPLICATION_SOFTWARE_VERSION,
|
||||
PROP_PROTOCOL_VERSION,
|
||||
PROP_PROTOCOL_REVISION,
|
||||
PROP_PROTOCOL_SERVICES_SUPPORTED,
|
||||
PROP_PROTOCOL_OBJECT_TYPES_SUPPORTED,
|
||||
PROP_OBJECT_LIST,
|
||||
PROP_MAX_APDU_LENGTH_ACCEPTED,
|
||||
PROP_SEGMENTATION_SUPPORTED,
|
||||
PROP_APDU_TIMEOUT,
|
||||
PROP_NUMBER_OF_APDU_RETRIES,
|
||||
PROP_MAX_MASTER,
|
||||
PROP_MAX_INFO_FRAMES,
|
||||
PROP_DEVICE_ADDRESS_BINDING,
|
||||
PROP_DATABASE_REVISION,
|
||||
-1
|
||||
};
|
||||
|
||||
static const int Device_Properties_Optional[] = { PROP_DESCRIPTION, -1 };
|
||||
|
||||
static const int Device_Properties_Proprietary[] = { -1 };
|
||||
|
||||
static struct my_object_functions *Device_Objects_Find_Functions(
|
||||
BACNET_OBJECT_TYPE Object_Type)
|
||||
static struct my_object_functions *
|
||||
Device_Objects_Find_Functions(BACNET_OBJECT_TYPE Object_Type)
|
||||
{
|
||||
struct my_object_functions *pObject = NULL;
|
||||
|
||||
@@ -148,14 +165,10 @@ static int Read_Property_Common(
|
||||
#if (BACNET_PROTOCOL_REVISION >= 14)
|
||||
case PROP_PROPERTY_LIST:
|
||||
Device_Objects_Property_List(
|
||||
rpdata->object_type,
|
||||
rpdata->object_instance,
|
||||
&property_list);
|
||||
rpdata->object_type, rpdata->object_instance, &property_list);
|
||||
apdu_len = property_list_encode(
|
||||
rpdata,
|
||||
property_list.Required.pList,
|
||||
property_list.Optional.pList,
|
||||
property_list.Proprietary.pList);
|
||||
rpdata, property_list.Required.pList,
|
||||
property_list.Optional.pList, property_list.Proprietary.pList);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
@@ -193,7 +206,8 @@ static unsigned property_list_count(const int *pList)
|
||||
* list, separately, the Required, Optional, and Proprietary object
|
||||
* properties with their counts.
|
||||
*/
|
||||
void Device_Objects_Property_List(BACNET_OBJECT_TYPE object_type,
|
||||
void Device_Objects_Property_List(
|
||||
BACNET_OBJECT_TYPE object_type,
|
||||
uint32_t object_instance,
|
||||
struct special_property_list_t *pPropertyList)
|
||||
{
|
||||
@@ -211,8 +225,9 @@ void Device_Objects_Property_List(BACNET_OBJECT_TYPE object_type,
|
||||
|
||||
pObject = Device_Objects_Find_Functions(object_type);
|
||||
if ((pObject != NULL) && (pObject->Object_RPM_List != NULL)) {
|
||||
pObject->Object_RPM_List(&pPropertyList->Required.pList,
|
||||
&pPropertyList->Optional.pList, &pPropertyList->Proprietary.pList);
|
||||
pObject->Object_RPM_List(
|
||||
&pPropertyList->Required.pList, &pPropertyList->Optional.pList,
|
||||
&pPropertyList->Proprietary.pList);
|
||||
}
|
||||
|
||||
/* Fetch the counts if available otherwise zero them */
|
||||
@@ -234,12 +249,15 @@ void Device_Objects_Property_List(BACNET_OBJECT_TYPE object_type,
|
||||
void Device_Property_Lists(
|
||||
const int **pRequired, const int **pOptional, const int **pProprietary)
|
||||
{
|
||||
if (pRequired)
|
||||
if (pRequired) {
|
||||
*pRequired = Device_Properties_Required;
|
||||
if (pOptional)
|
||||
}
|
||||
if (pOptional) {
|
||||
*pOptional = Device_Properties_Optional;
|
||||
if (pProprietary)
|
||||
}
|
||||
if (pProprietary) {
|
||||
*pProprietary = Device_Properties_Proprietary;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -364,8 +382,9 @@ bool Device_Set_Object_Instance_Number(uint32_t object_id)
|
||||
|
||||
if (object_id <= BACNET_MAX_INSTANCE) {
|
||||
Object_Instance_Number = object_id;
|
||||
} else
|
||||
} else {
|
||||
status = false;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
@@ -584,7 +603,8 @@ int Device_Object_List_Element_Encode(
|
||||
* Object.
|
||||
* @return True on success or else False if not found.
|
||||
*/
|
||||
bool Device_Valid_Object_Name(const char *object_name,
|
||||
bool Device_Valid_Object_Name(
|
||||
const char *object_name,
|
||||
BACNET_OBJECT_TYPE *object_type,
|
||||
uint32_t *object_instance)
|
||||
{
|
||||
@@ -617,8 +637,8 @@ bool Device_Valid_Object_Name(const char *object_name,
|
||||
}
|
||||
|
||||
/* returns the name or NULL if not found */
|
||||
char *Device_Valid_Object_Id(
|
||||
BACNET_OBJECT_TYPE object_type, uint32_t object_instance)
|
||||
char *
|
||||
Device_Valid_Object_Id(BACNET_OBJECT_TYPE object_type, uint32_t object_instance)
|
||||
{
|
||||
char *name = NULL; /* return value */
|
||||
struct my_object_functions *pObject = NULL;
|
||||
@@ -701,7 +721,8 @@ int Device_Read_Property_Local(BACNET_READ_PROPERTY_DATA *rpdata)
|
||||
bitstring_init(&bit_string);
|
||||
for (i = 0; i < MAX_BACNET_SERVICES_SUPPORTED; i++) {
|
||||
/* automatic lookup based on handlers set */
|
||||
bitstring_set_bit(&bit_string, (uint8_t)i,
|
||||
bitstring_set_bit(
|
||||
&bit_string, (uint8_t)i,
|
||||
apdu_service_supported((BACNET_SERVICES_SUPPORTED)i));
|
||||
}
|
||||
apdu_len = encode_application_bitstring(&apdu[0], &bit_string);
|
||||
@@ -728,10 +749,9 @@ int Device_Read_Property_Local(BACNET_READ_PROPERTY_DATA *rpdata)
|
||||
break;
|
||||
case PROP_OBJECT_LIST:
|
||||
count = Device_Object_List_Count();
|
||||
apdu_len = bacnet_array_encode(rpdata->object_instance,
|
||||
rpdata->array_index,
|
||||
Device_Object_List_Element_Encode,
|
||||
count, apdu, apdu_max);
|
||||
apdu_len = bacnet_array_encode(
|
||||
rpdata->object_instance, rpdata->array_index,
|
||||
Device_Object_List_Element_Encode, count, apdu, apdu_max);
|
||||
if (apdu_len == BACNET_STATUS_ABORT) {
|
||||
rpdata->error_code =
|
||||
ERROR_CODE_ABORT_SEGMENTATION_NOT_SUPPORTED;
|
||||
@@ -837,8 +857,8 @@ bool Device_Write_Property_Local(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
}
|
||||
switch (wp_data->object_property) {
|
||||
case PROP_OBJECT_IDENTIFIER:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_OBJECT_ID);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_OBJECT_ID);
|
||||
if (status) {
|
||||
if ((value.type.Object_Id.type == OBJECT_DEVICE) &&
|
||||
(Device_Set_Object_Instance_Number(
|
||||
@@ -853,8 +873,8 @@ bool Device_Write_Property_Local(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
}
|
||||
break;
|
||||
case PROP_SYSTEM_STATUS:
|
||||
status = write_property_type_valid(wp_data, &value,
|
||||
BACNET_APPLICATION_TAG_ENUMERATED);
|
||||
status = write_property_type_valid(
|
||||
wp_data, &value, BACNET_APPLICATION_TAG_ENUMERATED);
|
||||
if (status) {
|
||||
temp = Device_Set_System_Status(
|
||||
(BACNET_DEVICE_STATUS)value.type.Enumerated, false);
|
||||
@@ -871,8 +891,8 @@ bool Device_Write_Property_Local(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
}
|
||||
break;
|
||||
case PROP_OBJECT_NAME:
|
||||
status = write_property_string_valid(&wp_data, &value,
|
||||
MAX_DEV_NAME_LEN);
|
||||
status =
|
||||
write_property_string_valid(&wp_data, &value, MAX_DEV_NAME_LEN);
|
||||
if (status) {
|
||||
Device_Set_Object_Name(
|
||||
characterstring_value(&value.type.Character_String),
|
||||
@@ -880,8 +900,8 @@ bool Device_Write_Property_Local(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
}
|
||||
break;
|
||||
case PROP_LOCATION:
|
||||
status = write_property_empty_string_valid(&wp_data, &value,
|
||||
MAX_DEV_LOC_LEN);
|
||||
status = write_property_empty_string_valid(
|
||||
&wp_data, &value, MAX_DEV_LOC_LEN);
|
||||
if (status) {
|
||||
Device_Set_Location(
|
||||
characterstring_value(&value.type.Character_String),
|
||||
@@ -890,8 +910,8 @@ bool Device_Write_Property_Local(BACNET_WRITE_PROPERTY_DATA *wp_data)
|
||||
break;
|
||||
|
||||
case PROP_DESCRIPTION:
|
||||
status = write_property_empty_string_valid(&wp_data, &value,
|
||||
MAX_DEV_DESC_LEN);
|
||||
status = write_property_empty_string_valid(
|
||||
&wp_data, &value, MAX_DEV_DESC_LEN);
|
||||
if (status) {
|
||||
Device_Set_Description(
|
||||
characterstring_value(&value.type.Character_String),
|
||||
|
||||
+16
-10
@@ -16,8 +16,8 @@
|
||||
for BACnet/Ethernet. */
|
||||
|
||||
/* commonly used comparison address for ethernet */
|
||||
static uint8_t Ethernet_Broadcast[MAX_MAC_LEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF };
|
||||
static uint8_t Ethernet_Broadcast[MAX_MAC_LEN] = { 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF };
|
||||
|
||||
/* IEEE maintains list of 48-bit MAC "addresses" AKA EUI-48 identifiers.
|
||||
An EUI-48 is structured into an initial 3-octet OUI
|
||||
@@ -26,8 +26,8 @@ static uint8_t Ethernet_Broadcast[MAX_MAC_LEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
/* see [RFC5342] for current information and registration procedures. */
|
||||
/* The OUI 00-00-5E has been allocated to IANA. */
|
||||
/* my local device data - MAC address */
|
||||
static uint8_t Ethernet_MAC_Address[MAX_MAC_LEN] = { 0x00, 0x00, 0x5E, 0x00,
|
||||
0x00, 0x01 };
|
||||
static uint8_t Ethernet_MAC_Address[MAX_MAC_LEN] = { 0x00, 0x00, 0x5E,
|
||||
0x00, 0x00, 0x01 };
|
||||
|
||||
/* status of the link */
|
||||
static int32_t Ethernet_Status = R_ETHER_ERROR;
|
||||
@@ -69,7 +69,8 @@ int ethernet_send(uint8_t *mtu, int mtu_len)
|
||||
|
||||
/* function to send a packet out the 802.2 socket */
|
||||
/* returns number of bytes sent on success, negative on failure */
|
||||
int ethernet_send_pdu(BACNET_ADDRESS *dest, /* destination address */
|
||||
int ethernet_send_pdu(
|
||||
BACNET_ADDRESS *dest, /* destination address */
|
||||
BACNET_NPDU_DATA *npdu_data, /* network information */
|
||||
uint8_t *pdu, /* any data to be sent - may be null */
|
||||
unsigned pdu_len)
|
||||
@@ -129,7 +130,8 @@ int ethernet_send_pdu(BACNET_ADDRESS *dest, /* destination address */
|
||||
|
||||
/* receives an 802.2 framed packet */
|
||||
/* returns the number of octets in the PDU, or zero on failure */
|
||||
uint16_t ethernet_receive(BACNET_ADDRESS *src, /* source address */
|
||||
uint16_t ethernet_receive(
|
||||
BACNET_ADDRESS *src, /* source address */
|
||||
uint8_t *pdu, /* PDU data */
|
||||
uint16_t max_pdu, /* amount of space available in the PDU */
|
||||
unsigned timeout)
|
||||
@@ -139,13 +141,15 @@ uint16_t ethernet_receive(BACNET_ADDRESS *src, /* source address */
|
||||
uint16_t pdu_len = 0; /* return value */
|
||||
|
||||
/* Make sure the socket is open */
|
||||
if (!ethernet_valid())
|
||||
if (!ethernet_valid()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
received_bytes = R_Ether_Read(0, (void *)buf);
|
||||
|
||||
if (received_bytes == 0)
|
||||
if (received_bytes == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* the signature of an 802.2 BACnet packet */
|
||||
if ((buf[14] != 0x82) && (buf[15] != 0x82)) {
|
||||
@@ -165,11 +169,13 @@ uint16_t ethernet_receive(BACNET_ADDRESS *src, /* source address */
|
||||
(void)decode_unsigned16(&buf[12], &pdu_len);
|
||||
pdu_len -= 3 /* DSAP, SSAP, LLC Control */;
|
||||
/* copy the buffer into the PDU */
|
||||
if (pdu_len < max_pdu)
|
||||
if (pdu_len < max_pdu) {
|
||||
memmove(&pdu[0], &buf[17], pdu_len);
|
||||
}
|
||||
/* ignore packets that are too large */
|
||||
else
|
||||
else {
|
||||
pdu_len = 0;
|
||||
}
|
||||
|
||||
return pdu_len;
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright (C) 2011 Steve Karg <skarg@users.sourceforge.net>
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*********************************************************************/
|
||||
*
|
||||
* Copyright (C) 2011 Steve Karg <skarg@users.sourceforge.net>
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*********************************************************************/
|
||||
#ifndef HARDWARE_H
|
||||
#define HARDWARE_H
|
||||
|
||||
|
||||
+14
-24
@@ -1,10 +1,10 @@
|
||||
/**************************************************************************
|
||||
*
|
||||
* Copyright (C) 2009 Steve Karg <skarg@users.sourceforge.net>
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*********************************************************************/
|
||||
*
|
||||
* Copyright (C) 2009 Steve Karg <skarg@users.sourceforge.net>
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
*********************************************************************/
|
||||
#ifndef LED_H
|
||||
#define LED_H
|
||||
|
||||
@@ -15,24 +15,14 @@
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
void led_on(
|
||||
uint8_t index);
|
||||
void led_on_interval(
|
||||
uint8_t index,
|
||||
uint16_t interval_ms);
|
||||
void led_off(
|
||||
uint8_t index);
|
||||
void led_off_delay(
|
||||
uint8_t index,
|
||||
uint32_t delay_ms);
|
||||
void led_toggle(
|
||||
uint8_t index);
|
||||
bool led_state(
|
||||
uint8_t index);
|
||||
void led_task(
|
||||
void);
|
||||
void led_init(
|
||||
void);
|
||||
void led_on(uint8_t index);
|
||||
void led_on_interval(uint8_t index, uint16_t interval_ms);
|
||||
void led_off(uint8_t index);
|
||||
void led_off_delay(uint8_t index, uint32_t delay_ms);
|
||||
void led_toggle(uint8_t index);
|
||||
bool led_state(uint8_t index);
|
||||
void led_task(void);
|
||||
void led_init(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user