Fix warnings found by splint (#324)
* Fix warnings found by splint * Ignore Win32 Builder warnings about possible data loss for integers. * Fix Windows build warnings Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
This commit is contained in:
+3
-3
@@ -61,10 +61,10 @@ bin/
|
|||||||
Backup*
|
Backup*
|
||||||
BACnet_BDT_table
|
BACnet_BDT_table
|
||||||
address_cache
|
address_cache
|
||||||
/build/*
|
**/build/*
|
||||||
/_build/*
|
**/_build/*
|
||||||
CMakeLists.txt.user
|
CMakeLists.txt.user
|
||||||
/out/*
|
**/out/*
|
||||||
Obj/
|
Obj/
|
||||||
Release/
|
Release/
|
||||||
apps/piface/libmcp23s17/
|
apps/piface/libmcp23s17/
|
||||||
|
|||||||
@@ -502,6 +502,8 @@ elseif(WIN32)
|
|||||||
$<$<BOOL:${BACDL_BIP}>:ws2_32>
|
$<$<BOOL:${BACDL_BIP}>:ws2_32>
|
||||||
$<$<BOOL:${BACDL_BIP}>:iphlpapi>)
|
$<$<BOOL:${BACDL_BIP}>:iphlpapi>)
|
||||||
|
|
||||||
|
add_definitions("/W3 /D_CRT_SECURE_NO_WARNINGS /wd4244 /wd4018 /wd4267")
|
||||||
|
|
||||||
target_sources(${PROJECT_NAME} PRIVATE
|
target_sources(${PROJECT_NAME} PRIVATE
|
||||||
ports/win32/bacport.h
|
ports/win32/bacport.h
|
||||||
$<$<BOOL:${BACDL_BIP6}>:ports/win32/bip6.c>
|
$<$<BOOL:${BACDL_BIP6}>:ports/win32/bip6.c>
|
||||||
|
|||||||
@@ -235,6 +235,7 @@ int main(int argc, char *argv[])
|
|||||||
time_t timeout_seconds = 0;
|
time_t timeout_seconds = 0;
|
||||||
bool found = false;
|
bool found = false;
|
||||||
long dnet = -1;
|
long dnet = -1;
|
||||||
|
unsigned object_type = 0;
|
||||||
BACNET_MAC_ADDRESS mac = { 0 };
|
BACNET_MAC_ADDRESS mac = { 0 };
|
||||||
BACNET_MAC_ADDRESS adr = { 0 };
|
BACNET_MAC_ADDRESS adr = { 0 };
|
||||||
BACNET_ADDRESS dest = { 0 };
|
BACNET_ADDRESS dest = { 0 };
|
||||||
@@ -289,8 +290,8 @@ int main(int argc, char *argv[])
|
|||||||
target_args++;
|
target_args++;
|
||||||
} else if (target_args == 2) {
|
} else if (target_args == 2) {
|
||||||
/* event-object-type */
|
/* event-object-type */
|
||||||
if (bactext_object_type_strtol(argv[argi],
|
if (bactext_object_type_strtol(argv[argi], &object_type)) {
|
||||||
&data.eventObjectIdentifier.type)) {
|
data.eventObjectIdentifier.type = object_type;
|
||||||
target_args++;
|
target_args++;
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "event-object-type=%s invalid\n",
|
fprintf(stderr, "event-object-type=%s invalid\n",
|
||||||
@@ -305,7 +306,8 @@ int main(int argc, char *argv[])
|
|||||||
} else if (target_args == 4) {
|
} else if (target_args == 4) {
|
||||||
/* event-state-acked */
|
/* event-state-acked */
|
||||||
if (bactext_event_state_strtol(argv[argi],
|
if (bactext_event_state_strtol(argv[argi],
|
||||||
&data.eventStateAcked)) {
|
&object_type)) {
|
||||||
|
data.eventStateAcked = object_type;
|
||||||
target_args++;
|
target_args++;
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "event-state=%s invalid\n",
|
fprintf(stderr, "event-state=%s invalid\n",
|
||||||
|
|||||||
@@ -252,6 +252,8 @@ int main(int argc, char *argv[])
|
|||||||
BACNET_ADDRESS dest = { 0 };
|
BACNET_ADDRESS dest = { 0 };
|
||||||
bool specific_address = false;
|
bool specific_address = false;
|
||||||
int argi = 0;
|
int argi = 0;
|
||||||
|
unsigned object_type = 0;
|
||||||
|
unsigned object_property = 0;
|
||||||
unsigned int target_args = 0;
|
unsigned int target_args = 0;
|
||||||
char *filename = NULL;
|
char *filename = NULL;
|
||||||
|
|
||||||
@@ -296,20 +298,22 @@ int main(int argc, char *argv[])
|
|||||||
target_args++;
|
target_args++;
|
||||||
} else if (target_args == 1) {
|
} else if (target_args == 1) {
|
||||||
if (bactext_object_type_strtol(
|
if (bactext_object_type_strtol(
|
||||||
argv[argi], &Target_Object_Type) == false) {
|
argv[argi], &object_type) == false) {
|
||||||
fprintf(stderr, "object-type=%s invalid\n", argv[argi]);
|
fprintf(stderr, "object-type=%s invalid\n", argv[argi]);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
Target_Object_Type = object_type;
|
||||||
target_args++;
|
target_args++;
|
||||||
} else if (target_args == 2) {
|
} else if (target_args == 2) {
|
||||||
Target_Object_Instance = strtol(argv[argi], NULL, 0);
|
Target_Object_Instance = strtol(argv[argi], NULL, 0);
|
||||||
target_args++;
|
target_args++;
|
||||||
} else if (target_args == 3) {
|
} else if (target_args == 3) {
|
||||||
if (bactext_property_strtol(
|
if (bactext_property_strtol(
|
||||||
argv[argi], &Target_Object_Property) == false) {
|
argv[argi], &object_property) == false) {
|
||||||
fprintf(stderr, "property=%s invalid\n", argv[argi]);
|
fprintf(stderr, "property=%s invalid\n", argv[argi]);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
Target_Object_Property = object_property;
|
||||||
target_args++;
|
target_args++;
|
||||||
} else if (target_args == 4) {
|
} else if (target_args == 4) {
|
||||||
Target_Object_Index = strtol(argv[argi], NULL, 0);
|
Target_Object_Index = strtol(argv[argi], NULL, 0);
|
||||||
@@ -399,7 +403,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
if (Error_Detected) {
|
if (Error_Detected) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* wait until the device is bound, or timeout and quit */
|
/* wait until the device is bound, or timeout and quit */
|
||||||
if (!found) {
|
if (!found) {
|
||||||
found = address_bind_request(
|
found = address_bind_request(
|
||||||
@@ -441,9 +445,9 @@ int main(int argc, char *argv[])
|
|||||||
/* keep track of time for next check */
|
/* keep track of time for next check */
|
||||||
last_seconds = current_seconds;
|
last_seconds = current_seconds;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Error_Detected) {
|
if (Error_Detected) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -359,6 +359,7 @@ int main(int argc, char *argv[])
|
|||||||
int scan_count = 0;
|
int scan_count = 0;
|
||||||
int argi = 0;
|
int argi = 0;
|
||||||
long dnet = -1;
|
long dnet = -1;
|
||||||
|
unsigned object_type = 0;
|
||||||
BACNET_MAC_ADDRESS mac = { 0 };
|
BACNET_MAC_ADDRESS mac = { 0 };
|
||||||
BACNET_MAC_ADDRESS adr = { 0 };
|
BACNET_MAC_ADDRESS adr = { 0 };
|
||||||
bool specific_address = false;
|
bool specific_address = false;
|
||||||
@@ -425,12 +426,13 @@ int main(int argc, char *argv[])
|
|||||||
atexit(cleanup);
|
atexit(cleanup);
|
||||||
}
|
}
|
||||||
status = bactext_object_type_strtol(
|
status = bactext_object_type_strtol(
|
||||||
argv[argi], &rpm_object->object_type);
|
argv[argi], &object_type);
|
||||||
if (status == false) {
|
if (status == false) {
|
||||||
fprintf(stderr, "Error: object-type=%s invalid\n",
|
fprintf(stderr, "Error: object-type=%s invalid\n",
|
||||||
argv[argi]);
|
argv[argi]);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
rpm_object->object_type = object_type;
|
||||||
if (rpm_object->object_type >= MAX_BACNET_OBJECT_TYPE) {
|
if (rpm_object->object_type >= MAX_BACNET_OBJECT_TYPE) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"object-type=%u - it must be less than %u\n",
|
"object-type=%u - it must be less than %u\n",
|
||||||
|
|||||||
@@ -203,6 +203,8 @@ int main(int argc, char *argv[])
|
|||||||
int count = 0;
|
int count = 0;
|
||||||
int hour, min, sec, hundredths;
|
int hour, min, sec, hundredths;
|
||||||
int year, month, day, wday;
|
int year, month, day, wday;
|
||||||
|
unsigned object_type = 0;
|
||||||
|
unsigned object_property = 0;
|
||||||
char *filename = NULL;
|
char *filename = NULL;
|
||||||
|
|
||||||
filename = filename_remove_path(argv[0]);
|
filename = filename_remove_path(argv[0]);
|
||||||
@@ -228,15 +230,17 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
/* decode the command line parameters */
|
/* decode the command line parameters */
|
||||||
Target_Device_Object_Instance = strtol(argv[1], NULL, 0);
|
Target_Device_Object_Instance = strtol(argv[1], NULL, 0);
|
||||||
if (bactext_object_type_strtol(argv[2], &Target_Object_Type) == false) {
|
if (bactext_object_type_strtol(argv[2], &object_type) == false) {
|
||||||
fprintf(stderr, "object-type=%s invalid\n", argv[2]);
|
fprintf(stderr, "object-type=%s invalid\n", argv[2]);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
Target_Object_Type = object_type;
|
||||||
Target_Object_Instance = strtol(argv[3], NULL, 0);
|
Target_Object_Instance = strtol(argv[3], NULL, 0);
|
||||||
if (bactext_property_strtol(argv[4], &Target_Object_Property) == false) {
|
if (bactext_property_strtol(argv[4], &object_property) == false) {
|
||||||
fprintf(stderr, "property=%s invalid\n", argv[4]);
|
fprintf(stderr, "property=%s invalid\n", argv[4]);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
Target_Object_Property = object_property;
|
||||||
Target_Object_Range_Type = strtol(argv[5], NULL, 0);
|
Target_Object_Range_Type = strtol(argv[5], NULL, 0);
|
||||||
/* some bounds checking */
|
/* some bounds checking */
|
||||||
if (Target_Device_Object_Instance > BACNET_MAX_INSTANCE) {
|
if (Target_Device_Object_Instance > BACNET_MAX_INSTANCE) {
|
||||||
@@ -356,7 +360,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
if (Error_Detected) {
|
if (Error_Detected) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* wait until the device is bound, or timeout and quit */
|
/* wait until the device is bound, or timeout and quit */
|
||||||
if (!found) {
|
if (!found) {
|
||||||
found = address_bind_request(
|
found = address_bind_request(
|
||||||
@@ -396,9 +400,9 @@ int main(int argc, char *argv[])
|
|||||||
/* keep track of time for next check */
|
/* keep track of time for next check */
|
||||||
last_seconds = current_seconds;
|
last_seconds = current_seconds;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Error_Detected) {
|
if (Error_Detected) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -91,6 +91,7 @@ int main(int argc, char *argv[])
|
|||||||
struct mstimer print_value_timer = { 0 };
|
struct mstimer print_value_timer = { 0 };
|
||||||
float float_value = 0.0;
|
float float_value = 0.0;
|
||||||
bool bool_value = false;
|
bool bool_value = false;
|
||||||
|
unsigned object_type = 0;
|
||||||
uint32_t unsigned_value = 0;
|
uint32_t unsigned_value = 0;
|
||||||
/* data from the command line */
|
/* data from the command line */
|
||||||
unsigned long print_seconds = 10;
|
unsigned long print_seconds = 10;
|
||||||
@@ -132,11 +133,12 @@ int main(int argc, char *argv[])
|
|||||||
target_device_object_instance = strtol(argv[argi], NULL, 0);
|
target_device_object_instance = strtol(argv[argi], NULL, 0);
|
||||||
target_args++;
|
target_args++;
|
||||||
} else if (target_args == 1) {
|
} else if (target_args == 1) {
|
||||||
if (bactext_object_type_strtol(
|
if (bactext_object_type_strtol(argv[argi], &object_type) ==
|
||||||
argv[argi], &target_object_type) == false) {
|
false) {
|
||||||
fprintf(stderr, "object-type=%s invalid\n", argv[argi]);
|
fprintf(stderr, "object-type=%s invalid\n", argv[argi]);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
target_object_type = object_type;
|
||||||
target_args++;
|
target_args++;
|
||||||
} else if (target_args == 2) {
|
} else if (target_args == 2) {
|
||||||
target_object_instance = strtol(argv[argi], NULL, 0);
|
target_object_instance = strtol(argv[argi], NULL, 0);
|
||||||
|
|||||||
+6
-4
@@ -73,7 +73,8 @@ int main(int argc, char *argv[])
|
|||||||
BACNET_COV_DATA cov_data;
|
BACNET_COV_DATA cov_data;
|
||||||
BACNET_PROPERTY_VALUE value_list;
|
BACNET_PROPERTY_VALUE value_list;
|
||||||
uint8_t tag;
|
uint8_t tag;
|
||||||
unsigned int uint;
|
unsigned object_type = 0;
|
||||||
|
unsigned object_property = 0;
|
||||||
|
|
||||||
if (argc < 7) {
|
if (argc < 7) {
|
||||||
/* note: priority 16 and 0 should produce the same end results... */
|
/* note: priority 16 and 0 should produce the same end results... */
|
||||||
@@ -173,20 +174,21 @@ int main(int argc, char *argv[])
|
|||||||
/* decode the command line parameters */
|
/* decode the command line parameters */
|
||||||
cov_data.subscriberProcessIdentifier = strtol(argv[1], NULL, 0);
|
cov_data.subscriberProcessIdentifier = strtol(argv[1], NULL, 0);
|
||||||
cov_data.initiatingDeviceIdentifier = strtol(argv[2], NULL, 0);
|
cov_data.initiatingDeviceIdentifier = strtol(argv[2], NULL, 0);
|
||||||
if (bactext_object_type_strtol(argv[3], &uint) == false) {
|
if (bactext_object_type_strtol(argv[3], &object_type) == false) {
|
||||||
fprintf(stderr, "error: object-type=%s invalid\n", argv[3]);
|
fprintf(stderr, "error: object-type=%s invalid\n", argv[3]);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
cov_data.monitoredObjectIdentifier.type = (uint16_t)uint;
|
cov_data.monitoredObjectIdentifier.type = (uint16_t)object_type;
|
||||||
cov_data.monitoredObjectIdentifier.instance = strtol(argv[4], NULL, 0);
|
cov_data.monitoredObjectIdentifier.instance = strtol(argv[4], NULL, 0);
|
||||||
cov_data.timeRemaining = strtol(argv[5], NULL, 0);
|
cov_data.timeRemaining = strtol(argv[5], NULL, 0);
|
||||||
cov_data.listOfValues = &value_list;
|
cov_data.listOfValues = &value_list;
|
||||||
value_list.next = NULL;
|
value_list.next = NULL;
|
||||||
if (bactext_property_strtol(argv[6], &value_list.propertyIdentifier) ==
|
if (bactext_property_strtol(argv[6], &object_property) ==
|
||||||
false) {
|
false) {
|
||||||
fprintf(stderr, "property=%s invalid\n", argv[6]);
|
fprintf(stderr, "property=%s invalid\n", argv[6]);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
value_list.propertyIdentifier = object_property;
|
||||||
tag = strtol(argv[7], NULL, 0);
|
tag = strtol(argv[7], NULL, 0);
|
||||||
value_string = argv[8];
|
value_string = argv[8];
|
||||||
/* optional priority */
|
/* optional priority */
|
||||||
|
|||||||
+5
-2
@@ -135,6 +135,7 @@ int main(int argc, char *argv[])
|
|||||||
time_t current_seconds = 0;
|
time_t current_seconds = 0;
|
||||||
time_t timeout_seconds = 0;
|
time_t timeout_seconds = 0;
|
||||||
int argi = 0;
|
int argi = 0;
|
||||||
|
unsigned object_type = 0;
|
||||||
bool by_name = false;
|
bool by_name = false;
|
||||||
|
|
||||||
if (argc < 2) {
|
if (argc < 2) {
|
||||||
@@ -157,10 +158,11 @@ int main(int argc, char *argv[])
|
|||||||
} else if (argc < 4) {
|
} else if (argc < 4) {
|
||||||
/* bacwh 8 1234 */
|
/* bacwh 8 1234 */
|
||||||
Target_Object_Instance_Min = Target_Object_Instance_Max = -1;
|
Target_Object_Instance_Min = Target_Object_Instance_Max = -1;
|
||||||
if (bactext_object_type_strtol(argv[1], &Target_Object_Type) == false) {
|
if (bactext_object_type_strtol(argv[1], &object_type) == false) {
|
||||||
fprintf(stderr, "object-type=%s invalid\n", argv[1]);
|
fprintf(stderr, "object-type=%s invalid\n", argv[1]);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
Target_Object_Type = object_type;
|
||||||
Target_Object_Instance = strtol(argv[2], NULL, 0);
|
Target_Object_Instance = strtol(argv[2], NULL, 0);
|
||||||
} else if (argc < 5) {
|
} else if (argc < 5) {
|
||||||
/* bacwh 0 4194303 "name" */
|
/* bacwh 0 4194303 "name" */
|
||||||
@@ -172,10 +174,11 @@ int main(int argc, char *argv[])
|
|||||||
/* bacwh 0 4194303 8 1234 */
|
/* bacwh 0 4194303 8 1234 */
|
||||||
Target_Object_Instance_Min = strtol(argv[1], NULL, 0);
|
Target_Object_Instance_Min = strtol(argv[1], NULL, 0);
|
||||||
Target_Object_Instance_Max = strtol(argv[2], NULL, 0);
|
Target_Object_Instance_Max = strtol(argv[2], NULL, 0);
|
||||||
if (bactext_object_type_strtol(argv[3], &Target_Object_Type) == false) {
|
if (bactext_object_type_strtol(argv[3], &object_type) == false) {
|
||||||
fprintf(stderr, "object-type=%s invalid\n", argv[3]);
|
fprintf(stderr, "object-type=%s invalid\n", argv[3]);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
Target_Object_Type = object_type;
|
||||||
Target_Object_Instance = strtol(argv[4], NULL, 0);
|
Target_Object_Instance = strtol(argv[4], NULL, 0);
|
||||||
} else {
|
} else {
|
||||||
print_usage(filename_remove_path(argv[0]));
|
print_usage(filename_remove_path(argv[0]));
|
||||||
|
|||||||
@@ -239,6 +239,8 @@ int main(int argc, char *argv[])
|
|||||||
uint16_t pdu_len = 0;
|
uint16_t pdu_len = 0;
|
||||||
unsigned timeout = 100; /* milliseconds */
|
unsigned timeout = 100; /* milliseconds */
|
||||||
unsigned max_apdu = 0;
|
unsigned max_apdu = 0;
|
||||||
|
unsigned object_type = 0;
|
||||||
|
unsigned object_property = 0;
|
||||||
time_t elapsed_seconds = 0;
|
time_t elapsed_seconds = 0;
|
||||||
time_t last_seconds = 0;
|
time_t last_seconds = 0;
|
||||||
time_t current_seconds = 0;
|
time_t current_seconds = 0;
|
||||||
@@ -275,15 +277,17 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
/* decode the command line parameters */
|
/* decode the command line parameters */
|
||||||
Target_Device_Object_Instance = strtol(argv[1], NULL, 0);
|
Target_Device_Object_Instance = strtol(argv[1], NULL, 0);
|
||||||
if (bactext_object_type_strtol(argv[2], &Target_Object_Type) == false) {
|
if (bactext_object_type_strtol(argv[2], &object_type) == false) {
|
||||||
fprintf(stderr, "object-type=%s invalid\n", argv[2]);
|
fprintf(stderr, "object-type=%s invalid\n", argv[2]);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
Target_Object_Type = object_type;
|
||||||
Target_Object_Instance = strtol(argv[3], NULL, 0);
|
Target_Object_Instance = strtol(argv[3], NULL, 0);
|
||||||
if (bactext_property_strtol(argv[4], &Target_Object_Property) == false) {
|
if (bactext_property_strtol(argv[4], &object_property) == false) {
|
||||||
fprintf(stderr, "property=%s invalid\n", argv[4]);
|
fprintf(stderr, "property=%s invalid\n", argv[4]);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
Target_Object_Property = object_property;
|
||||||
Target_Object_Property_Priority = (uint8_t)strtol(argv[5], NULL, 0);
|
Target_Object_Property_Priority = (uint8_t)strtol(argv[5], NULL, 0);
|
||||||
Target_Object_Property_Index = strtol(argv[6], NULL, 0);
|
Target_Object_Property_Index = strtol(argv[6], NULL, 0);
|
||||||
if (Target_Object_Property_Index == -1) {
|
if (Target_Object_Property_Index == -1) {
|
||||||
|
|||||||
@@ -277,6 +277,7 @@ int main(int argc, char *argv[])
|
|||||||
bool status = false;
|
bool status = false;
|
||||||
BACNET_APPLICATION_TAG property_tag;
|
BACNET_APPLICATION_TAG property_tag;
|
||||||
uint8_t context_tag = 0;
|
uint8_t context_tag = 0;
|
||||||
|
unsigned object_type = 0;
|
||||||
unsigned property_id = 0;
|
unsigned property_id = 0;
|
||||||
unsigned property_array_index = 0;
|
unsigned property_array_index = 0;
|
||||||
int scan_count = 0;
|
int scan_count = 0;
|
||||||
@@ -318,12 +319,13 @@ int main(int argc, char *argv[])
|
|||||||
arg_sets = 0;
|
arg_sets = 0;
|
||||||
while (wpm_object) {
|
while (wpm_object) {
|
||||||
tag_value_arg = 2 + (arg_sets * 6);
|
tag_value_arg = 2 + (arg_sets * 6);
|
||||||
if (bactext_object_type_strtol(
|
if (bactext_object_type_strtol(argv[tag_value_arg], &object_type) ==
|
||||||
argv[tag_value_arg], &wpm_object->object_type) == false) {
|
false) {
|
||||||
fprintf(
|
fprintf(
|
||||||
stderr, "Error: object-type=%s invalid\n", argv[tag_value_arg]);
|
stderr, "Error: object-type=%s invalid\n", argv[tag_value_arg]);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
wpm_object->object_type = object_type;
|
||||||
tag_value_arg++;
|
tag_value_arg++;
|
||||||
args_remaining--;
|
args_remaining--;
|
||||||
if (Verbose) {
|
if (Verbose) {
|
||||||
|
|||||||
@@ -114,8 +114,8 @@ static void bacnet_data_object_store(int index,
|
|||||||
{
|
{
|
||||||
BACNET_DATA_OBJECT *object = NULL;
|
BACNET_DATA_OBJECT *object = NULL;
|
||||||
|
|
||||||
assert(rp_data);
|
assert(rp_data != NULL);
|
||||||
assert(value);
|
assert(value != NULL);
|
||||||
if ((index < BACNET_DATA_OBJECT_MAX) && (!value->context_specific)) {
|
if ((index < BACNET_DATA_OBJECT_MAX) && (!value->context_specific)) {
|
||||||
object = &Object_Table[index];
|
object = &Object_Table[index];
|
||||||
switch (rp_data->object_property) {
|
switch (rp_data->object_property) {
|
||||||
|
|||||||
@@ -164,6 +164,7 @@ int cl_decode_apdu(uint8_t *apdu,
|
|||||||
int dec_len = 0;
|
int dec_len = 0;
|
||||||
uint8_t tag_number = 0;
|
uint8_t tag_number = 0;
|
||||||
uint32_t len_value_type = 0;
|
uint32_t len_value_type = 0;
|
||||||
|
uint32_t enum_value = 0;
|
||||||
BACNET_UNSIGNED_INTEGER unsigned_value = 0;
|
BACNET_UNSIGNED_INTEGER unsigned_value = 0;
|
||||||
|
|
||||||
if (decode_is_context_tag(&apdu[dec_len], 0)) {
|
if (decode_is_context_tag(&apdu[dec_len], 0)) {
|
||||||
@@ -195,10 +196,11 @@ int cl_decode_apdu(uint8_t *apdu,
|
|||||||
return BACNET_STATUS_REJECT;
|
return BACNET_STATUS_REJECT;
|
||||||
}
|
}
|
||||||
len = decode_enumerated(
|
len = decode_enumerated(
|
||||||
&apdu[dec_len], len_value_type, &bcl->Property_Identifier);
|
&apdu[dec_len], len_value_type, &enum_value);
|
||||||
if (len < 0) {
|
if (len < 0) {
|
||||||
return BACNET_STATUS_REJECT;
|
return BACNET_STATUS_REJECT;
|
||||||
}
|
}
|
||||||
|
bcl->Property_Identifier = enum_value;
|
||||||
dec_len += len;
|
dec_len += len;
|
||||||
if (decode_is_context_tag(&apdu[dec_len], 3)) {
|
if (decode_is_context_tag(&apdu[dec_len], 3)) {
|
||||||
len = decode_tag_number_and_value(
|
len = decode_tag_number_and_value(
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ void color_rgb_from_xy(uint8_t *red, uint8_t *green, uint8_t *blue,
|
|||||||
float x = x_coordinate;
|
float x = x_coordinate;
|
||||||
float y = y_coordinate;
|
float y = y_coordinate;
|
||||||
float z = 1.0f - x - y;
|
float z = 1.0f - x - y;
|
||||||
float Y = brightness;
|
float Y = (float)brightness;
|
||||||
Y /= 255.0f;
|
Y /= 255.0f;
|
||||||
float X = (Y / y) * x;
|
float X = (Y / y) * x;
|
||||||
float Z = (Y / y) * z;
|
float Z = (Y / y) * z;
|
||||||
@@ -448,17 +448,17 @@ void color_rgb_from_temperature(
|
|||||||
/* Red values below 6600 K are always 255 */
|
/* Red values below 6600 K are always 255 */
|
||||||
red = 255.0;
|
red = 255.0;
|
||||||
} else {
|
} else {
|
||||||
red = temperature_kelvin - 60;
|
red = (float)(temperature_kelvin - 60);
|
||||||
red = 329.698727446 * pow(red, -0.1332047592);
|
red = 329.698727446 * pow(red, -0.1332047592);
|
||||||
red = clamp(red, 0.0, 255.0);
|
red = clamp(red, 0.0, 255.0);
|
||||||
}
|
}
|
||||||
/* Calculate Green */
|
/* Calculate Green */
|
||||||
if (temperature_kelvin <= 66) {
|
if (temperature_kelvin <= 66) {
|
||||||
/* Green values below 6600 K */
|
/* Green values below 6600 K */
|
||||||
green = temperature_kelvin;
|
green = (float)temperature_kelvin;
|
||||||
green = 99.4708025861 * log(green) - 161.1195681661;
|
green = 99.4708025861 * log(green) - 161.1195681661;
|
||||||
} else {
|
} else {
|
||||||
green = temperature_kelvin - 60;
|
green = (float)(temperature_kelvin - 60);
|
||||||
green = 288.1221695283 * pow(green, -0.0755148492);
|
green = 288.1221695283 * pow(green, -0.0755148492);
|
||||||
}
|
}
|
||||||
green = clamp(green, 0.0, 255.0);
|
green = clamp(green, 0.0, 255.0);
|
||||||
@@ -470,17 +470,17 @@ void color_rgb_from_temperature(
|
|||||||
/* Blue values below 1900 K */
|
/* Blue values below 1900 K */
|
||||||
blue = 0.0;
|
blue = 0.0;
|
||||||
} else {
|
} else {
|
||||||
blue = temperature_kelvin - 10;
|
blue = (float)(temperature_kelvin - 10);
|
||||||
blue = 138.5177312231 * log(blue) - 305.0447927307;
|
blue = 138.5177312231 * log(blue) - 305.0447927307;
|
||||||
blue = clamp(blue, 0, 255);
|
blue = clamp(blue, 0, 255);
|
||||||
}
|
}
|
||||||
if (r) {
|
if (r) {
|
||||||
*r = red;
|
*r = (uint8_t)red;
|
||||||
}
|
}
|
||||||
if (g) {
|
if (g) {
|
||||||
*g = green;
|
*g = (uint8_t)green;
|
||||||
}
|
}
|
||||||
if (b) {
|
if (b) {
|
||||||
*b = blue;
|
*b = (uint8_t)blue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-11
@@ -786,11 +786,11 @@ int event_notify_decode_service_request(
|
|||||||
if (-1 == (section_length =
|
if (-1 == (section_length =
|
||||||
decode_enumerated(&apdu[len],
|
decode_enumerated(&apdu[len],
|
||||||
len_value,
|
len_value,
|
||||||
&data->
|
&enum_value))) {
|
||||||
notificationParams.commandFailure.
|
|
||||||
commandValue.binaryValue))) {
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
data->notificationParams.commandFailure.
|
||||||
|
commandValue.binaryValue = enum_value;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BACNET_APPLICATION_TAG_UNSIGNED_INT:
|
case BACNET_APPLICATION_TAG_UNSIGNED_INT:
|
||||||
@@ -836,13 +836,12 @@ int event_notify_decode_service_request(
|
|||||||
switch (tag_number) {
|
switch (tag_number) {
|
||||||
case BACNET_APPLICATION_TAG_ENUMERATED:
|
case BACNET_APPLICATION_TAG_ENUMERATED:
|
||||||
if (-1 == (section_length =
|
if (-1 == (section_length =
|
||||||
decode_enumerated(&apdu[len],
|
decode_enumerated(&apdu[len], len_value,
|
||||||
len_value,
|
&enum_value))) {
|
||||||
&data->
|
|
||||||
notificationParams.commandFailure.
|
|
||||||
feedbackValue.binaryValue))) {
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
data->notificationParams.commandFailure.
|
||||||
|
feedbackValue.binaryValue = enum_value;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BACNET_APPLICATION_TAG_UNSIGNED_INT:
|
case BACNET_APPLICATION_TAG_UNSIGNED_INT:
|
||||||
@@ -1060,12 +1059,12 @@ int event_notify_decode_service_request(
|
|||||||
case EVENT_ACCESS_EVENT:
|
case EVENT_ACCESS_EVENT:
|
||||||
if (-1 == (section_length =
|
if (-1 == (section_length =
|
||||||
decode_context_enumerated(&apdu[len], 0,
|
decode_context_enumerated(&apdu[len], 0,
|
||||||
&data->notificationParams.
|
&enum_value))) {
|
||||||
accessEvent.accessEvent))) {
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
data->notificationParams.accessEvent.accessEvent =
|
||||||
|
enum_value;
|
||||||
len += section_length;
|
len += section_length;
|
||||||
|
|
||||||
if (-1 == (section_length =
|
if (-1 == (section_length =
|
||||||
decode_context_bitstring(&apdu[len], 1,
|
decode_context_bitstring(&apdu[len], 1,
|
||||||
&data->notificationParams.
|
&data->notificationParams.
|
||||||
|
|||||||
Reference in New Issue
Block a user