Make most of functions const correct (#714)
* Make most of the functions const correct
Used clang-tidy and sonarlint to help find places where const could
pretty easily applied. Also lot of hand work.
This commit does not yet touch handlers and typedefs of those.
* Fix Arduino uno handler_who_is() has extra parenthesis
For some reason there is extra parenthesis. Remove it this is more
likely buildable.
* Bugfix/bacapp: Fix uninitilized array_index
We have changed bacapp_snprintf_value() to be const correct. After that
we got
```
/home/runner/work/bacnet-stack/bacnet-stack/src/bacnet/bacapp.c:3183:27: warning: 4th function call argument is an uninitialized value [core.CallAndMessage]
ret_val = bacapp_snprintf_weeklyschedule(
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
```
So analyzer could now spot that we do not actually initilize array_index
at all. Fix this by setting array_index to zero. Note that I actually do
not know if zeroing is right thing to do here. I choose zero as if this
has worked before it is most likely that it will work with zero value.
* cmake: Add and ignore Wwrite-strings compiler option
Wwrite-strings helps find places where const correctness is broken.
Example it will warn about these
```C
void func1(char* str);
func("test") /* "test" is const so we should not pass it to func1().
char* func2()
{
return "test"; /* func2() should return const char*.
}
```
We still need to ignore it as not all are fixed but let's add it already
so we remember that it should be opened at some point.
---------
Co-authored-by: Kari Argillander <kari.argillander@fidelix.com>
This commit is contained in:
@@ -112,6 +112,7 @@ if (CMAKE_C_COMPILER_ID MATCHES "Clang" OR CMAKE_C_COMPILER_ID MATCHES "AppleCla
|
||||
add_compile_options(-Wswitch-default)
|
||||
add_compile_options(-Wunused-variable)
|
||||
add_compile_options(-Wcast-qual)
|
||||
add_compile_options(-Wwrite-strings)
|
||||
|
||||
# Don't warn about conversion, sign, compares since they are common in
|
||||
# embedded
|
||||
@@ -138,6 +139,7 @@ if (CMAKE_C_COMPILER_ID MATCHES "Clang" OR CMAKE_C_COMPILER_ID MATCHES "AppleCla
|
||||
add_compile_options(-Wno-float-conversion)
|
||||
add_compile_options(-Wno-missing-declarations)
|
||||
add_compile_options(-Wno-unused-but-set-variable)
|
||||
add_compile_options(-Wno-write-strings)
|
||||
elseif(MSVC)
|
||||
add_compile_options(/Wall)
|
||||
|
||||
|
||||
+3
-3
@@ -74,14 +74,14 @@ static void Init_Service_Handlers(void)
|
||||
apdu_set_reject_handler(MyRejectHandler);
|
||||
}
|
||||
|
||||
static void print_usage(char *filename)
|
||||
static void print_usage(const char *filename)
|
||||
{
|
||||
printf("Usage: %s [abort-reason [invoke-id [server]]]\n", filename);
|
||||
printf(" [--dnet][--dadr][--mac]\n");
|
||||
printf(" [--version][--help]\n");
|
||||
}
|
||||
|
||||
static void print_help(char *filename)
|
||||
static void print_help(const char *filename)
|
||||
{
|
||||
printf("Send BACnet Abort message to the network.\n");
|
||||
printf("--mac A\n"
|
||||
@@ -123,7 +123,7 @@ int main(int argc, char *argv[])
|
||||
bool specific_address = false;
|
||||
int argi = 0;
|
||||
unsigned int target_args = 0;
|
||||
char *filename = NULL;
|
||||
const char *filename = NULL;
|
||||
|
||||
filename = filename_remove_path(argv[0]);
|
||||
for (argi = 1; argi < argc; argi++) {
|
||||
|
||||
@@ -141,7 +141,7 @@ static void Init_Service_Handlers(void)
|
||||
apdu_set_reject_handler(MyRejectHandler);
|
||||
}
|
||||
|
||||
static void print_usage(char *filename)
|
||||
static void print_usage(const char *filename)
|
||||
{
|
||||
printf("Usage: %s device-id process-id\n"
|
||||
" event-object-type event-object-instance event-state-acked\n"
|
||||
@@ -151,7 +151,7 @@ static void print_usage(char *filename)
|
||||
printf(" [--version][--help]\n");
|
||||
}
|
||||
|
||||
static void print_help(char *filename)
|
||||
static void print_help(const char *filename)
|
||||
{
|
||||
printf("Send BACnet AcknowledgedAlarm, message to a device.\n");
|
||||
printf("device-id:\n"
|
||||
@@ -222,7 +222,7 @@ int main(int argc, char *argv[])
|
||||
bool specific_address = false;
|
||||
int argi = 0;
|
||||
unsigned int target_args = 0;
|
||||
char *filename = NULL;
|
||||
const char *filename = NULL;
|
||||
|
||||
filename = filename_remove_path(argv[0]);
|
||||
for (argi = 1; argi < argc; argi++) {
|
||||
|
||||
@@ -137,7 +137,7 @@ static void Init_Service_Handlers(void)
|
||||
apdu_set_reject_handler(MyRejectHandler);
|
||||
}
|
||||
|
||||
static void print_usage(char *filename)
|
||||
static void print_usage(const char *filename)
|
||||
{
|
||||
printf("Usage: %s device-instance object-type object-instance "
|
||||
"property array-index tag value\n",
|
||||
@@ -146,7 +146,7 @@ static void print_usage(char *filename)
|
||||
printf(" [--version][--help][--verbose]\n");
|
||||
}
|
||||
|
||||
static void print_help(char *filename)
|
||||
static void print_help(const char *filename)
|
||||
{
|
||||
printf("Add a BACnetLIST element to a property of an object\n"
|
||||
"in a BACnet device.\n");
|
||||
@@ -244,7 +244,7 @@ int main(int argc, char *argv[])
|
||||
bool specific_address = false;
|
||||
unsigned int target_args = 0;
|
||||
int argi = 0;
|
||||
char *filename = NULL;
|
||||
const char *filename = NULL;
|
||||
|
||||
filename = filename_remove_path(argv[0]);
|
||||
for (argi = 1; argi < argc; argi++) {
|
||||
|
||||
+4
-4
@@ -123,7 +123,7 @@ static void init_service_handlers(void)
|
||||
/**
|
||||
* @brief Print the usage message
|
||||
*/
|
||||
static void print_usage(char *filename)
|
||||
static void print_usage(const char *filename)
|
||||
{
|
||||
printf("Usage: %s", filename);
|
||||
printf(" <device-instance> <hex-ASCII>\n");
|
||||
@@ -135,7 +135,7 @@ static void print_usage(char *filename)
|
||||
/**
|
||||
* @brief Print the help message
|
||||
*/
|
||||
static void print_help(char *filename)
|
||||
static void print_help(const char *filename)
|
||||
{
|
||||
printf("Send an arbitrary BACnet APDU to a device.\n");
|
||||
printf("\n");
|
||||
@@ -199,7 +199,7 @@ static void print_help(char *filename)
|
||||
* @param buffer_len [in] The size of the buffer.
|
||||
*/
|
||||
static void Send_APDU_To_Network(
|
||||
BACNET_ADDRESS *target_address, uint8_t *buffer, size_t buffer_len)
|
||||
BACNET_ADDRESS *target_address, const uint8_t *buffer, size_t buffer_len)
|
||||
{
|
||||
int pdu_len = 0;
|
||||
int bytes_sent = 0;
|
||||
@@ -288,7 +288,7 @@ int main(int argc, char *argv[])
|
||||
bool found = false;
|
||||
int argi = 0;
|
||||
unsigned int target_args = 0;
|
||||
char *filename = NULL;
|
||||
const char *filename = NULL;
|
||||
bool repeat_forever = false;
|
||||
long retry_count = 1;
|
||||
|
||||
|
||||
@@ -462,7 +462,7 @@ bool Device_Object_Name(
|
||||
return status;
|
||||
}
|
||||
|
||||
bool Device_Set_Object_Name(BACNET_CHARACTER_STRING *object_name)
|
||||
bool Device_Set_Object_Name(const BACNET_CHARACTER_STRING *object_name)
|
||||
{
|
||||
bool status = false; /*return value */
|
||||
|
||||
@@ -1198,7 +1198,7 @@ int Device_Read_Property_Local(BACNET_READ_PROPERTY_DATA *rpdata)
|
||||
* @return The length of the APDU on success, else BACNET_STATUS_ERROR
|
||||
*/
|
||||
static int Read_Property_Common(
|
||||
struct object_functions *pObject, BACNET_READ_PROPERTY_DATA *rpdata)
|
||||
const struct object_functions *pObject, BACNET_READ_PROPERTY_DATA *rpdata)
|
||||
{
|
||||
int apdu_len = BACNET_STATUS_ERROR;
|
||||
BACNET_CHARACTER_STRING char_string;
|
||||
|
||||
+1
-1
@@ -343,7 +343,7 @@ int main(int argc, char *argv[])
|
||||
unsigned int target_args = 0;
|
||||
uint32_t device_id = BACNET_MAX_INSTANCE;
|
||||
int argi = 0;
|
||||
char *filename = NULL;
|
||||
const char *filename = NULL;
|
||||
|
||||
filename = filename_remove_path(argv[0]);
|
||||
for (argi = 1; argi < argc; argi++) {
|
||||
|
||||
@@ -175,7 +175,7 @@ static void Init_Service_Handlers(void)
|
||||
apdu_set_reject_handler(MyRejectHandler);
|
||||
}
|
||||
|
||||
static void print_usage(char *filename)
|
||||
static void print_usage(const char *filename)
|
||||
{
|
||||
printf(
|
||||
"Usage: %s device-instance object-type [object-instance]\n", filename);
|
||||
@@ -183,7 +183,7 @@ static void print_usage(char *filename)
|
||||
printf(" [--version][--help][--verbose]\n");
|
||||
}
|
||||
|
||||
static void print_help(char *filename)
|
||||
static void print_help(const char *filename)
|
||||
{
|
||||
printf("Create an object in a BACnet device.\n");
|
||||
printf("\n");
|
||||
@@ -232,7 +232,7 @@ int main(int argc, char *argv[])
|
||||
bool specific_address = false;
|
||||
unsigned int target_args = 0;
|
||||
int argi = 0;
|
||||
char *filename = NULL;
|
||||
const char *filename = NULL;
|
||||
|
||||
filename = filename_remove_path(argv[0]);
|
||||
for (argi = 1; argi < argc; argi++) {
|
||||
|
||||
+3
-3
@@ -116,13 +116,13 @@ static void Init_Service_Handlers(void)
|
||||
apdu_set_reject_handler(MyRejectHandler);
|
||||
}
|
||||
|
||||
static void print_usage(char *filename)
|
||||
static void print_usage(const char *filename)
|
||||
{
|
||||
printf("Usage: %s device-instance state [timeout [password]]\n", filename);
|
||||
printf(" [--version][--help]\n");
|
||||
}
|
||||
|
||||
static void print_help(char *filename)
|
||||
static void print_help(const char *filename)
|
||||
{
|
||||
printf(
|
||||
"Send BACnet DeviceCommunicationControl service to device.\n"
|
||||
@@ -155,7 +155,7 @@ int main(int argc, char *argv[])
|
||||
uint8_t invoke_id = 0;
|
||||
bool found = false;
|
||||
int argi = 0;
|
||||
char *filename = NULL;
|
||||
const char *filename = NULL;
|
||||
|
||||
filename = filename_remove_path(argv[0]);
|
||||
for (argi = 1; argi < argc; argi++) {
|
||||
|
||||
@@ -136,7 +136,7 @@ static void Init_Service_Handlers(void)
|
||||
apdu_set_reject_handler(MyRejectHandler);
|
||||
}
|
||||
|
||||
static void print_usage(char *filename)
|
||||
static void print_usage(const char *filename)
|
||||
{
|
||||
printf("Usage: %s device-instance object-type object-instance\n",
|
||||
filename);
|
||||
@@ -144,7 +144,7 @@ static void print_usage(char *filename)
|
||||
printf(" [--version][--help][--verbose]\n");
|
||||
}
|
||||
|
||||
static void print_help(char *filename)
|
||||
static void print_help(const char *filename)
|
||||
{
|
||||
printf("Create an object in a BACnet device.\n");
|
||||
printf("\n");
|
||||
@@ -193,7 +193,7 @@ int main(int argc, char *argv[])
|
||||
bool specific_address = false;
|
||||
unsigned int target_args = 0;
|
||||
int argi = 0;
|
||||
char *filename = NULL;
|
||||
const char *filename = NULL;
|
||||
|
||||
filename = filename_remove_path(argv[0]);
|
||||
for (argi = 1; argi < argc; argi++) {
|
||||
|
||||
+4
-4
@@ -710,7 +710,7 @@ static void BuildPropRequest(BACNET_READ_ACCESS_DATA *rpm_object)
|
||||
* of the property list.
|
||||
*/
|
||||
static uint8_t Read_Properties(
|
||||
uint32_t device_instance, BACNET_OBJECT_ID *pMyObject)
|
||||
uint32_t device_instance, const BACNET_OBJECT_ID *pMyObject)
|
||||
{
|
||||
uint8_t invoke_id = 0;
|
||||
struct special_property_list_t PropertyListStruct;
|
||||
@@ -884,7 +884,7 @@ static EPICS_STATES ProcessRPMData(
|
||||
return nextState;
|
||||
}
|
||||
|
||||
static void print_usage(char *filename)
|
||||
static void print_usage(const char *filename)
|
||||
{
|
||||
printf("Usage: %s [-v] [-d] [-p sport] [-t target_mac [-n dnet]]"
|
||||
" device-instance\n",
|
||||
@@ -892,7 +892,7 @@ static void print_usage(char *filename)
|
||||
printf(" [--version][--help]\n");
|
||||
}
|
||||
|
||||
static void print_help(char *filename)
|
||||
static void print_help(const char *filename)
|
||||
{
|
||||
(void)filename;
|
||||
printf("Generates Full EPICS file, including Object and Property List\n");
|
||||
@@ -921,7 +921,7 @@ static int CheckCommandLineArgs(int argc, char *argv[])
|
||||
int i;
|
||||
bool bFoundTarget = false;
|
||||
int argi = 0;
|
||||
char *filename = NULL;
|
||||
const char *filename = NULL;
|
||||
|
||||
filename = filename_remove_path(argv[0]);
|
||||
for (argi = 1; argi < argc; argi++) {
|
||||
|
||||
+3
-3
@@ -75,7 +75,7 @@ static void Init_Service_Handlers(void)
|
||||
apdu_set_reject_handler(MyRejectHandler);
|
||||
}
|
||||
|
||||
static void print_usage(char *filename)
|
||||
static void print_usage(const char *filename)
|
||||
{
|
||||
printf("Usage: %s [error-class error-code service-number invoke-id]\n",
|
||||
filename);
|
||||
@@ -83,7 +83,7 @@ static void print_usage(char *filename)
|
||||
printf(" [--version][--help]\n");
|
||||
}
|
||||
|
||||
static void print_help(char *filename)
|
||||
static void print_help(const char *filename)
|
||||
{
|
||||
printf("Send BACnet Error message to the network.\n");
|
||||
printf("--mac A\n"
|
||||
@@ -125,7 +125,7 @@ int main(int argc, char *argv[])
|
||||
bool specific_address = false;
|
||||
int argi = 0;
|
||||
unsigned int target_args = 0;
|
||||
char *filename = NULL;
|
||||
const char *filename = NULL;
|
||||
|
||||
filename = filename_remove_path(argv[0]);
|
||||
for (argi = 1; argi < argc; argi++) {
|
||||
|
||||
+3
-3
@@ -141,7 +141,7 @@ static void Init_Service_Handlers(void)
|
||||
apdu_set_reject_handler(MyRejectHandler);
|
||||
}
|
||||
|
||||
static void print_usage(char *filename)
|
||||
static void print_usage(const char *filename)
|
||||
{
|
||||
printf("Usage: %s device-id process-id initiating-device-id\n"
|
||||
" event-object-type event-object-instance\n"
|
||||
@@ -154,7 +154,7 @@ static void print_usage(char *filename)
|
||||
printf(" [--version][--help]\n");
|
||||
}
|
||||
|
||||
static void print_help(char *filename)
|
||||
static void print_help(const char *filename)
|
||||
{
|
||||
printf("Send BACnet ConfirmedEventNotification message to a device.\n");
|
||||
printf("device-id:\n"
|
||||
@@ -246,7 +246,7 @@ int main(int argc, char *argv[])
|
||||
bool specific_address = false;
|
||||
int argi = 0;
|
||||
unsigned int target_args = 0;
|
||||
char *filename = NULL;
|
||||
const char *filename = NULL;
|
||||
unsigned found_index = 0;
|
||||
|
||||
filename = filename_remove_path(argv[0]);
|
||||
|
||||
@@ -160,7 +160,7 @@ static void Init_Service_Handlers(void)
|
||||
apdu_set_reject_handler(MyRejectHandler);
|
||||
}
|
||||
|
||||
static int print_help(char *exe_name)
|
||||
static int print_help(const char *exe_name)
|
||||
{
|
||||
printf("Usage:\n"
|
||||
"\n"
|
||||
|
||||
+3
-3
@@ -78,7 +78,7 @@ static void Init_Service_Handlers(void)
|
||||
apdu_set_reject_handler(MyRejectHandler);
|
||||
}
|
||||
|
||||
static void print_usage(char *filename)
|
||||
static void print_usage(const char *filename)
|
||||
{
|
||||
printf("Usage: %s [device-instance vendor-id max-apdu segmentation]\n",
|
||||
filename);
|
||||
@@ -86,7 +86,7 @@ static void print_usage(char *filename)
|
||||
printf(" [--version][--help]\n");
|
||||
}
|
||||
|
||||
static void print_help(char *filename)
|
||||
static void print_help(const char *filename)
|
||||
{
|
||||
printf("Send BACnet I-Am message for a device.\n");
|
||||
printf("--mac A\n"
|
||||
@@ -149,7 +149,7 @@ int main(int argc, char *argv[])
|
||||
unsigned timeout = 100; /* milliseconds */
|
||||
int argi = 0;
|
||||
unsigned int target_args = 0;
|
||||
char *filename = NULL;
|
||||
const char *filename = NULL;
|
||||
long retry_count = 0;
|
||||
|
||||
filename = filename_remove_path(argv[0]);
|
||||
|
||||
@@ -75,13 +75,13 @@ static void Init_Service_Handlers(void)
|
||||
apdu_set_reject_handler(MyRejectHandler);
|
||||
}
|
||||
|
||||
static void print_usage(char *filename)
|
||||
static void print_usage(const char *filename)
|
||||
{
|
||||
printf("Usage: %s DNET [DNET] [DNET] [...]\n", filename);
|
||||
printf(" [--version][--help]\n");
|
||||
}
|
||||
|
||||
static void print_help(char *filename)
|
||||
static void print_help(const char *filename)
|
||||
{
|
||||
printf("Send BACnet I-Am-Router-To-Network message for \n"
|
||||
"one or more networks.\n"
|
||||
@@ -99,7 +99,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
unsigned arg_count = 0;
|
||||
int argi = 0;
|
||||
char *filename = NULL;
|
||||
const char *filename = NULL;
|
||||
|
||||
filename = filename_remove_path(argv[0]);
|
||||
for (argi = 1; argi < argc; argi++) {
|
||||
|
||||
@@ -211,13 +211,13 @@ static void Init_Service_Handlers(void)
|
||||
apdu_set_reject_handler(MyRejectHandler);
|
||||
}
|
||||
|
||||
static void print_usage(char *filename)
|
||||
static void print_usage(const char *filename)
|
||||
{
|
||||
printf("Usage: %s address [DNET ID Len Info]\n", filename);
|
||||
printf(" [--version][--help]\n");
|
||||
}
|
||||
|
||||
static void print_help(char *filename)
|
||||
static void print_help(const char *filename)
|
||||
{
|
||||
printf(
|
||||
"Send BACnet Initialize-Routing-Table message to a network\n"
|
||||
@@ -286,7 +286,7 @@ int main(int argc, char *argv[])
|
||||
time_t current_seconds = 0;
|
||||
time_t timeout_seconds = 0;
|
||||
int argi = 0;
|
||||
char *filename = NULL;
|
||||
const char *filename = NULL;
|
||||
|
||||
filename = filename_remove_path(argv[0]);
|
||||
for (argi = 1; argi < argc; argi++) {
|
||||
|
||||
+14
-11
@@ -121,7 +121,8 @@ struct mstp_statistics {
|
||||
static struct mstp_statistics MSTP_Statistics[MAX_MSTP_DEVICES];
|
||||
static uint32_t Invalid_Frame_Count;
|
||||
|
||||
static uint32_t timeval_diff_ms(struct timeval *old, struct timeval *now)
|
||||
static uint32_t timeval_diff_ms(
|
||||
const struct timeval *old, const struct timeval *now)
|
||||
{
|
||||
uint32_t ms = 0;
|
||||
|
||||
@@ -132,17 +133,18 @@ static uint32_t timeval_diff_ms(struct timeval *old, struct timeval *now)
|
||||
return ms;
|
||||
}
|
||||
|
||||
static void mstp_monitor_i_am(uint8_t mac, uint8_t *pdu, uint16_t pdu_len)
|
||||
static void mstp_monitor_i_am(
|
||||
uint8_t mac, const uint8_t *pdu, uint16_t pdu_len)
|
||||
{
|
||||
BACNET_ADDRESS src = { 0 };
|
||||
BACNET_ADDRESS dest = { 0 };
|
||||
BACNET_NPDU_DATA npdu_data = { 0 };
|
||||
int apdu_offset = 0;
|
||||
uint16_t apdu_len = 0;
|
||||
uint8_t *apdu = NULL;
|
||||
const uint8_t *apdu = NULL;
|
||||
uint8_t pdu_type = 0;
|
||||
uint8_t service_choice = 0;
|
||||
uint8_t *service_request = NULL;
|
||||
const uint8_t *service_request = NULL;
|
||||
uint32_t device_id = 0;
|
||||
int len = 0;
|
||||
|
||||
@@ -171,7 +173,8 @@ static void mstp_monitor_i_am(uint8_t mac, uint8_t *pdu, uint16_t pdu_len)
|
||||
}
|
||||
|
||||
static void packet_statistics(
|
||||
struct timeval *tv, struct mstp_port_struct_t *mstp_port)
|
||||
const struct timeval *tv,
|
||||
const struct mstp_port_struct_t *mstp_port)
|
||||
{
|
||||
static struct timeval old_tv = { 0 };
|
||||
static uint8_t old_frame = 255;
|
||||
@@ -423,7 +426,7 @@ uint16_t MSTP_Get_Send(
|
||||
*/
|
||||
void MSTP_Send_Frame(
|
||||
struct mstp_port_struct_t *mstp_port,
|
||||
uint8_t * buffer,
|
||||
const uint8_t * buffer,
|
||||
uint16_t nbytes)
|
||||
{
|
||||
(void)mstp_port;
|
||||
@@ -443,7 +446,7 @@ static char Capture_Filename[64] = "mstp_20090123091200.cap";
|
||||
static FILE *File_Handle = NULL; /* stream pointer */
|
||||
#if defined(_WIN32)
|
||||
static HANDLE Pipe_Handle = INVALID_HANDLE_VALUE; /* pipe handle */
|
||||
static void named_pipe_create(char *pipe_name)
|
||||
static void named_pipe_create(const char *pipe_name)
|
||||
{
|
||||
if (!Wireshark_Capture) {
|
||||
fprintf(stdout, "mstpcap: Creating Named Pipe \"%s\"\n", pipe_name);
|
||||
@@ -510,7 +513,7 @@ static size_t data_write_header(
|
||||
}
|
||||
#else
|
||||
static int FD_Pipe = -1;
|
||||
static void named_pipe_create(char *name)
|
||||
static void named_pipe_create(const char *name)
|
||||
{
|
||||
int rv = 0;
|
||||
rv = mkfifo(name, 0666);
|
||||
@@ -915,7 +918,7 @@ static void signal_init(void)
|
||||
}
|
||||
#endif
|
||||
|
||||
static void print_usage(char *filename)
|
||||
static void print_usage(const char *filename)
|
||||
{
|
||||
printf("Usage: %s", filename);
|
||||
printf(" [--scan <filename>]\n");
|
||||
@@ -925,7 +928,7 @@ static void print_usage(char *filename)
|
||||
printf(" [--version][--help]\n");
|
||||
}
|
||||
|
||||
static void print_help(char *filename)
|
||||
static void print_help(const char *filename)
|
||||
{
|
||||
printf("%s --scan <filename>\n"
|
||||
"perform statistic analysis on MS/TP capture file.\n",
|
||||
@@ -986,7 +989,7 @@ int main(int argc, char *argv[])
|
||||
uint32_t packet_count = 0;
|
||||
uint32_t header_len = 0;
|
||||
int argi = 0;
|
||||
char *filename = NULL;
|
||||
const char *filename = NULL;
|
||||
|
||||
MSTP_Port.InputBuffer = &RxBuffer[0];
|
||||
MSTP_Port.InputBufferSize = sizeof(RxBuffer);
|
||||
|
||||
@@ -444,7 +444,7 @@ bool Device_Object_Name(
|
||||
return status;
|
||||
}
|
||||
|
||||
bool Device_Set_Object_Name(BACNET_CHARACTER_STRING *object_name)
|
||||
bool Device_Set_Object_Name(const BACNET_CHARACTER_STRING *object_name)
|
||||
{
|
||||
bool status = false; /*return value */
|
||||
|
||||
@@ -785,7 +785,7 @@ int Device_Object_List_Element_Encode(
|
||||
* Object.
|
||||
* @return True on success or else False if not found.
|
||||
*/
|
||||
bool Device_Valid_Object_Name(BACNET_CHARACTER_STRING *object_name1,
|
||||
bool Device_Valid_Object_Name(const BACNET_CHARACTER_STRING *object_name1,
|
||||
BACNET_OBJECT_TYPE *object_type,
|
||||
uint32_t *object_instance)
|
||||
{
|
||||
@@ -1180,7 +1180,7 @@ int Device_Read_Property_Local(BACNET_READ_PROPERTY_DATA *rpdata)
|
||||
* @return The length of the APDU on success, else BACNET_STATUS_ERROR
|
||||
*/
|
||||
static int Read_Property_Common(
|
||||
struct object_functions *pObject, BACNET_READ_PROPERTY_DATA *rpdata)
|
||||
const struct object_functions *pObject, BACNET_READ_PROPERTY_DATA *rpdata)
|
||||
{
|
||||
int apdu_len = BACNET_STATUS_ERROR;
|
||||
BACNET_CHARACTER_STRING char_string;
|
||||
|
||||
@@ -205,13 +205,13 @@ static void Init_Service_Handlers(void)
|
||||
apdu_set_reject_handler(MyRejectHandler);
|
||||
}
|
||||
|
||||
static void print_usage(char *filename)
|
||||
static void print_usage(const char *filename)
|
||||
{
|
||||
printf("Usage: %s device-instance file-instance local-name\n", filename);
|
||||
printf(" [--version][--help]\n");
|
||||
}
|
||||
|
||||
static void print_help(char *filename)
|
||||
static void print_help(const char *filename)
|
||||
{
|
||||
printf(
|
||||
"Read a file from a BACnet device and save it locally.\n");
|
||||
@@ -251,7 +251,7 @@ int main(int argc, char *argv[])
|
||||
bool found = false;
|
||||
uint16_t my_max_apdu = 0;
|
||||
int argi = 0;
|
||||
char *filename = NULL;
|
||||
const char *filename = NULL;
|
||||
|
||||
/* print help if requested */
|
||||
filename = filename_remove_path(argv[0]);
|
||||
|
||||
@@ -147,7 +147,7 @@ static void Init_Service_Handlers(void)
|
||||
apdu_set_reject_handler(MyRejectHandler);
|
||||
}
|
||||
|
||||
static void print_usage(char *filename)
|
||||
static void print_usage(const char *filename)
|
||||
{
|
||||
printf("Usage: %s device-instance object-type object-instance "
|
||||
"property [index]\n",
|
||||
@@ -156,7 +156,7 @@ static void print_usage(char *filename)
|
||||
printf(" [--version][--help]\n");
|
||||
}
|
||||
|
||||
static void print_help(char *filename)
|
||||
static void print_help(const char *filename)
|
||||
{
|
||||
printf("Read a property from an object in a BACnet device\n"
|
||||
"and print the value.\n");
|
||||
@@ -255,7 +255,7 @@ int main(int argc, char *argv[])
|
||||
unsigned object_type = 0;
|
||||
unsigned object_property = 0;
|
||||
unsigned int target_args = 0;
|
||||
char *filename = NULL;
|
||||
const char *filename = NULL;
|
||||
|
||||
filename = filename_remove_path(argv[0]);
|
||||
for (argi = 1; argi < argc; argi++) {
|
||||
|
||||
@@ -199,7 +199,7 @@ static void cleanup(void)
|
||||
}
|
||||
|
||||
static void target_address_add(
|
||||
long dnet, BACNET_MAC_ADDRESS *mac, BACNET_MAC_ADDRESS *adr)
|
||||
long dnet, const BACNET_MAC_ADDRESS *mac, const BACNET_MAC_ADDRESS *adr)
|
||||
{
|
||||
BACNET_ADDRESS dest = { 0 };
|
||||
|
||||
@@ -234,7 +234,7 @@ static void target_address_add(
|
||||
address_add(Target_Device_Object_Instance, MAX_APDU, &dest);
|
||||
}
|
||||
|
||||
static void print_usage(char *filename)
|
||||
static void print_usage(const char *filename)
|
||||
{
|
||||
printf("Usage: %s device-instance object-type object-instance "
|
||||
"property[index][,property[index]] [object-type ...]\n",
|
||||
@@ -243,7 +243,7 @@ static void print_usage(char *filename)
|
||||
printf(" [--version][--help]\n");
|
||||
}
|
||||
|
||||
static void print_help(char *filename)
|
||||
static void print_help(const char *filename)
|
||||
{
|
||||
printf("Read one or more properties from one or more objects\n"
|
||||
"in a BACnet device and print the value(s).\n");
|
||||
@@ -350,7 +350,7 @@ int main(int argc, char *argv[])
|
||||
bool specific_address = false;
|
||||
unsigned int target_args = 0;
|
||||
bool status = false;
|
||||
char *filename = NULL;
|
||||
const char *filename = NULL;
|
||||
|
||||
filename = filename_remove_path(argv[0]);
|
||||
for (argi = 1; argi < argc; argi++) {
|
||||
|
||||
@@ -121,7 +121,7 @@ static void Init_Service_Handlers(void)
|
||||
apdu_set_reject_handler(MyRejectHandler);
|
||||
}
|
||||
|
||||
static void print_usage(char *filename)
|
||||
static void print_usage(const char *filename)
|
||||
{
|
||||
printf("Usage: %s device-instance object-type object-instance property\n",
|
||||
filename);
|
||||
@@ -129,7 +129,7 @@ static void print_usage(char *filename)
|
||||
printf(" [--version][--help]\n");
|
||||
}
|
||||
|
||||
static void print_help(char *filename)
|
||||
static void print_help(const char *filename)
|
||||
{
|
||||
printf("Read a range of properties from an array or list property\n"
|
||||
"in an object in a BACnet device and print the values.\n");
|
||||
@@ -199,7 +199,7 @@ int main(int argc, char *argv[])
|
||||
int year, month, day, wday;
|
||||
unsigned object_type = 0;
|
||||
unsigned object_property = 0;
|
||||
char *filename = NULL;
|
||||
const char *filename = NULL;
|
||||
|
||||
filename = filename_remove_path(argv[0]);
|
||||
for (argi = 1; argi < argc; argi++) {
|
||||
|
||||
@@ -137,7 +137,7 @@ static void Init_Service_Handlers(void)
|
||||
apdu_set_reject_handler(MyRejectHandler);
|
||||
}
|
||||
|
||||
static void print_usage(char *filename)
|
||||
static void print_usage(const char *filename)
|
||||
{
|
||||
printf("Usage: %s device-instance object-type object-instance "
|
||||
"property array-index tag value\n",
|
||||
@@ -146,7 +146,7 @@ static void print_usage(char *filename)
|
||||
printf(" [--version][--help][--verbose]\n");
|
||||
}
|
||||
|
||||
static void print_help(char *filename)
|
||||
static void print_help(const char *filename)
|
||||
{
|
||||
printf("Remove an element from a BACnetLIST property of an object\n"
|
||||
"in a BACnet device.\n");
|
||||
@@ -244,7 +244,7 @@ int main(int argc, char *argv[])
|
||||
bool specific_address = false;
|
||||
unsigned int target_args = 0;
|
||||
int argi = 0;
|
||||
char *filename = NULL;
|
||||
const char *filename = NULL;
|
||||
|
||||
filename = filename_remove_path(argv[0]);
|
||||
for (argi = 1; argi < argc; argi++) {
|
||||
|
||||
+12
-8
@@ -156,7 +156,7 @@ static bool port_find(uint16_t snet, BACNET_ADDRESS *addr)
|
||||
* @param snet - router port SNET
|
||||
* @param addr - address of port at the net to be added
|
||||
*/
|
||||
static void port_add(uint16_t snet, BACNET_ADDRESS *addr)
|
||||
static void port_add(uint16_t snet, const BACNET_ADDRESS *addr)
|
||||
{
|
||||
DNET *port = NULL;
|
||||
DNET *dnet = NULL;
|
||||
@@ -204,7 +204,7 @@ static void port_add(uint16_t snet, BACNET_ADDRESS *addr)
|
||||
* @param net - net to be added
|
||||
* @param addr - address of router at the net to be added
|
||||
*/
|
||||
static void dnet_add(uint16_t snet, uint16_t net, BACNET_ADDRESS *addr)
|
||||
static void dnet_add(uint16_t snet, uint16_t net, const BACNET_ADDRESS *addr)
|
||||
{
|
||||
DNET *dnet = NULL;
|
||||
DNET *port = NULL;
|
||||
@@ -398,7 +398,8 @@ static void send_i_am_router_to_network(uint16_t snet, uint16_t net)
|
||||
* Optionally may designate a particular router destination,
|
||||
* especially when ACKing receipt of this message type.
|
||||
*/
|
||||
static void send_initialize_routing_table_ack(uint8_t snet, BACNET_ADDRESS *dst)
|
||||
static void send_initialize_routing_table_ack(
|
||||
uint8_t snet, const BACNET_ADDRESS *dst)
|
||||
{
|
||||
BACNET_ADDRESS dest;
|
||||
bool data_expecting_reply = false;
|
||||
@@ -458,7 +459,10 @@ static void send_initialize_routing_table_ack(uint8_t snet, BACNET_ADDRESS *dst)
|
||||
* @param reject_reason [in] One of the BACNET_NETWORK_REJECT_REASONS codes.
|
||||
*/
|
||||
static void send_reject_message_to_network(
|
||||
uint16_t snet, BACNET_ADDRESS *dst, uint8_t reject_reason, uint16_t dnet)
|
||||
uint16_t snet,
|
||||
const BACNET_ADDRESS *dst,
|
||||
uint8_t reject_reason,
|
||||
uint16_t dnet)
|
||||
{
|
||||
BACNET_ADDRESS dest;
|
||||
bool data_expecting_reply = false;
|
||||
@@ -571,9 +575,9 @@ static void send_who_is_router_to_network(uint16_t snet, uint16_t dnet)
|
||||
* @param npdu_len [in] The length of the remaining NPDU message in npdu[].
|
||||
*/
|
||||
static void who_is_router_to_network_handler(uint16_t snet,
|
||||
BACNET_ADDRESS *src,
|
||||
BACNET_NPDU_DATA *npdu_data,
|
||||
uint8_t *npdu,
|
||||
const BACNET_ADDRESS *src,
|
||||
const BACNET_NPDU_DATA *npdu_data,
|
||||
const uint8_t *npdu,
|
||||
uint16_t npdu_len)
|
||||
{
|
||||
DNET *port = NULL;
|
||||
@@ -752,7 +756,7 @@ static void network_control_handler(uint16_t snet,
|
||||
* @param src [in] The BACNET_ADDRESS of the message's original src.
|
||||
*/
|
||||
static void routed_src_address(
|
||||
BACNET_ADDRESS *router_src, uint16_t snet, BACNET_ADDRESS *src)
|
||||
BACNET_ADDRESS *router_src, uint16_t snet, const BACNET_ADDRESS *src)
|
||||
{
|
||||
unsigned int i = 0;
|
||||
|
||||
|
||||
+12
-8
@@ -177,7 +177,7 @@ static bool port_find(uint16_t snet, BACNET_ADDRESS *addr)
|
||||
* @param snet - router port SNET
|
||||
* @param addr - address of port at the net to be added
|
||||
*/
|
||||
static void port_add(uint16_t snet, BACNET_ADDRESS *addr)
|
||||
static void port_add(uint16_t snet, const BACNET_ADDRESS *addr)
|
||||
{
|
||||
DNET *port = NULL;
|
||||
DNET *dnet = NULL;
|
||||
@@ -225,7 +225,7 @@ static void port_add(uint16_t snet, BACNET_ADDRESS *addr)
|
||||
* @param net - net to be added
|
||||
* @param addr - address of router at the net to be added
|
||||
*/
|
||||
static void dnet_add(uint16_t snet, uint16_t net, BACNET_ADDRESS *addr)
|
||||
static void dnet_add(uint16_t snet, uint16_t net, const BACNET_ADDRESS *addr)
|
||||
{
|
||||
DNET *dnet = NULL;
|
||||
DNET *port = NULL;
|
||||
@@ -419,7 +419,8 @@ static void send_i_am_router_to_network(uint16_t snet, uint16_t net)
|
||||
* Optionally may designate a particular router destination,
|
||||
* especially when ACKing receipt of this message type.
|
||||
*/
|
||||
static void send_initialize_routing_table_ack(uint8_t snet, BACNET_ADDRESS *dst)
|
||||
static void send_initialize_routing_table_ack(
|
||||
uint8_t snet, const BACNET_ADDRESS *dst)
|
||||
{
|
||||
BACNET_ADDRESS dest;
|
||||
bool data_expecting_reply = false;
|
||||
@@ -479,7 +480,10 @@ static void send_initialize_routing_table_ack(uint8_t snet, BACNET_ADDRESS *dst)
|
||||
* @param reject_reason [in] One of the BACNET_NETWORK_REJECT_REASONS codes.
|
||||
*/
|
||||
static void send_reject_message_to_network(
|
||||
uint16_t snet, BACNET_ADDRESS *dst, uint8_t reject_reason, uint16_t dnet)
|
||||
uint16_t snet,
|
||||
const BACNET_ADDRESS *dst,
|
||||
uint8_t reject_reason,
|
||||
uint16_t dnet)
|
||||
{
|
||||
BACNET_ADDRESS dest;
|
||||
bool data_expecting_reply = false;
|
||||
@@ -592,9 +596,9 @@ static void send_who_is_router_to_network(uint16_t snet, uint16_t dnet)
|
||||
* @param npdu_len [in] The length of the remaining NPDU message in npdu[].
|
||||
*/
|
||||
static void who_is_router_to_network_handler(uint16_t snet,
|
||||
BACNET_ADDRESS *src,
|
||||
BACNET_NPDU_DATA *npdu_data,
|
||||
uint8_t *npdu,
|
||||
const BACNET_ADDRESS *src,
|
||||
const BACNET_NPDU_DATA *npdu_data,
|
||||
const uint8_t *npdu,
|
||||
uint16_t npdu_len)
|
||||
{
|
||||
DNET *port = NULL;
|
||||
@@ -775,7 +779,7 @@ static void network_control_handler(uint16_t snet,
|
||||
* @param src [in] The BACNET_ADDRESS of the message's original src.
|
||||
*/
|
||||
static void routed_src_address(
|
||||
BACNET_ADDRESS *router_src, uint16_t snet, BACNET_ADDRESS *src)
|
||||
BACNET_ADDRESS *router_src, uint16_t snet, const BACNET_ADDRESS *src)
|
||||
{
|
||||
unsigned int i = 0;
|
||||
|
||||
|
||||
@@ -199,7 +199,10 @@ bool dl_ip_init(ROUTER_PORT *port, IP_DATA *ip_data)
|
||||
}
|
||||
|
||||
int dl_ip_send(
|
||||
IP_DATA *data, BACNET_ADDRESS *dest, uint8_t *pdu, unsigned pdu_len)
|
||||
IP_DATA *data,
|
||||
const BACNET_ADDRESS *dest,
|
||||
const uint8_t *pdu,
|
||||
unsigned pdu_len)
|
||||
{
|
||||
struct sockaddr_in bip_dest = { 0 };
|
||||
int buff_len = 0;
|
||||
|
||||
@@ -45,8 +45,8 @@ bool dl_ip_init(
|
||||
|
||||
int dl_ip_send(
|
||||
IP_DATA * data,
|
||||
BACNET_ADDRESS * dest,
|
||||
uint8_t * pdu,
|
||||
const BACNET_ADDRESS * dest,
|
||||
const uint8_t * pdu,
|
||||
unsigned pdu_len);
|
||||
|
||||
int dl_ip_recv(
|
||||
|
||||
+8
-8
@@ -43,7 +43,7 @@ int port_count;
|
||||
|
||||
void print_help(void);
|
||||
|
||||
bool read_config(char *filepath);
|
||||
bool read_config(const char *filepath);
|
||||
|
||||
bool parse_cmd(int argc, char *argv[]);
|
||||
|
||||
@@ -53,7 +53,7 @@ bool init_router(void);
|
||||
|
||||
void cleanup(void);
|
||||
|
||||
void print_msg(BACMSG *msg);
|
||||
void print_msg(const BACMSG *msg);
|
||||
|
||||
uint16_t process_msg(BACMSG *msg, MSG_DATA *data, uint8_t **buff);
|
||||
|
||||
@@ -61,7 +61,7 @@ uint16_t get_next_free_dnet(void);
|
||||
|
||||
int kbhit(void);
|
||||
|
||||
inline bool is_network_msg(BACMSG *msg);
|
||||
inline bool is_network_msg(const BACMSG *msg);
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
@@ -201,7 +201,7 @@ void print_help(void)
|
||||
"-s, --stopbits <1|2>\n\tspecify MSTP port stopbits\n");
|
||||
}
|
||||
|
||||
bool read_config(char *filepath)
|
||||
bool read_config(const char *filepath)
|
||||
{
|
||||
config_t cfg;
|
||||
config_setting_t *setting;
|
||||
@@ -725,11 +725,11 @@ void cleanup(void)
|
||||
pthread_mutex_destroy(&msg_lock);
|
||||
}
|
||||
|
||||
void print_msg(BACMSG *msg)
|
||||
void print_msg(const BACMSG *msg)
|
||||
{
|
||||
if (msg->type == DATA) {
|
||||
int i;
|
||||
MSG_DATA *data = (MSG_DATA *)msg->data;
|
||||
const MSG_DATA *data = (const MSG_DATA *)msg->data;
|
||||
|
||||
if (data->pdu_len) {
|
||||
PRINT(DEBUG, "Message PDU: ");
|
||||
@@ -821,10 +821,10 @@ int kbhit(void)
|
||||
return bytesWaiting;
|
||||
}
|
||||
|
||||
bool is_network_msg(BACMSG *msg)
|
||||
bool is_network_msg(const BACMSG *msg)
|
||||
{
|
||||
uint8_t control_byte; /* NPDU control byte */
|
||||
MSG_DATA *data = (MSG_DATA *)msg->data;
|
||||
const MSG_DATA *data = (const MSG_DATA *)msg->data;
|
||||
|
||||
control_byte = data->pdu[1];
|
||||
|
||||
|
||||
@@ -14,7 +14,8 @@
|
||||
#include "network_layer.h"
|
||||
#include "bacnet/bacint.h"
|
||||
|
||||
uint16_t process_network_message(BACMSG *msg, MSG_DATA *data, uint8_t **buff)
|
||||
uint16_t process_network_message(
|
||||
const BACMSG *msg, MSG_DATA *data, uint8_t **buff)
|
||||
{
|
||||
BACNET_NPDU_DATA npdu_data;
|
||||
ROUTER_PORT *srcport;
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#include "portthread.h"
|
||||
|
||||
uint16_t process_network_message(
|
||||
BACMSG * msg,
|
||||
const BACMSG * msg,
|
||||
MSG_DATA * data,
|
||||
uint8_t ** buff);
|
||||
|
||||
|
||||
+3
-3
@@ -161,14 +161,14 @@ static void cleanup(void)
|
||||
}
|
||||
}
|
||||
|
||||
static void print_usage(char *filename)
|
||||
static void print_usage(const char *filename)
|
||||
{
|
||||
printf("Usage: %s device-id object-type object-instance "
|
||||
"process-id <[un]confirmed lifetime|cancel>\n",
|
||||
filename);
|
||||
}
|
||||
|
||||
static void print_help(char *filename)
|
||||
static void print_help(const char *filename)
|
||||
{
|
||||
printf("Subscribe to a BACnet object for Change-of-Value notifications\n"
|
||||
"in a BACnet device and print the Change-of-Value notifications.\n");
|
||||
@@ -226,7 +226,7 @@ int main(int argc, char *argv[])
|
||||
time_t timeout_seconds = 0;
|
||||
time_t delta_seconds = 0;
|
||||
bool found = false;
|
||||
char *filename = NULL;
|
||||
const char *filename = NULL;
|
||||
bool print_usage_terse = false;
|
||||
bool print_usage_verbose = false;
|
||||
BACNET_SUBSCRIBE_COV_DATA *cov_data = NULL;
|
||||
|
||||
@@ -82,14 +82,14 @@ static void Init_Service_Handlers(void)
|
||||
apdu_set_reject_handler(MyRejectHandler);
|
||||
}
|
||||
|
||||
static void print_usage(char *filename)
|
||||
static void print_usage(const char *filename)
|
||||
{
|
||||
printf("Usage: %s [--dnet][--dadr][--mac]\n", filename);
|
||||
printf(" [--date][--time]\n");
|
||||
printf(" [--version][--help]\n");
|
||||
}
|
||||
|
||||
static void print_help(char *filename)
|
||||
static void print_help(const char *filename)
|
||||
{
|
||||
printf("Send BACnet TimeSynchronization request.\n");
|
||||
printf("\n");
|
||||
@@ -157,7 +157,7 @@ int main(int argc, char *argv[])
|
||||
BACNET_ADDRESS dest = { 0 };
|
||||
bool global_broadcast = true;
|
||||
int argi = 0;
|
||||
char *filename = NULL;
|
||||
const char *filename = NULL;
|
||||
|
||||
/* decode any command line parameters */
|
||||
filename = filename_remove_path(argv[0]);
|
||||
|
||||
+1
-1
@@ -47,7 +47,7 @@ static void Init_Service_Handlers(void)
|
||||
SERVICE_CONFIRMED_READ_PROPERTY, handler_read_property);
|
||||
}
|
||||
|
||||
static void print_usage(char *filename)
|
||||
static void print_usage(const char *filename)
|
||||
{
|
||||
printf("Sends a BACnet Unconfirmed Change-of-Value Notification\n"
|
||||
"to the network.\n");
|
||||
|
||||
+3
-3
@@ -49,7 +49,7 @@ static void Init_Service_Handlers(void)
|
||||
SERVICE_CONFIRMED_READ_PROPERTY, handler_read_property);
|
||||
}
|
||||
|
||||
static void print_usage(char *filename)
|
||||
static void print_usage(const char *filename)
|
||||
{
|
||||
printf("Usage: %s pid object-type object-instance \n"
|
||||
" event-object-type event-object-instance \n"
|
||||
@@ -63,7 +63,7 @@ static void print_usage(char *filename)
|
||||
printf(" [--version][--help]\n");
|
||||
}
|
||||
|
||||
static void print_help(char *filename)
|
||||
static void print_help(const char *filename)
|
||||
{
|
||||
printf("Send BACnet UnconfirmedEventNotification message for a device.\n");
|
||||
printf("--mac A\n"
|
||||
@@ -99,7 +99,7 @@ int main(int argc, char *argv[])
|
||||
bool specific_address = false;
|
||||
int argi = 0;
|
||||
unsigned int target_args = 0;
|
||||
char *filename = NULL;
|
||||
const char *filename = NULL;
|
||||
|
||||
filename = filename_remove_path(argv[0]);
|
||||
for (argi = 1; argi < argc; argi++) {
|
||||
|
||||
@@ -117,14 +117,14 @@ static void Init_Service_Handlers(void)
|
||||
apdu_set_reject_handler(MyRejectHandler);
|
||||
}
|
||||
|
||||
static void print_usage(char *filename)
|
||||
static void print_usage(const char *filename)
|
||||
{
|
||||
printf("Usage: %s <device-instance|broadcast|dnet=> vendor-id"
|
||||
" service-number tag value [tag value...]\n",
|
||||
filename);
|
||||
}
|
||||
|
||||
static void print_help(char *filename)
|
||||
static void print_help(const char *filename)
|
||||
{
|
||||
printf("Send BACnet UnconfirmedPrivateTransfer message to the network.\n");
|
||||
printf("device-instance:\n"
|
||||
@@ -181,7 +181,7 @@ int main(int argc, char *argv[])
|
||||
time_t timeout_seconds = 0;
|
||||
time_t delta_seconds = 0;
|
||||
bool found = false;
|
||||
char *filename = NULL;
|
||||
const char *filename = NULL;
|
||||
char *value_string = NULL;
|
||||
bool status = false;
|
||||
int args_remaining = 0, tag_value_arg = 0, i = 0;
|
||||
|
||||
+2
-2
@@ -85,14 +85,14 @@ static void Init_Service_Handlers(void)
|
||||
apdu_set_reject_handler(MyRejectHandler);
|
||||
}
|
||||
|
||||
static void print_usage(char *filename)
|
||||
static void print_usage(const char *filename)
|
||||
{
|
||||
printf("Usage: %s [device-instance-min device-instance-min] "
|
||||
"<object-type object-instance | object-name> [--help]\r\n",
|
||||
filename);
|
||||
}
|
||||
|
||||
static void print_help(char *filename)
|
||||
static void print_help(const char *filename)
|
||||
{
|
||||
print_usage(filename);
|
||||
printf("Send BACnet WhoHas request to devices, \r\n"
|
||||
|
||||
+5
-5
@@ -73,7 +73,7 @@ static struct address_entry *alloc_address_entry(void)
|
||||
}
|
||||
|
||||
static void address_table_add(
|
||||
uint32_t device_id, unsigned max_apdu, BACNET_ADDRESS *src)
|
||||
uint32_t device_id, unsigned max_apdu, const BACNET_ADDRESS *src)
|
||||
{
|
||||
struct address_entry *pMatch;
|
||||
uint8_t flags = 0;
|
||||
@@ -185,7 +185,7 @@ static void init_service_handlers(void)
|
||||
apdu_set_reject_handler(MyRejectHandler);
|
||||
}
|
||||
|
||||
static void print_macaddr(uint8_t *addr, int len)
|
||||
static void print_macaddr(const uint8_t *addr, int len)
|
||||
{
|
||||
int j = 0;
|
||||
|
||||
@@ -246,7 +246,7 @@ static void print_address_cache(void)
|
||||
}
|
||||
}
|
||||
|
||||
static void print_usage(char *filename)
|
||||
static void print_usage(const char *filename)
|
||||
{
|
||||
printf("Usage: %s", filename);
|
||||
printf(" [device-instance-min [device-instance-max]]\n");
|
||||
@@ -254,7 +254,7 @@ static void print_usage(char *filename)
|
||||
printf(" [--version][--help]\n");
|
||||
}
|
||||
|
||||
static void print_help(char *filename)
|
||||
static void print_help(const char *filename)
|
||||
{
|
||||
printf("Send BACnet WhoIs service request to a device or multiple\n"
|
||||
"devices, and wait for responses. Displays any devices found\n"
|
||||
@@ -338,7 +338,7 @@ int main(int argc, char *argv[])
|
||||
bool global_broadcast = true;
|
||||
int argi = 0;
|
||||
unsigned int target_args = 0;
|
||||
char *filename = NULL;
|
||||
const char *filename = NULL;
|
||||
bool repeat_forever = false;
|
||||
long retry_count = 0;
|
||||
|
||||
|
||||
@@ -136,14 +136,14 @@ static void Init_Service_Handlers(void)
|
||||
apdu_set_reject_handler(MyRejectHandler);
|
||||
}
|
||||
|
||||
static void print_usage(char *filename)
|
||||
static void print_usage(const char *filename)
|
||||
{
|
||||
printf("Usage: %s device-instance object-type object-instance "
|
||||
"property priority index tag value [tag value...]\n",
|
||||
filename);
|
||||
}
|
||||
|
||||
static void print_help(char *filename)
|
||||
static void print_help(const char *filename)
|
||||
{
|
||||
printf(
|
||||
"device-instance:\n"
|
||||
|
||||
@@ -162,7 +162,7 @@ static void cleanup(void)
|
||||
}
|
||||
}
|
||||
|
||||
static void print_usage(char *filename)
|
||||
static void print_usage(const char *filename)
|
||||
{
|
||||
printf("Usage: %s device-instance object-type object-instance "
|
||||
"property[index] priority tag value [property[index] priority tag "
|
||||
@@ -171,7 +171,7 @@ static void print_usage(char *filename)
|
||||
printf(" [--version][--help]\n");
|
||||
}
|
||||
|
||||
static void print_help(char *filename)
|
||||
static void print_help(const char *filename)
|
||||
{
|
||||
printf("Write one or more properties to one or more objects\n"
|
||||
"in a BACnet device.\n");
|
||||
@@ -278,7 +278,7 @@ int main(int argc, char *argv[])
|
||||
unsigned property_array_index = 0;
|
||||
int scan_count = 0;
|
||||
int argi = 0;
|
||||
char *filename = NULL;
|
||||
const char *filename = NULL;
|
||||
|
||||
filename = filename_remove_path(argv[0]);
|
||||
for (argi = 1; argi < argc; argi++) {
|
||||
|
||||
@@ -50,7 +50,7 @@ long bip_getaddrbyname(const char *host_name)
|
||||
* @param ifname [in] The named interface to use for the network layer.
|
||||
* Eg, for Linux, ifname is eth0, ath0, arc0, and others.
|
||||
*/
|
||||
void bip_set_interface(char *ifname)
|
||||
void bip_set_interface(const char *ifname)
|
||||
{
|
||||
uint8_t local_address[] = { 0, 0, 0, 0 };
|
||||
uint8_t broadcast_address[] = { 0, 0, 0, 0 };
|
||||
|
||||
@@ -34,7 +34,7 @@ static uint8_t BIP_Broadcast_Address[4] = { 0, 0, 0, 0 };
|
||||
/** Converter from uint8_t[4] type address to uint32_t
|
||||
*
|
||||
*/
|
||||
uint32_t convertBIP_Address2uint32(uint8_t *bip_address)
|
||||
uint32_t convertBIP_Address2uint32(const suint8_t *bip_address)
|
||||
{
|
||||
return (uint32_t)((bip_address[0] * 2 ^ 24) + (bip_address[1] * 2 ^ 16) +
|
||||
(bip_address[2] * 2 ^ 8) + bip_address[3]);
|
||||
@@ -74,7 +74,7 @@ bool bip_valid(void)
|
||||
return (BIP_Socket < MAX_SOCK_NUM);
|
||||
}
|
||||
|
||||
void bip_set_addr(uint8_t *net_address)
|
||||
void bip_set_addr(const uint8_t *net_address)
|
||||
{ /* in network byte order */
|
||||
for (uint8_t i = 0; i < 4; i++)
|
||||
BIP_Address[i] = net_address[i];
|
||||
@@ -86,7 +86,7 @@ uint8_t *bip_get_addr(void)
|
||||
return BIP_Address;
|
||||
}
|
||||
|
||||
void bip_set_broadcast_addr(uint8_t *net_address)
|
||||
void bip_set_broadcast_addr(const uint8_t *net_address)
|
||||
{ /* in network byte order */
|
||||
for (uint8_t i = 0; i < 4; i++)
|
||||
BIP_Broadcast_Address[i] = net_address[i];
|
||||
@@ -109,9 +109,8 @@ uint16_t bip_get_port(void)
|
||||
return ntohs(BIP_Port);
|
||||
}
|
||||
|
||||
static int bip_decode_bip_address(BACNET_ADDRESS *bac_addr,
|
||||
static int bip_decode_bip_address(const BACNET_ADDRESS *bac_addr,
|
||||
uint8_t *address, /* in network format */
|
||||
|
||||
uint16_t *port)
|
||||
{ /* in network format */
|
||||
int len = 0;
|
||||
|
||||
@@ -28,11 +28,11 @@ extern "C" {
|
||||
/* on Linux, ifname is eth0, ath0, arc0, and others.
|
||||
on Windows, ifname is the dotted ip address of the interface */
|
||||
bool bip_init(char *ifname);
|
||||
void bip_set_interface(char *ifname);
|
||||
void bip_set_interface(const char *ifname);
|
||||
void bip_cleanup(void);
|
||||
|
||||
/* Convert uint8_t IPv4 to uint32 */
|
||||
uint32_t convertBIP_Address2uint32(uint8_t * bip_address);
|
||||
uint32_t convertBIP_Address2uint32(const uint8_t * bip_address);
|
||||
void convertUint32Address_2_uint8Address(uint32_t ip,
|
||||
uint8_t * address);
|
||||
/* common BACnet/IP functions */
|
||||
@@ -68,12 +68,12 @@ extern "C" {
|
||||
uint16_t bip_get_port(void);
|
||||
|
||||
/* use network byte order for setting */
|
||||
void bip_set_addr(uint8_t * net_address);
|
||||
void bip_set_addr(const uint8_t * net_address);
|
||||
/* returns network byte order */
|
||||
uint8_t *bip_get_addr(void);
|
||||
|
||||
/* use network byte order for setting */
|
||||
void bip_set_broadcast_addr(uint8_t * net_address);
|
||||
void bip_set_broadcast_addr(const uint8_t * net_address);
|
||||
/* returns network byte order */
|
||||
uint8_t *bip_get_broadcast_addr(void);
|
||||
|
||||
|
||||
@@ -54,12 +54,9 @@ static int bvlc_encode_bvlc_result(uint8_t *pdu, BACNET_BVLC_RESULT result_code)
|
||||
* @return Upon successful completion, returns the number of bytes sent.
|
||||
* Otherwise, -1 shall be returned and errno set to indicate the error.
|
||||
*/
|
||||
static int bvlc_send_mpdu(uint8_t *dest_addr, /* the destination address */
|
||||
|
||||
uint16_t *dest_port, /* the destination port */
|
||||
|
||||
static int bvlc_send_mpdu(const uint8_t *dest_addr, /* the destination address */
|
||||
const uint16_t *dest_port, /* the destination port */
|
||||
uint8_t *mtu, /* the data */
|
||||
|
||||
uint16_t mtu_len)
|
||||
{ /* amount of data to send */
|
||||
/* assumes that the driver has already been initialized */
|
||||
@@ -75,9 +72,8 @@ static int bvlc_send_mpdu(uint8_t *dest_addr, /* the destination address */
|
||||
* @param dest_addr - destination address
|
||||
* @param dest_port - destination port
|
||||
*/
|
||||
static void bvlc_send_result(uint8_t *dest_addr,
|
||||
uint16_t *dest_port, /* the destination address */
|
||||
|
||||
static void bvlc_send_result(const uint8_t *dest_addr,
|
||||
const uint16_t *dest_port, /* the destination address */
|
||||
BACNET_BVLC_RESULT result_code)
|
||||
{
|
||||
uint8_t mtu[BIP_MPDU_MAX] = { 0 };
|
||||
|
||||
@@ -64,7 +64,7 @@ void handler_who_is(
|
||||
} else if (len != -1) {
|
||||
/* is my device id within the limits? */
|
||||
target_device = Device_Object_Instance_Number();
|
||||
if (((target_device >= low_limit) && (target_device <= high_limit)) {
|
||||
if ((target_device >= low_limit) && (target_device <= high_limit)) {
|
||||
sendIamUnicast(&Handler_Transmit_Buffer[0], src);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,7 +126,8 @@ static struct my_object_functions *Device_Objects_Find_Functions(
|
||||
}
|
||||
|
||||
static int Read_Property_Common(
|
||||
struct my_object_functions *pObject, BACNET_READ_PROPERTY_DATA *rpdata)
|
||||
const struct my_object_functions *pObject,
|
||||
BACNET_READ_PROPERTY_DATA *rpdata)
|
||||
{
|
||||
int apdu_len = BACNET_STATUS_ERROR;
|
||||
BACNET_CHARACTER_STRING char_string;
|
||||
@@ -299,7 +300,7 @@ bool Device_Object_Name(
|
||||
return status;
|
||||
}
|
||||
|
||||
bool Device_Set_Object_Name(BACNET_CHARACTER_STRING *object_name)
|
||||
bool Device_Set_Object_Name(const BACNET_CHARACTER_STRING *object_name)
|
||||
{
|
||||
bool status = false; /*return value */
|
||||
|
||||
@@ -574,7 +575,7 @@ int Device_Object_List_Element_Encode(
|
||||
return apdu_len;
|
||||
}
|
||||
|
||||
bool Device_Valid_Object_Name(BACNET_CHARACTER_STRING *object_name1,
|
||||
bool Device_Valid_Object_Name(const BACNET_CHARACTER_STRING *object_name1,
|
||||
BACNET_OBJECT_TYPE *object_type,
|
||||
uint32_t *object_instance)
|
||||
{
|
||||
|
||||
@@ -195,10 +195,10 @@ void dlmstp_fill_bacnet_address(BACNET_ADDRESS *src, uint8_t mstp_address)
|
||||
}
|
||||
}
|
||||
|
||||
static bool dlmstp_compare_data_expecting_reply(uint8_t *request_pdu,
|
||||
static bool dlmstp_compare_data_expecting_reply(const uint8_t *request_pdu,
|
||||
uint16_t request_pdu_len,
|
||||
uint8_t src_address,
|
||||
uint8_t *reply_pdu,
|
||||
const uint8_t *reply_pdu,
|
||||
uint16_t reply_pdu_len,
|
||||
uint8_t dest_address)
|
||||
{
|
||||
@@ -314,7 +314,7 @@ static void MSTP_Send_Frame(
|
||||
uint8_t frame_type, /* type of frame to send - see defines */
|
||||
uint8_t destination, /* destination address */
|
||||
uint8_t source, /* source address */
|
||||
uint8_t *data, /* any data to be sent - may be null */
|
||||
const uint8_t *data, /* any data to be sent - may be null */
|
||||
uint16_t data_len)
|
||||
{ /* number of bytes of data (up to 501) */
|
||||
uint8_t crc8 = 0xFF; /* used to calculate the crc value */
|
||||
@@ -735,7 +735,7 @@ static bool MSTP_Master_Node_FSM(void)
|
||||
frame_type = FRAME_TYPE_BACNET_DATA_NOT_EXPECTING_REPLY;
|
||||
}
|
||||
MSTP_Send_Frame(frame_type, pkt->destination_mac, This_Station,
|
||||
(uint8_t *)&pkt->buffer[0], pkt->length);
|
||||
&pkt->buffer[0], pkt->length);
|
||||
FrameCount++;
|
||||
switch (frame_type) {
|
||||
case FRAME_TYPE_BACNET_DATA_EXPECTING_REPLY:
|
||||
@@ -1081,7 +1081,7 @@ static bool MSTP_Master_Node_FSM(void)
|
||||
frame_type = FRAME_TYPE_BACNET_DATA_NOT_EXPECTING_REPLY;
|
||||
}
|
||||
MSTP_Send_Frame(frame_type, pkt->destination_mac, This_Station,
|
||||
(uint8_t *)&pkt->buffer[0], pkt->length);
|
||||
&pkt->buffer[0], pkt->length);
|
||||
Master_State = MSTP_MASTER_STATE_IDLE;
|
||||
/* clear our flag we were holding for comparison */
|
||||
MSTP_Flag.ReceivedValidFrame = false;
|
||||
@@ -1165,7 +1165,7 @@ static void MSTP_Slave_Node_FSM(void)
|
||||
frame_type = FRAME_TYPE_BACNET_DATA_NOT_EXPECTING_REPLY;
|
||||
}
|
||||
MSTP_Send_Frame(frame_type, pkt->destination_mac, This_Station,
|
||||
(uint8_t *)&pkt->buffer[0], pkt->length);
|
||||
&pkt->buffer[0], pkt->length);
|
||||
(void)Ringbuf_Pop(&PDU_Queue, NULL);
|
||||
}
|
||||
/* clear our flag we were holding for comparison */
|
||||
|
||||
@@ -294,7 +294,7 @@ bool Network_Port_MAC_Address(
|
||||
* @return true if object-name was set
|
||||
*/
|
||||
bool Network_Port_MAC_Address_Set(
|
||||
uint32_t object_instance, uint8_t *mac_src, uint8_t mac_len)
|
||||
uint32_t object_instance, const uint8_t *mac_src, uint8_t mac_len)
|
||||
{
|
||||
if (mac_len == 1) {
|
||||
Object_List[0].MAC_Address[0] = mac_src[0];
|
||||
|
||||
@@ -171,7 +171,7 @@ void RS485_Transmitter_Enable(bool enable)
|
||||
* ALGORITHM: none
|
||||
* NOTES: none
|
||||
*****************************************************************************/
|
||||
void RS485_Send_Data(uint8_t *buffer, /* data to send */
|
||||
void RS485_Send_Data(const uint8_t *buffer, /* data to send */
|
||||
uint16_t nbytes)
|
||||
{ /* number of bytes of data */
|
||||
/* LED on send */
|
||||
|
||||
@@ -22,7 +22,7 @@ extern "C" {
|
||||
bool enable);
|
||||
|
||||
void RS485_Send_Data(
|
||||
uint8_t * buffer, /* data to send */
|
||||
const uint8_t * buffer, /* data to send */
|
||||
uint16_t nbytes); /* number of bytes of data */
|
||||
|
||||
bool RS485_ReceiveError(
|
||||
|
||||
@@ -37,13 +37,13 @@ extern "C" {
|
||||
uint32_t object_instance);
|
||||
bool Analog_Input_Name_Set(
|
||||
uint32_t object_instance,
|
||||
char *new_name);
|
||||
const char *new_name);
|
||||
|
||||
char *Analog_Input_Description(
|
||||
const char *Analog_Input_Description(
|
||||
uint32_t instance);
|
||||
bool Analog_Input_Description_Set(
|
||||
uint32_t instance,
|
||||
char *new_name);
|
||||
const char *new_name);
|
||||
|
||||
bool Analog_Input_Units_Set(
|
||||
uint32_t instance,
|
||||
|
||||
@@ -226,7 +226,7 @@ static void MSTP_Send_Frame(
|
||||
uint8_t frame_type, /* type of frame to send - see defines */
|
||||
uint8_t destination, /* destination address */
|
||||
uint8_t source, /* source address */
|
||||
uint8_t *pdu, /* any data to be sent - may be null */
|
||||
const uint8_t *pdu, /* any data to be sent - may be null */
|
||||
uint16_t pdu_len)
|
||||
{ /* number of bytes of data (up to 501) */
|
||||
uint8_t crc8 = 0xFF; /* used to calculate the crc value */
|
||||
@@ -635,7 +635,7 @@ static bool MSTP_Master_Node_FSM(void)
|
||||
if (TransmitPacketLen) {
|
||||
MSTP_Send_Frame(FRAME_TYPE_BACNET_DATA_NOT_EXPECTING_REPLY,
|
||||
MSTP_BROADCAST_ADDRESS, This_Station,
|
||||
(uint8_t *)&TransmitPacket[0], TransmitPacketLen);
|
||||
&TransmitPacket[0], TransmitPacketLen);
|
||||
FrameCount++;
|
||||
} else {
|
||||
/* NothingToSend */
|
||||
@@ -959,7 +959,7 @@ static bool MSTP_Master_Node_FSM(void)
|
||||
/* Note: optimized such that we are never a client */
|
||||
MSTP_Send_Frame(FRAME_TYPE_BACNET_DATA_NOT_EXPECTING_REPLY,
|
||||
TransmitPacketDest, This_Station,
|
||||
(uint8_t *)&TransmitPacket[0], TransmitPacketLen);
|
||||
&TransmitPacket[0], TransmitPacketLen);
|
||||
MSTP_Flag.TransmitPacketPending = false;
|
||||
Master_State = MSTP_MASTER_STATE_IDLE;
|
||||
} else {
|
||||
|
||||
@@ -144,7 +144,7 @@ void RS485_Turnaround_Delay(void)
|
||||
* @param buffer - data to send
|
||||
* @param nbytes - number of bytes of data
|
||||
*/
|
||||
void RS485_Send_Data(uint8_t *buffer,
|
||||
void RS485_Send_Data(const uint8_t *buffer,
|
||||
uint16_t nbytes)
|
||||
{
|
||||
while (nbytes) {
|
||||
|
||||
@@ -21,7 +21,7 @@ extern "C" {
|
||||
bool enable);
|
||||
|
||||
void RS485_Send_Data(
|
||||
uint8_t * buffer, /* data to send */
|
||||
const uint8_t * buffer, /* data to send */
|
||||
uint16_t nbytes); /* number of bytes of data */
|
||||
|
||||
bool RS485_ReceiveError(
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#include "bacnet/basic/object/device.h"
|
||||
#include "bname.h"
|
||||
|
||||
static bool bacnet_name_isvalid(uint8_t encoding, uint8_t length, char *str)
|
||||
static bool bacnet_name_isvalid(uint8_t encoding, uint8_t length, const char *str)
|
||||
{
|
||||
bool valid = false;
|
||||
|
||||
@@ -35,7 +35,7 @@ static bool bacnet_name_isvalid(uint8_t encoding, uint8_t length, char *str)
|
||||
}
|
||||
|
||||
bool bacnet_name_save(
|
||||
uint16_t offset, uint8_t encoding, char *str, uint8_t length)
|
||||
uint16_t offset, uint8_t encoding, const char *str, uint8_t length)
|
||||
{
|
||||
uint8_t buffer[NV_EEPROM_NAME_SIZE] = { 0 };
|
||||
uint8_t i = 0;
|
||||
@@ -55,11 +55,11 @@ bool bacnet_name_save(
|
||||
return false;
|
||||
}
|
||||
|
||||
bool bacnet_name_set(uint16_t offset, BACNET_CHARACTER_STRING *char_string)
|
||||
bool bacnet_name_set(uint16_t offset, const BACNET_CHARACTER_STRING *char_string)
|
||||
{
|
||||
uint8_t encoding = 0;
|
||||
uint8_t length = 0;
|
||||
char *str = NULL;
|
||||
const char *str = NULL;
|
||||
|
||||
length = characterstring_length(char_string);
|
||||
encoding = characterstring_encoding(char_string);
|
||||
@@ -70,7 +70,7 @@ bool bacnet_name_set(uint16_t offset, BACNET_CHARACTER_STRING *char_string)
|
||||
bool bacnet_name_write_unique(uint16_t offset,
|
||||
BACNET_OBJECT_TYPE object_type,
|
||||
uint32_t object_instance,
|
||||
BACNET_CHARACTER_STRING *char_string,
|
||||
const BACNET_CHARACTER_STRING *char_string,
|
||||
BACNET_ERROR_CLASS *error_class,
|
||||
BACNET_ERROR_CODE *error_code)
|
||||
{
|
||||
@@ -120,7 +120,7 @@ bool bacnet_name_write_unique(uint16_t offset,
|
||||
|
||||
/* no required minumum length or duplicate checking */
|
||||
bool bacnet_name_write(uint16_t offset,
|
||||
BACNET_CHARACTER_STRING *char_string,
|
||||
const BACNET_CHARACTER_STRING *char_string,
|
||||
BACNET_ERROR_CLASS *error_class,
|
||||
BACNET_ERROR_CODE *error_code)
|
||||
{
|
||||
@@ -149,14 +149,16 @@ bool bacnet_name_write(uint16_t offset,
|
||||
return status;
|
||||
}
|
||||
|
||||
void bacnet_name_init(uint16_t offset, char *default_string)
|
||||
void bacnet_name_init(uint16_t offset, const char *default_string)
|
||||
{
|
||||
(void)bacnet_name_save(
|
||||
offset, CHARACTER_UTF8, default_string, strlen(default_string));
|
||||
}
|
||||
|
||||
void bacnet_name(
|
||||
uint16_t offset, BACNET_CHARACTER_STRING *char_string, char *default_string)
|
||||
uint16_t offset,
|
||||
BACNET_CHARACTER_STRING *char_string,
|
||||
const char *default_string)
|
||||
{
|
||||
uint8_t encoding = 0;
|
||||
uint8_t length = 0;
|
||||
|
||||
@@ -17,30 +17,30 @@ extern "C" {
|
||||
|
||||
bool bacnet_name_set(
|
||||
uint16_t eeprom_offset,
|
||||
BACNET_CHARACTER_STRING * char_string);
|
||||
const BACNET_CHARACTER_STRING * char_string);
|
||||
void bacnet_name_init(
|
||||
uint16_t eeprom_offset,
|
||||
char *default_string);
|
||||
const char *default_string);
|
||||
bool bacnet_name_save(
|
||||
uint16_t offset,
|
||||
uint8_t encoding,
|
||||
char *str,
|
||||
const char *str,
|
||||
uint8_t length);
|
||||
void bacnet_name(
|
||||
uint16_t eeprom_offset,
|
||||
BACNET_CHARACTER_STRING * char_string,
|
||||
char *default_string);
|
||||
const char *default_string);
|
||||
bool bacnet_name_write_unique(
|
||||
uint16_t offset,
|
||||
BACNET_OBJECT_TYPE object_type,
|
||||
uint32_t object_instance,
|
||||
BACNET_CHARACTER_STRING * char_string,
|
||||
const BACNET_CHARACTER_STRING * char_string,
|
||||
BACNET_ERROR_CLASS * error_class,
|
||||
BACNET_ERROR_CODE * error_code);
|
||||
/* no required minumum length or duplicate checking */
|
||||
bool bacnet_name_write(
|
||||
uint16_t offset,
|
||||
BACNET_CHARACTER_STRING * char_string,
|
||||
const BACNET_CHARACTER_STRING * char_string,
|
||||
BACNET_ERROR_CLASS * error_class,
|
||||
BACNET_ERROR_CODE * error_code);
|
||||
|
||||
|
||||
@@ -551,7 +551,7 @@ int Device_Object_List_Element_Encode(
|
||||
return apdu_len;
|
||||
}
|
||||
|
||||
bool Device_Valid_Object_Name(BACNET_CHARACTER_STRING *object_name1,
|
||||
bool Device_Valid_Object_Name(const BACNET_CHARACTER_STRING *object_name1,
|
||||
BACNET_OBJECT_TYPE *object_type,
|
||||
uint32_t *object_instance)
|
||||
{
|
||||
|
||||
@@ -196,10 +196,10 @@ void dlmstp_fill_bacnet_address(BACNET_ADDRESS *src, uint8_t mstp_address)
|
||||
}
|
||||
}
|
||||
|
||||
static bool dlmstp_compare_data_expecting_reply(uint8_t *request_pdu,
|
||||
static bool dlmstp_compare_data_expecting_reply(const uint8_t *request_pdu,
|
||||
uint16_t request_pdu_len,
|
||||
uint8_t src_address,
|
||||
uint8_t *reply_pdu,
|
||||
const uint8_t *reply_pdu,
|
||||
uint16_t reply_pdu_len,
|
||||
uint8_t dest_address)
|
||||
{
|
||||
@@ -315,7 +315,7 @@ static void MSTP_Send_Frame(
|
||||
uint8_t frame_type, /* type of frame to send - see defines */
|
||||
uint8_t destination, /* destination address */
|
||||
uint8_t source, /* source address */
|
||||
uint8_t *data, /* any data to be sent - may be null */
|
||||
const uint8_t *data, /* any data to be sent - may be null */
|
||||
uint16_t data_len)
|
||||
{ /* number of bytes of data (up to 501) */
|
||||
uint8_t crc8 = 0xFF; /* used to calculate the crc value */
|
||||
@@ -757,7 +757,7 @@ static bool MSTP_Master_Node_FSM(void)
|
||||
frame_type = FRAME_TYPE_BACNET_DATA_NOT_EXPECTING_REPLY;
|
||||
}
|
||||
MSTP_Send_Frame(frame_type, pkt->destination_mac, This_Station,
|
||||
(uint8_t *)&pkt->buffer[0], pkt->length);
|
||||
&pkt->buffer[0], pkt->length);
|
||||
FrameCount++;
|
||||
switch (frame_type) {
|
||||
case FRAME_TYPE_BACNET_DATA_EXPECTING_REPLY:
|
||||
@@ -1111,7 +1111,7 @@ static bool MSTP_Master_Node_FSM(void)
|
||||
frame_type = FRAME_TYPE_BACNET_DATA_NOT_EXPECTING_REPLY;
|
||||
}
|
||||
MSTP_Send_Frame(frame_type, pkt->destination_mac, This_Station,
|
||||
(uint8_t *)&pkt->buffer[0], pkt->length);
|
||||
&pkt->buffer[0], pkt->length);
|
||||
Master_State = MSTP_MASTER_STATE_IDLE;
|
||||
/* clear our flag we were holding for comparison */
|
||||
MSTP_Flag.ReceivedValidFrame = false;
|
||||
@@ -1195,7 +1195,7 @@ static void MSTP_Slave_Node_FSM(void)
|
||||
frame_type = FRAME_TYPE_BACNET_DATA_NOT_EXPECTING_REPLY;
|
||||
}
|
||||
MSTP_Send_Frame(frame_type, pkt->destination_mac, This_Station,
|
||||
(uint8_t *)&pkt->buffer[0], pkt->length);
|
||||
&pkt->buffer[0], pkt->length);
|
||||
(void)Ringbuf_Pop(&PDU_Queue, NULL);
|
||||
}
|
||||
/* clear our flag we were holding for comparison */
|
||||
|
||||
@@ -30,7 +30,7 @@ int eeprom_bytes_read(
|
||||
}
|
||||
|
||||
int eeprom_bytes_write(uint16_t eeaddr, /* EEPROM starting memory address */
|
||||
uint8_t *buf, /* data to send */
|
||||
const uint8_t *buf, /* data to send */
|
||||
int len)
|
||||
{ /* number of bytes of data */
|
||||
int count = 0;
|
||||
|
||||
@@ -21,7 +21,7 @@ extern "C" {
|
||||
int nbytes); /* number of bytes of data to read */
|
||||
int eeprom_bytes_write(
|
||||
uint16_t ee_address, /* EEPROM starting memory address */
|
||||
uint8_t * buffer, /* data to send */
|
||||
const uint8_t * buffer, /* data to send */
|
||||
int nbytes); /* number of bytes of data */
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -295,7 +295,7 @@ bool Network_Port_MAC_Address(
|
||||
* @return true if object-name was set
|
||||
*/
|
||||
bool Network_Port_MAC_Address_Set(
|
||||
uint32_t object_instance, uint8_t *mac_src, uint8_t mac_len)
|
||||
uint32_t object_instance, const uint8_t *mac_src, uint8_t mac_len)
|
||||
{
|
||||
if (mac_len == 1) {
|
||||
Object_List[0].MAC_Address[0] = mac_src[0];
|
||||
|
||||
@@ -175,7 +175,7 @@ bool rs485_receive_error(void)
|
||||
* RETURN: none
|
||||
* NOTES: none
|
||||
*****************************************************************************/
|
||||
void rs485_bytes_send(uint8_t *buffer, /* data to send */
|
||||
void rs485_bytes_send(const uint8_t *buffer, /* data to send */
|
||||
uint16_t nbytes)
|
||||
{ /* number of bytes of data */
|
||||
led_on(LED_5);
|
||||
|
||||
@@ -23,7 +23,7 @@ extern "C" {
|
||||
bool rs485_receive_error(
|
||||
void);
|
||||
void rs485_bytes_send(
|
||||
uint8_t * buffer, /* data to send */
|
||||
const uint8_t * buffer, /* data to send */
|
||||
uint16_t nbytes); /* number of bytes of data */
|
||||
uint32_t rs485_baud_rate(
|
||||
void);
|
||||
|
||||
@@ -162,7 +162,7 @@ void bip_get_broadcast_address(BACNET_ADDRESS *dest)
|
||||
*
|
||||
* @param addr - network IPv4 address
|
||||
*/
|
||||
bool bip_set_addr(BACNET_IP_ADDRESS *addr)
|
||||
bool bip_set_addr(const BACNET_IP_ADDRESS *addr)
|
||||
{
|
||||
(void)addr;
|
||||
/* not something we do within this driver */
|
||||
@@ -189,7 +189,7 @@ bool bip_get_addr(BACNET_IP_ADDRESS *addr)
|
||||
* @param addr - network IPv4 address
|
||||
* @return true if the address was set
|
||||
*/
|
||||
bool bip_set_broadcast_addr(BACNET_IP_ADDRESS *addr)
|
||||
bool bip_set_broadcast_addr(const BACNET_IP_ADDRESS *addr)
|
||||
{
|
||||
(void)addr;
|
||||
/* not something we do within this driver */
|
||||
@@ -257,7 +257,8 @@ uint8_t bip_get_subnet_prefix(void)
|
||||
* @return Upon successful completion, returns the number of bytes sent.
|
||||
* Otherwise, -1 shall be returned and errno set to indicate the error.
|
||||
*/
|
||||
int bip_send_mpdu(BACNET_IP_ADDRESS *dest, uint8_t *mtu, uint16_t mtu_len)
|
||||
int bip_send_mpdu(
|
||||
const BACNET_IP_ADDRESS *dest, const uint8_t *mtu, uint16_t mtu_len)
|
||||
{
|
||||
struct sockaddr_in bip_dest = { 0 };
|
||||
|
||||
@@ -276,7 +277,7 @@ int bip_send_mpdu(BACNET_IP_ADDRESS *dest, uint8_t *mtu, uint16_t mtu_len)
|
||||
/* Send the packet */
|
||||
debug_print_ipv4(
|
||||
"Sending MPDU->", &bip_dest.sin_addr, bip_dest.sin_port, mtu_len);
|
||||
return sendto(BIP_Socket, (char *)mtu, mtu_len, 0,
|
||||
return sendto(BIP_Socket, (const char *)mtu, mtu_len, 0,
|
||||
(struct sockaddr *)&bip_dest, sizeof(struct sockaddr));
|
||||
}
|
||||
|
||||
@@ -472,7 +473,8 @@ static char *ifname_default(void)
|
||||
* @param addr [out] The netmask addr, broadcast addr, ip addr.
|
||||
* @param request [in] addr broadaddr netmask
|
||||
*/
|
||||
static int get_local_address(char *ifname, struct in_addr *addr, char *request)
|
||||
static int get_local_address(
|
||||
const char *ifname, struct in_addr *addr, const char *request)
|
||||
{
|
||||
char rv = '\0'; /* return value */
|
||||
|
||||
@@ -543,7 +545,7 @@ int bip_set_broadcast_binding(
|
||||
* @param ifname [in] The named interface to use for the network layer.
|
||||
* Eg, for MAC OS X, ifname is en0, en1, and others.
|
||||
*/
|
||||
void bip_set_interface(char *ifname)
|
||||
void bip_set_interface(const char *ifname)
|
||||
{
|
||||
struct in_addr local_address;
|
||||
struct in_addr broadcast_address;
|
||||
@@ -602,7 +604,7 @@ void bip_set_interface(char *ifname)
|
||||
}
|
||||
}
|
||||
|
||||
static int createSocket(struct sockaddr_in *sin)
|
||||
static int createSocket(const struct sockaddr_in *sin)
|
||||
{
|
||||
int status = 0; /* return from socket lib calls */
|
||||
int sockopt = 0;
|
||||
|
||||
+5
-4
@@ -181,7 +181,7 @@ void bip6_get_my_address(BACNET_ADDRESS *addr)
|
||||
*
|
||||
* @param addr - network IPv6 address
|
||||
*/
|
||||
bool bip6_set_addr(BACNET_IP6_ADDRESS *addr)
|
||||
bool bip6_set_addr(const BACNET_IP6_ADDRESS *addr)
|
||||
{
|
||||
return bvlc6_address_copy(&BIP6_Addr, addr);
|
||||
}
|
||||
@@ -201,7 +201,7 @@ bool bip6_get_addr(BACNET_IP6_ADDRESS *addr)
|
||||
*
|
||||
* @param addr - network IPv6 address
|
||||
*/
|
||||
bool bip6_set_broadcast_addr(BACNET_IP6_ADDRESS *addr)
|
||||
bool bip6_set_broadcast_addr(const BACNET_IP6_ADDRESS *addr)
|
||||
{
|
||||
return bvlc6_address_copy(&BIP6_Broadcast_Addr, addr);
|
||||
}
|
||||
@@ -227,7 +227,8 @@ bool bip6_get_broadcast_addr(BACNET_IP6_ADDRESS *addr)
|
||||
* @return Upon successful completion, returns the number of bytes sent.
|
||||
* Otherwise, -1 shall be returned and errno set to indicate the error.
|
||||
*/
|
||||
int bip6_send_mpdu(BACNET_IP6_ADDRESS *dest, uint8_t *mtu, uint16_t mtu_len)
|
||||
int bip6_send_mpdu(
|
||||
const BACNET_IP6_ADDRESS *dest, const uint8_t *mtu, uint16_t mtu_len)
|
||||
{
|
||||
struct sockaddr_in6 bvlc_dest = { 0 };
|
||||
uint16_t addr16[8];
|
||||
@@ -252,7 +253,7 @@ int bip6_send_mpdu(BACNET_IP6_ADDRESS *dest, uint8_t *mtu, uint16_t mtu_len)
|
||||
bvlc_dest.sin6_scope_id = BIP6_Socket_Scope_Id;
|
||||
debug_print_ipv6("Sending MPDU->", &bvlc_dest.sin6_addr);
|
||||
/* Send the packet */
|
||||
return sendto(BIP6_Socket, (char *)mtu, mtu_len, 0,
|
||||
return sendto(BIP6_Socket, (const char *)mtu, mtu_len, 0,
|
||||
(struct sockaddr *)&bvlc_dest, sizeof(bvlc_dest));
|
||||
}
|
||||
|
||||
|
||||
@@ -27,8 +27,7 @@
|
||||
* @param utc - True for UTC sync, False for Local time
|
||||
* @return True if time is set
|
||||
*/
|
||||
void datetime_timesync(
|
||||
BACNET_DATE *bdate, BACNET_TIME *btime, bool utc)
|
||||
void datetime_timesync(BACNET_DATE *bdate, BACNET_TIME *btime, bool utc)
|
||||
{
|
||||
(void)bdate;
|
||||
(void)btime;
|
||||
|
||||
+1
-1
@@ -396,7 +396,7 @@ bool RS485_Set_Baud_Rate(uint32_t baud)
|
||||
*****************************************************************************/
|
||||
void RS485_Send_Frame(
|
||||
struct mstp_port_struct_t *mstp_port, /* port specific data */
|
||||
uint8_t *buffer, /* frame to send (up to 501 bytes of data) */
|
||||
const uint8_t *buffer, /* frame to send (up to 501 bytes of data) */
|
||||
uint16_t nbytes)
|
||||
{ /* number of bytes of data (up to 501) */
|
||||
uint32_t turnaround_time = Tturnaround * 1000;
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ void RS485_Initialize(void);
|
||||
BACNET_STACK_EXPORT
|
||||
void RS485_Send_Frame(
|
||||
struct mstp_port_struct_t *mstp_port, /* port specific data */
|
||||
uint8_t *buffer, /* frame to send (up to 501 bytes of data) */
|
||||
const uint8_t *buffer, /* frame to send (up to 501 bytes of data) */
|
||||
uint16_t nbytes); /* number of bytes of data (up to 501) */
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
|
||||
@@ -73,13 +73,13 @@ extern "C" {
|
||||
BACNET_CHARACTER_STRING * object_name);
|
||||
bool Analog_Input_Name_Set(
|
||||
uint32_t object_instance,
|
||||
char *new_name);
|
||||
const char *new_name);
|
||||
|
||||
char *Analog_Input_Description(
|
||||
const char *Analog_Input_Description(
|
||||
uint32_t instance);
|
||||
bool Analog_Input_Description_Set(
|
||||
uint32_t instance,
|
||||
char *new_name);
|
||||
const char *new_name);
|
||||
|
||||
bool Analog_Input_Units_Set(
|
||||
uint32_t instance,
|
||||
|
||||
@@ -15,7 +15,7 @@ long bip_get_addr_by_name(const char *host_name)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void bip_set_interface(char *ifname)
|
||||
void bip_set_interface(const char *ifname)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -45,13 +45,13 @@ extern "C" {
|
||||
uint32_t object_instance,
|
||||
char *new_name);
|
||||
|
||||
char *Binary_Output_Description(
|
||||
const char *Binary_Output_Description(
|
||||
uint32_t instance);
|
||||
bool Binary_Output_Description_Set(
|
||||
uint32_t instance,
|
||||
char *new_name);
|
||||
const char *new_name);
|
||||
|
||||
char *Binary_Output_Inactive_Text(
|
||||
const char *Binary_Output_Inactive_Text(
|
||||
uint32_t instance);
|
||||
bool Binary_Output_Inactive_Text_Set(
|
||||
uint32_t instance,
|
||||
|
||||
@@ -381,7 +381,7 @@ bool Device_Object_Name(
|
||||
return status;
|
||||
}
|
||||
|
||||
bool Device_Set_Object_Name(BACNET_CHARACTER_STRING *object_name)
|
||||
bool Device_Set_Object_Name(const BACNET_CHARACTER_STRING *object_name)
|
||||
{
|
||||
bool status = false; /*return value */
|
||||
|
||||
@@ -689,7 +689,7 @@ bool Device_Object_List_Identifier(
|
||||
* Object.
|
||||
* @return True on success or else False if not found.
|
||||
*/
|
||||
bool Device_Valid_Object_Name(BACNET_CHARACTER_STRING *object_name1,
|
||||
bool Device_Valid_Object_Name(const BACNET_CHARACTER_STRING *object_name1,
|
||||
BACNET_OBJECT_TYPE *object_type,
|
||||
uint32_t *object_instance)
|
||||
{
|
||||
|
||||
@@ -274,7 +274,7 @@ extern "C" {
|
||||
uint32_t object_instance,
|
||||
BACNET_CHARACTER_STRING * object_name);
|
||||
bool Device_Set_Object_Name(
|
||||
BACNET_CHARACTER_STRING * object_name);
|
||||
const BACNET_CHARACTER_STRING * object_name);
|
||||
/* Copy a child object name, given its ID. */
|
||||
bool Device_Object_Name_Copy(
|
||||
BACNET_OBJECT_TYPE object_type,
|
||||
@@ -340,7 +340,7 @@ extern "C" {
|
||||
void);
|
||||
|
||||
bool Device_Valid_Object_Name(
|
||||
BACNET_CHARACTER_STRING * object_name,
|
||||
const BACNET_CHARACTER_STRING * object_name,
|
||||
BACNET_OBJECT_TYPE *object_type,
|
||||
uint32_t * object_instance);
|
||||
bool Device_Valid_Object_Id(
|
||||
@@ -375,7 +375,7 @@ extern "C" {
|
||||
|
||||
uint16_t Add_Routed_Device(
|
||||
uint32_t Object_Instance,
|
||||
BACNET_CHARACTER_STRING * Object_Name,
|
||||
const BACNET_CHARACTER_STRING * Object_Name,
|
||||
const char *Description);
|
||||
DEVICE_OBJECT_DATA *Get_Routed_Device_Object(
|
||||
int idx);
|
||||
@@ -388,14 +388,14 @@ extern "C" {
|
||||
bool Routed_Device_Address_Lookup(
|
||||
int idx,
|
||||
uint8_t address_len,
|
||||
uint8_t * mac_adress);
|
||||
const uint8_t * mac_adress);
|
||||
bool Routed_Device_GetNext(
|
||||
BACNET_ADDRESS * dest,
|
||||
int *DNET_list,
|
||||
const BACNET_ADDRESS * dest,
|
||||
const int *DNET_list,
|
||||
int *cursor);
|
||||
bool Routed_Device_Is_Valid_Network(
|
||||
uint16_t dest_net,
|
||||
int *DNET_list);
|
||||
const int *DNET_list);
|
||||
|
||||
uint32_t Routed_Device_Index_To_Instance(
|
||||
unsigned index);
|
||||
|
||||
@@ -69,7 +69,7 @@ void arcnet_cleanup(void)
|
||||
return;
|
||||
}
|
||||
|
||||
static int arcnet_bind(char *interface_name)
|
||||
static int arcnet_bind(const char *interface_name)
|
||||
{
|
||||
int sock_fd = -1; /* return value */
|
||||
struct ifreq ifr;
|
||||
|
||||
@@ -100,7 +100,7 @@ extern int bip_get_local_netmask(
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
extern int bip_get_local_address_ioctl(
|
||||
char *ifname,
|
||||
const char *ifname,
|
||||
struct in_addr *addr,
|
||||
int request);
|
||||
|
||||
|
||||
+11
-8
@@ -178,7 +178,7 @@ void bip_get_broadcast_address(BACNET_ADDRESS *dest)
|
||||
*
|
||||
* @param addr - network IPv4 address
|
||||
*/
|
||||
bool bip_set_addr(BACNET_IP_ADDRESS *addr)
|
||||
bool bip_set_addr(const BACNET_IP_ADDRESS *addr)
|
||||
{
|
||||
/* not something we do within this driver */
|
||||
(void)addr;
|
||||
@@ -205,7 +205,7 @@ bool bip_get_addr(BACNET_IP_ADDRESS *addr)
|
||||
* @param addr - network IPv4 address
|
||||
* @return true if the address was set
|
||||
*/
|
||||
bool bip_set_broadcast_addr(BACNET_IP_ADDRESS *addr)
|
||||
bool bip_set_broadcast_addr(const BACNET_IP_ADDRESS *addr)
|
||||
{
|
||||
/* not something we do within this driver */
|
||||
(void)addr;
|
||||
@@ -273,7 +273,8 @@ uint8_t bip_get_subnet_prefix(void)
|
||||
* @return Upon successful completion, returns the number of bytes sent.
|
||||
* Otherwise, -1 shall be returned and errno set to indicate the error.
|
||||
*/
|
||||
int bip_send_mpdu(BACNET_IP_ADDRESS *dest, uint8_t *mtu, uint16_t mtu_len)
|
||||
int bip_send_mpdu(
|
||||
const BACNET_IP_ADDRESS *dest, const uint8_t *mtu, uint16_t mtu_len)
|
||||
{
|
||||
struct sockaddr_in bip_dest = { 0 };
|
||||
|
||||
@@ -292,7 +293,7 @@ int bip_send_mpdu(BACNET_IP_ADDRESS *dest, uint8_t *mtu, uint16_t mtu_len)
|
||||
/* Send the packet */
|
||||
debug_print_ipv4(
|
||||
"Sending MPDU->", &bip_dest.sin_addr, bip_dest.sin_port, mtu_len);
|
||||
return sendto(BIP_Socket, (char *)mtu, mtu_len, 0,
|
||||
return sendto(BIP_Socket, (const char *)mtu, mtu_len, 0,
|
||||
(struct sockaddr *)&bip_dest, sizeof(struct sockaddr));
|
||||
}
|
||||
|
||||
@@ -465,7 +466,8 @@ bool bip_get_addr_by_name(const char *host_name, BACNET_IP_ADDRESS *addr)
|
||||
* @param request - the ioctl() request
|
||||
* @return 0 on success, else the error from the ioctl() call.
|
||||
*/
|
||||
static int get_local_ifr_ioctl(char *ifname, struct ifreq *ifr, int request)
|
||||
static int get_local_ifr_ioctl(
|
||||
const char *ifname, struct ifreq *ifr, int request)
|
||||
{
|
||||
int fd;
|
||||
int rv; /* return value */
|
||||
@@ -491,7 +493,8 @@ static int get_local_ifr_ioctl(char *ifname, struct ifreq *ifr, int request)
|
||||
* @param request - the ioctl() request
|
||||
* @return 0 on success, else the error from the ioctl() call.
|
||||
*/
|
||||
int bip_get_local_address_ioctl(char *ifname, struct in_addr *addr, int request)
|
||||
int bip_get_local_address_ioctl(
|
||||
const char *ifname, struct in_addr *addr, int request)
|
||||
{
|
||||
struct ifreq ifr = { 0 };
|
||||
struct sockaddr_in *tcpip_address;
|
||||
@@ -746,7 +749,7 @@ int bip_set_broadcast_binding(
|
||||
* @param ifname [in] The named interface to use for the network layer.
|
||||
* Eg, for Linux, ifname is eth0, ath0, arc0, and others.
|
||||
*/
|
||||
void bip_set_interface(char *ifname)
|
||||
void bip_set_interface(const char *ifname)
|
||||
{
|
||||
struct in_addr local_address;
|
||||
struct in_addr netmask;
|
||||
@@ -804,7 +807,7 @@ void bip_set_interface(char *ifname)
|
||||
}
|
||||
}
|
||||
|
||||
static int createSocket(struct sockaddr_in *sin)
|
||||
static int createSocket(const struct sockaddr_in *sin)
|
||||
{
|
||||
int status = 0; /* return from socket lib calls */
|
||||
int sockopt = 0;
|
||||
|
||||
+5
-4
@@ -188,7 +188,7 @@ void bip6_get_my_address(BACNET_ADDRESS *addr)
|
||||
*
|
||||
* @param addr - network IPv6 address
|
||||
*/
|
||||
bool bip6_set_addr(BACNET_IP6_ADDRESS *addr)
|
||||
bool bip6_set_addr(const BACNET_IP6_ADDRESS *addr)
|
||||
{
|
||||
return bvlc6_address_copy(&BIP6_Addr, addr);
|
||||
}
|
||||
@@ -208,7 +208,7 @@ bool bip6_get_addr(BACNET_IP6_ADDRESS *addr)
|
||||
*
|
||||
* @param addr - network IPv6 address
|
||||
*/
|
||||
bool bip6_set_broadcast_addr(BACNET_IP6_ADDRESS *addr)
|
||||
bool bip6_set_broadcast_addr(const BACNET_IP6_ADDRESS *addr)
|
||||
{
|
||||
return bvlc6_address_copy(&BIP6_Broadcast_Addr, addr);
|
||||
}
|
||||
@@ -234,7 +234,8 @@ bool bip6_get_broadcast_addr(BACNET_IP6_ADDRESS *addr)
|
||||
* @return Upon successful completion, returns the number of bytes sent.
|
||||
* Otherwise, -1 shall be returned and errno set to indicate the error.
|
||||
*/
|
||||
int bip6_send_mpdu(BACNET_IP6_ADDRESS *dest, uint8_t *mtu, uint16_t mtu_len)
|
||||
int bip6_send_mpdu(
|
||||
const BACNET_IP6_ADDRESS *dest, const uint8_t *mtu, uint16_t mtu_len)
|
||||
{
|
||||
struct sockaddr_in6 bvlc_dest = { 0 };
|
||||
uint16_t addr16[8];
|
||||
@@ -259,7 +260,7 @@ int bip6_send_mpdu(BACNET_IP6_ADDRESS *dest, uint8_t *mtu, uint16_t mtu_len)
|
||||
bvlc_dest.sin6_scope_id = BIP6_Socket_Scope_Id;
|
||||
debug_print_ipv6("Sending MPDU->", &bvlc_dest.sin6_addr);
|
||||
/* Send the packet */
|
||||
return sendto(BIP6_Socket, (char *)mtu, mtu_len, 0,
|
||||
return sendto(BIP6_Socket, (const char *)mtu, mtu_len, 0,
|
||||
(struct sockaddr *)&bvlc_dest, sizeof(bvlc_dest));
|
||||
}
|
||||
|
||||
|
||||
@@ -398,16 +398,18 @@ uint16_t MSTP_Get_Send(struct mstp_port_struct_t *mstp_port, unsigned timeout)
|
||||
* @param nbytes - number of bytes of data to send
|
||||
*/
|
||||
void MSTP_Send_Frame(
|
||||
struct mstp_port_struct_t *mstp_port, uint8_t *buffer, uint16_t nbytes)
|
||||
struct mstp_port_struct_t *mstp_port,
|
||||
const uint8_t *buffer,
|
||||
uint16_t nbytes)
|
||||
{
|
||||
RS485_Send_Frame(mstp_port, buffer, nbytes);
|
||||
}
|
||||
|
||||
static bool dlmstp_compare_data_expecting_reply(
|
||||
uint8_t *request_pdu,
|
||||
const uint8_t *request_pdu,
|
||||
uint16_t request_pdu_len,
|
||||
uint8_t src_address,
|
||||
uint8_t *reply_pdu,
|
||||
const uint8_t *reply_pdu,
|
||||
uint16_t reply_pdu_len,
|
||||
uint8_t dest_address)
|
||||
{
|
||||
|
||||
@@ -379,16 +379,18 @@ uint16_t MSTP_Get_Send(struct mstp_port_struct_t *mstp_port, unsigned timeout)
|
||||
* @param nbytes - number of bytes of data to send
|
||||
*/
|
||||
void MSTP_Send_Frame(
|
||||
struct mstp_port_struct_t *mstp_port, uint8_t *buffer, uint16_t nbytes)
|
||||
struct mstp_port_struct_t *mstp_port,
|
||||
const uint8_t *buffer,
|
||||
uint16_t nbytes)
|
||||
{
|
||||
RS485_Send_Frame(mstp_port, buffer, nbytes);
|
||||
}
|
||||
|
||||
static bool dlmstp_compare_data_expecting_reply(
|
||||
uint8_t *request_pdu,
|
||||
const uint8_t *request_pdu,
|
||||
uint16_t request_pdu_len,
|
||||
uint8_t src_address,
|
||||
uint8_t *reply_pdu,
|
||||
const uint8_t *reply_pdu,
|
||||
uint16_t reply_pdu_len,
|
||||
uint8_t dest_address)
|
||||
{
|
||||
|
||||
@@ -64,7 +64,7 @@ int setNonblocking(
|
||||
#endif
|
||||
|
||||
/* opens an 802.2 socket to receive and send packets */
|
||||
static int ethernet_bind(struct sockaddr *eth_addr, char *interface_name)
|
||||
static int ethernet_bind(struct sockaddr *eth_addr, const char *interface_name)
|
||||
{
|
||||
int sock_fd = -1; /* return value */
|
||||
#if 0
|
||||
@@ -339,7 +339,7 @@ uint16_t ethernet_receive(BACNET_ADDRESS *src, /* source address */
|
||||
return pdu_len;
|
||||
}
|
||||
|
||||
void ethernet_set_my_address(BACNET_ADDRESS *my_address)
|
||||
void ethernet_set_my_address(const BACNET_ADDRESS *my_address)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
@@ -387,7 +387,7 @@ void ethernet_get_broadcast_address(BACNET_ADDRESS *dest)
|
||||
return;
|
||||
}
|
||||
|
||||
void ethernet_debug_address(const char *info, BACNET_ADDRESS *dest)
|
||||
void ethernet_debug_address(const char *info, const BACNET_ADDRESS *dest)
|
||||
{
|
||||
int i = 0; /* counter */
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ uint16_t MSTP_Get_Send(
|
||||
*/
|
||||
void MSTP_Send_Frame(
|
||||
struct mstp_port_struct_t *mstp_port,
|
||||
uint8_t * buffer,
|
||||
const uint8_t * buffer,
|
||||
uint16_t nbytes)
|
||||
{
|
||||
(void)mstp_port;
|
||||
@@ -141,7 +141,7 @@ static int network_init(const char *name, int protocol)
|
||||
}
|
||||
|
||||
static void snap_received_packet(
|
||||
struct mstp_port_struct_t *mstp_port, int sockfd)
|
||||
const struct mstp_port_struct_t *mstp_port, int sockfd)
|
||||
{
|
||||
uint16_t mtu_len = 0; /* number of octets of packet saved in file */
|
||||
unsigned i = 0; /* counter */
|
||||
|
||||
+2
-2
@@ -355,14 +355,14 @@ bool RS485_Set_Baud_Rate(uint32_t baud)
|
||||
*****************************************************************************/
|
||||
void RS485_Send_Frame(
|
||||
struct mstp_port_struct_t *mstp_port, /* port specific data */
|
||||
uint8_t *buffer, /* frame to send (up to 501 bytes of data) */
|
||||
const uint8_t *buffer, /* frame to send (up to 501 bytes of data) */
|
||||
uint16_t nbytes)
|
||||
{ /* number of bytes of data (up to 501) */
|
||||
uint32_t turnaround_time = Tturnaround * 1000;
|
||||
uint32_t baud;
|
||||
ssize_t written = 0;
|
||||
int greska;
|
||||
SHARED_MSTP_DATA *poSharedData = NULL;
|
||||
const SHARED_MSTP_DATA *poSharedData = NULL;
|
||||
|
||||
if (mstp_port) {
|
||||
poSharedData = (SHARED_MSTP_DATA *)mstp_port->UserData;
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ extern "C" {
|
||||
BACNET_STACK_EXPORT
|
||||
void RS485_Send_Frame(
|
||||
struct mstp_port_struct_t *mstp_port, /* port specific data */
|
||||
uint8_t * buffer, /* frame to send (up to 501 bytes of data) */
|
||||
const uint8_t * buffer, /* frame to send (up to 501 bytes of data) */
|
||||
uint16_t nbytes); /* number of bytes of data (up to 501) */
|
||||
|
||||
BACNET_STACK_EXPORT
|
||||
|
||||
+5
-5
@@ -67,7 +67,7 @@ uint32_t bip_stats_drop(void)
|
||||
* @param addr - network IPv4 address
|
||||
* @return true if the address is set
|
||||
*/
|
||||
bool bip_set_addr(BACNET_IP_ADDRESS *addr)
|
||||
bool bip_set_addr(const BACNET_IP_ADDRESS *addr)
|
||||
{
|
||||
return bvlc_address_copy(&BIP_Address, addr);
|
||||
}
|
||||
@@ -87,7 +87,7 @@ bool bip_get_addr(BACNET_IP_ADDRESS *addr)
|
||||
* @param network IPv4 broadcast address
|
||||
* @return true if the broadcast address is retrieved
|
||||
*/
|
||||
bool bip_set_broadcast_addr(BACNET_IP_ADDRESS *addr)
|
||||
bool bip_set_broadcast_addr(const BACNET_IP_ADDRESS *addr)
|
||||
{
|
||||
return bvlc_address_copy(&BIP_Broadcast_Address, addr);
|
||||
}
|
||||
@@ -137,7 +137,7 @@ uint16_t bip_get_port(void)
|
||||
* @param address - IPv4 address from LwIP
|
||||
* @param mac - IP address from BACnet/IP
|
||||
*/
|
||||
static void bip_mac_to_addr(ip4_addr_t *address, uint8_t *mac)
|
||||
static void bip_mac_to_addr(ip4_addr_t *address, const uint8_t *mac)
|
||||
{
|
||||
if (mac && address) {
|
||||
address->addr = ((u32_t)((((uint32_t)mac[0]) << 24) & 0xff000000));
|
||||
@@ -153,7 +153,7 @@ static void bip_mac_to_addr(ip4_addr_t *address, uint8_t *mac)
|
||||
* @param address - IPv4 address from LwIP
|
||||
* @param port - IPv4 UDP port number
|
||||
*/
|
||||
static int bip_decode_bip_address(BACNET_IP_ADDRESS *baddr,
|
||||
static int bip_decode_bip_address(const BACNET_IP_ADDRESS *baddr,
|
||||
ip_addr_t *address,
|
||||
uint16_t *port)
|
||||
{
|
||||
@@ -215,7 +215,7 @@ static int bip_encode_bip_address(BACNET_IP_ADDRESS *baddr,
|
||||
* @return number of bytes sent, or 0 on failure.
|
||||
*/
|
||||
int bip_send_mpdu(
|
||||
BACNET_IP_ADDRESS *dest, uint8_t *mtu, uint16_t mtu_len)
|
||||
const BACNET_IP_ADDRESS *dest, const uint8_t *mtu, uint16_t mtu_len)
|
||||
{
|
||||
struct pbuf *pkt = NULL;
|
||||
/* addr and port in host format */
|
||||
|
||||
@@ -118,7 +118,7 @@
|
||||
x++; \
|
||||
}
|
||||
|
||||
bool MSTP_Line_Active(volatile struct mstp_port_struct_t *mstp_port)
|
||||
bool MSTP_Line_Active(const volatile struct mstp_port_struct_t *mstp_port)
|
||||
{
|
||||
return (mstp_port->EventCount > Nmin_octets);
|
||||
}
|
||||
@@ -128,7 +128,7 @@ unsigned MSTP_Create_Frame(uint8_t *buffer, /* where frame is loaded */
|
||||
uint8_t frame_type, /* type of frame to send - see defines */
|
||||
uint8_t destination, /* destination address */
|
||||
uint8_t source, /* source address */
|
||||
uint8_t *data, /* any data to be sent - may be null */
|
||||
const uint8_t *data, /* any data to be sent - may be null */
|
||||
unsigned data_len)
|
||||
{ /* number of bytes of data (up to 501) */
|
||||
uint8_t crc8 = 0xFF; /* used to calculate the crc value */
|
||||
@@ -181,7 +181,7 @@ void MSTP_Create_And_Send_Frame(
|
||||
uint8_t frame_type, /* type of frame to send - see defines */
|
||||
uint8_t destination, /* destination address */
|
||||
uint8_t source, /* source address */
|
||||
uint8_t *data, /* any data to be sent - may be null */
|
||||
const uint8_t *data, /* any data to be sent - may be null */
|
||||
unsigned data_len)
|
||||
{ /* number of bytes of data (up to 501) */
|
||||
uint8_t buffer[DLMSTP_MPDU_MAX] = { 0 }; /* buffer for sending */
|
||||
|
||||
@@ -142,7 +142,7 @@ extern "C" {
|
||||
|
||||
/* returns true if line is active */
|
||||
bool MSTP_Line_Active(
|
||||
volatile struct mstp_port_struct_t *mstp_port);
|
||||
const volatile struct mstp_port_struct_t *mstp_port);
|
||||
|
||||
unsigned MSTP_Create_Frame(
|
||||
uint8_t * buffer, /* where frame is loaded */
|
||||
@@ -150,7 +150,7 @@ extern "C" {
|
||||
uint8_t frame_type, /* type of frame to send - see defines */
|
||||
uint8_t destination, /* destination address */
|
||||
uint8_t source, /* source address */
|
||||
uint8_t * data, /* any data to be sent - may be null */
|
||||
const uint8_t * data, /* any data to be sent - may be null */
|
||||
unsigned data_len); /* number of bytes of data (up to 501) */
|
||||
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ volatile uint8_t RS485_Tx_Buffer[NEXT_POWER_OF_2(DLMSTP_MPDU_MAX)];
|
||||
*****************************************************************************/
|
||||
void RS485_Send_Frame(
|
||||
volatile struct mstp_port_struct_t *mstp_port, /* port specific data */
|
||||
uint8_t *buffer, /* frame to send (up to 501 bytes of data) */
|
||||
const uint8_t *buffer, /* frame to send (up to 501 bytes of data) */
|
||||
uint16_t nbytes)
|
||||
{ /* number of bytes of data (up to 501) */
|
||||
uint16_t i = 0; /* loop counter */
|
||||
|
||||
@@ -28,7 +28,7 @@ extern "C" {
|
||||
|
||||
void RS485_Send_Frame(
|
||||
volatile struct mstp_port_struct_t *mstp_port, /* port specific data */
|
||||
uint8_t * buffer, /* frame to send (up to 501 bytes of data) */
|
||||
const uint8_t * buffer, /* frame to send (up to 501 bytes of data) */
|
||||
uint16_t nbytes); /* number of bytes of data (up to 501) */
|
||||
|
||||
/* returns true if there is more data waiting */
|
||||
|
||||
@@ -118,7 +118,7 @@
|
||||
x++; \
|
||||
}
|
||||
|
||||
bool MSTP_Line_Active(volatile struct mstp_port_struct_t *mstp_port)
|
||||
bool MSTP_Line_Active(const volatile struct mstp_port_struct_t *mstp_port)
|
||||
{
|
||||
return (mstp_port->EventCount > Nmin_octets);
|
||||
}
|
||||
@@ -128,7 +128,7 @@ unsigned MSTP_Create_Frame(uint8_t *buffer, /* where frame is loaded */
|
||||
uint8_t frame_type, /* type of frame to send - see defines */
|
||||
uint8_t destination, /* destination address */
|
||||
uint8_t source, /* source address */
|
||||
uint8_t *data, /* any data to be sent - may be null */
|
||||
const uint8_t *data, /* any data to be sent - may be null */
|
||||
unsigned data_len)
|
||||
{ /* number of bytes of data (up to 501) */
|
||||
uint8_t crc8 = 0xFF; /* used to calculate the crc value */
|
||||
@@ -181,7 +181,7 @@ void MSTP_Create_And_Send_Frame(
|
||||
uint8_t frame_type, /* type of frame to send - see defines */
|
||||
uint8_t destination, /* destination address */
|
||||
uint8_t source, /* source address */
|
||||
uint8_t *data, /* any data to be sent - may be null */
|
||||
const uint8_t *data, /* any data to be sent - may be null */
|
||||
unsigned data_len)
|
||||
{ /* number of bytes of data (up to 501) */
|
||||
uint8_t buffer[DLMSTP_MPDU_MAX] = { 0 }; /* buffer for sending */
|
||||
|
||||
@@ -142,7 +142,7 @@ extern "C" {
|
||||
|
||||
/* returns true if line is active */
|
||||
bool MSTP_Line_Active(
|
||||
volatile struct mstp_port_struct_t *mstp_port);
|
||||
const volatile struct mstp_port_struct_t *mstp_port);
|
||||
|
||||
unsigned MSTP_Create_Frame(
|
||||
uint8_t * buffer, /* where frame is loaded */
|
||||
@@ -150,7 +150,7 @@ extern "C" {
|
||||
uint8_t frame_type, /* type of frame to send - see defines */
|
||||
uint8_t destination, /* destination address */
|
||||
uint8_t source, /* source address */
|
||||
uint8_t * data, /* any data to be sent - may be null */
|
||||
const uint8_t * data, /* any data to be sent - may be null */
|
||||
unsigned data_len); /* number of bytes of data (up to 501) */
|
||||
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ volatile uint8_t RS485_Tx_Buffer[NEXT_POWER_OF_2(DLMSTP_MPDU_MAX)];
|
||||
*****************************************************************************/
|
||||
void RS485_Send_Frame(
|
||||
volatile struct mstp_port_struct_t *mstp_port, /* port specific data */
|
||||
uint8_t *buffer, /* frame to send (up to 501 bytes of data) */
|
||||
const uint8_t *buffer, /* frame to send (up to 501 bytes of data) */
|
||||
uint16_t nbytes)
|
||||
{ /* number of bytes of data (up to 501) */
|
||||
uint16_t i = 0; /* loop counter */
|
||||
|
||||
@@ -28,7 +28,7 @@ extern "C" {
|
||||
|
||||
void RS485_Send_Frame(
|
||||
volatile struct mstp_port_struct_t *mstp_port, /* port specific data */
|
||||
uint8_t * buffer, /* frame to send (up to 501 bytes of data) */
|
||||
const uint8_t * buffer, /* frame to send (up to 501 bytes of data) */
|
||||
uint16_t nbytes); /* number of bytes of data (up to 501) */
|
||||
|
||||
/* returns true if there is more data waiting */
|
||||
|
||||
@@ -107,11 +107,12 @@ static struct my_object_functions *Device_Objects_Find_Functions(
|
||||
}
|
||||
|
||||
static int Read_Property_Common(
|
||||
struct my_object_functions *pObject, BACNET_READ_PROPERTY_DATA *rpdata)
|
||||
const struct my_object_functions *pObject,
|
||||
BACNET_READ_PROPERTY_DATA *rpdata)
|
||||
{
|
||||
int apdu_len = BACNET_STATUS_ERROR;
|
||||
BACNET_CHARACTER_STRING char_string;
|
||||
char *pString = "";
|
||||
const char *pString = "";
|
||||
uint8_t *apdu = NULL;
|
||||
#if (BACNET_PROTOCOL_REVISION >= 14)
|
||||
struct special_property_list_t property_list;
|
||||
|
||||
@@ -174,7 +174,7 @@ uint16_t ethernet_receive(BACNET_ADDRESS *src, /* source address */
|
||||
return pdu_len;
|
||||
}
|
||||
|
||||
void ethernet_set_my_address(BACNET_ADDRESS *my_address)
|
||||
void ethernet_set_my_address(const BACNET_ADDRESS *my_address)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
|
||||
@@ -103,7 +103,8 @@ static struct my_object_functions *Device_Objects_Find_Functions(
|
||||
}
|
||||
|
||||
static int Read_Property_Common(
|
||||
struct my_object_functions *pObject, BACNET_READ_PROPERTY_DATA *rpdata)
|
||||
const struct my_object_functions *pObject,
|
||||
BACNET_READ_PROPERTY_DATA *rpdata)
|
||||
{
|
||||
int apdu_len = BACNET_STATUS_ERROR;
|
||||
BACNET_CHARACTER_STRING char_string;
|
||||
@@ -308,7 +309,7 @@ bool Device_Object_Name(
|
||||
return status;
|
||||
}
|
||||
|
||||
bool Device_Set_Object_Name(BACNET_CHARACTER_STRING *object_name)
|
||||
bool Device_Set_Object_Name(const BACNET_CHARACTER_STRING *object_name)
|
||||
{
|
||||
bool status = false; /*return value */
|
||||
|
||||
@@ -588,7 +589,7 @@ int Device_Object_List_Element_Encode(
|
||||
return apdu_len;
|
||||
}
|
||||
|
||||
bool Device_Valid_Object_Name(BACNET_CHARACTER_STRING *object_name1,
|
||||
bool Device_Valid_Object_Name(const BACNET_CHARACTER_STRING *object_name1,
|
||||
BACNET_OBJECT_TYPE *object_type,
|
||||
uint32_t *object_instance)
|
||||
{
|
||||
|
||||
@@ -294,7 +294,7 @@ bool Network_Port_MAC_Address(
|
||||
* @return true if object-name was set
|
||||
*/
|
||||
bool Network_Port_MAC_Address_Set(
|
||||
uint32_t object_instance, uint8_t *mac_src, uint8_t mac_len)
|
||||
uint32_t object_instance, const uint8_t *mac_src, uint8_t mac_len)
|
||||
{
|
||||
if (mac_len == 1) {
|
||||
Object_List[0].MAC_Address[0] = mac_src[0];
|
||||
|
||||
@@ -152,7 +152,7 @@ bool rs485_frame_sent(void)
|
||||
* @param nbytes - number of bytes to transmit
|
||||
* @return true if added to queue
|
||||
*/
|
||||
void rs485_bytes_send(uint8_t *buffer, /* data to send */
|
||||
void rs485_bytes_send(const uint8_t *buffer, /* data to send */
|
||||
uint16_t nbytes)
|
||||
{ /* number of bytes of data */
|
||||
uint8_t tx_byte;
|
||||
|
||||
@@ -30,7 +30,7 @@ extern "C" {
|
||||
bool rs485_receive_error(
|
||||
void);
|
||||
void rs485_bytes_send(
|
||||
uint8_t * buffer,
|
||||
const uint8_t * buffer,
|
||||
uint16_t nbytes);
|
||||
|
||||
uint32_t rs485_baud_rate(
|
||||
|
||||
@@ -345,7 +345,7 @@ bool Device_Object_Name(
|
||||
return status;
|
||||
}
|
||||
|
||||
bool Device_Set_Object_Name(BACNET_CHARACTER_STRING *object_name)
|
||||
bool Device_Set_Object_Name(const BACNET_CHARACTER_STRING *object_name)
|
||||
{
|
||||
bool status = false; /*return value */
|
||||
|
||||
@@ -478,7 +478,7 @@ void Device_UUID_Init(void)
|
||||
* @param new_uuid [in] The new UUID to set
|
||||
* @param length [in] The length of the new UUID
|
||||
*/
|
||||
void Device_UUID_Set(uint8_t *new_uuid, size_t length)
|
||||
void Device_UUID_Set(const uint8_t *new_uuid, size_t length)
|
||||
{
|
||||
if (new_uuid && (length == sizeof(Device_UUID))) {
|
||||
memcpy(Device_UUID, new_uuid, sizeof(Device_UUID));
|
||||
@@ -603,7 +603,7 @@ int Device_Object_List_Element_Encode(
|
||||
* Object.
|
||||
* @return True on success or else False if not found.
|
||||
*/
|
||||
bool Device_Valid_Object_Name(BACNET_CHARACTER_STRING *object_name1,
|
||||
bool Device_Valid_Object_Name(const BACNET_CHARACTER_STRING *object_name1,
|
||||
BACNET_OBJECT_TYPE *object_type,
|
||||
uint32_t *object_instance)
|
||||
{
|
||||
@@ -842,7 +842,8 @@ int Device_Read_Property_Local(BACNET_READ_PROPERTY_DATA *rpdata)
|
||||
* @return The length of the APDU on success, else BACNET_STATUS_ERROR
|
||||
*/
|
||||
static int Read_Property_Common(
|
||||
struct my_object_functions *pObject, BACNET_READ_PROPERTY_DATA *rpdata)
|
||||
const struct my_object_functions *pObject,
|
||||
BACNET_READ_PROPERTY_DATA *rpdata)
|
||||
{
|
||||
int apdu_len = BACNET_STATUS_ERROR;
|
||||
BACNET_CHARACTER_STRING char_string;
|
||||
|
||||
@@ -299,7 +299,7 @@ bool Network_Port_MAC_Address(
|
||||
* @return true if object-name was set
|
||||
*/
|
||||
bool Network_Port_MAC_Address_Set(
|
||||
uint32_t object_instance, uint8_t *mac_src, uint8_t mac_len)
|
||||
uint32_t object_instance, const uint8_t *mac_src, uint8_t mac_len)
|
||||
{
|
||||
if (mac_len == 1) {
|
||||
Object_List[0].MAC_Address[0] = mac_src[0];
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user