make pretty

This commit is contained in:
Steve Karg
2022-09-10 10:32:50 -05:00
parent 7cdab61d72
commit cc4911a185
123 changed files with 1387 additions and 1604 deletions
+26 -32
View File
@@ -153,8 +153,7 @@ static void Init_Service_Handlers(void)
apdu_set_confirmed_simple_ack_handler(
SERVICE_CONFIRMED_ACKNOWLEDGE_ALARM, MyWritePropertySimpleAckHandler);
/* handle any errors coming back */
apdu_set_error_handler(
SERVICE_CONFIRMED_ACKNOWLEDGE_ALARM, MyErrorHandler);
apdu_set_error_handler(SERVICE_CONFIRMED_ACKNOWLEDGE_ALARM, MyErrorHandler);
apdu_set_abort_handler(MyAbortHandler);
apdu_set_reject_handler(MyRejectHandler);
}
@@ -203,23 +202,23 @@ static void print_help(char *filename)
"The time-stamp of the alarm acknowledge.\n"
"\n");
printf("--mac A\n"
"Optional BACnet mac address."
"Valid ranges are from 00 to FF (hex) for MS/TP or ARCNET,\n"
"or an IP string with optional port number like 10.1.2.3:47808\n"
"or an Ethernet MAC in hex like 00:21:70:7e:32:bb\n"
"\n"
"--dnet N\n"
"Optional BACnet network number N for directed requests.\n"
"Valid range is from 0 to 65535 where 0 is the local connection\n"
"and 65535 is network broadcast.\n"
"\n"
"--dadr A\n"
"Optional BACnet mac address on the destination BACnet network "
"number.\n"
"Valid ranges are from 00 to FF (hex) for MS/TP or ARCNET,\n"
"or an IP string with optional port number like 10.1.2.3:47808\n"
"or an Ethernet MAC in hex like 00:21:70:7e:32:bb\n"
"\n");
"Optional BACnet mac address."
"Valid ranges are from 00 to FF (hex) for MS/TP or ARCNET,\n"
"or an IP string with optional port number like 10.1.2.3:47808\n"
"or an Ethernet MAC in hex like 00:21:70:7e:32:bb\n"
"\n"
"--dnet N\n"
"Optional BACnet network number N for directed requests.\n"
"Valid range is from 0 to 65535 where 0 is the local connection\n"
"and 65535 is network broadcast.\n"
"\n"
"--dadr A\n"
"Optional BACnet mac address on the destination BACnet network "
"number.\n"
"Valid ranges are from 00 to FF (hex) for MS/TP or ARCNET,\n"
"or an IP string with optional port number like 10.1.2.3:47808\n"
"or an Ethernet MAC in hex like 00:21:70:7e:32:bb\n"
"\n");
}
int main(int argc, char *argv[])
@@ -294,8 +293,8 @@ int main(int argc, char *argv[])
data.eventObjectIdentifier.type = object_type;
target_args++;
} else {
fprintf(stderr, "event-object-type=%s invalid\n",
argv[argi]);
fprintf(
stderr, "event-object-type=%s invalid\n", argv[argi]);
return 1;
}
} else if (target_args == 3) {
@@ -305,13 +304,11 @@ int main(int argc, char *argv[])
target_args++;
} else if (target_args == 4) {
/* event-state-acked */
if (bactext_event_state_strtol(argv[argi],
&object_type)) {
if (bactext_event_state_strtol(argv[argi], &object_type)) {
data.eventStateAcked = object_type;
target_args++;
} else {
fprintf(stderr, "event-state=%s invalid\n",
argv[argi]);
fprintf(stderr, "event-state=%s invalid\n", argv[argi]);
return 1;
}
} else if (target_args == 5) {
@@ -397,7 +394,7 @@ int main(int argc, char *argv[])
}
if (Error_Detected) {
break;
}
}
/* wait until the device is bound, or timeout and quit */
if (!found) {
found = address_bind_request(
@@ -405,12 +402,9 @@ int main(int argc, char *argv[])
}
if (found) {
if (Request_Invoke_ID == 0) {
Request_Invoke_ID =
Send_Alarm_Acknowledgement_Address(
Handler_Transmit_Buffer,
sizeof(Handler_Transmit_Buffer),
&data,
&Target_Address);
Request_Invoke_ID = Send_Alarm_Acknowledgement_Address(
Handler_Transmit_Buffer, sizeof(Handler_Transmit_Buffer),
&data, &Target_Address);
} else if (tsm_invoke_id_free(Request_Invoke_ID)) {
break;
} else if (tsm_invoke_id_failed(Request_Invoke_ID)) {
+1 -1
View File
@@ -248,7 +248,7 @@ int main(int argc, char *argv[])
}
if (Error_Detected) {
break;
}
}
/* wait until the device is bound, or timeout and quit */
if (!found) {
found = address_bind_request(
+30 -30
View File
@@ -220,7 +220,7 @@ static void MyAbortHandler(
(ERROR_CODE_ABORT_BUFFER_OVERFLOW - 1) + abort_reason;
} else {
Last_Error_Code = ERROR_CODE_ABORT_OTHER;
}
}
}
}
@@ -242,7 +242,7 @@ static void MyRejectHandler(
(ERROR_CODE_REJECT_BUFFER_OVERFLOW - 1) + reject_reason;
} else {
Last_Error_Code = ERROR_CODE_REJECT_OTHER;
}
}
}
}
@@ -269,7 +269,7 @@ static void MyReadPropertyAckHandler(uint8_t *service_request,
} else {
if (len < 0) { /* Eg, failed due to no segmentation */
Error_Detected = true;
}
}
free(rp_data);
}
}
@@ -428,7 +428,7 @@ static void CheckIsWritableProperty(BACNET_OBJECT_TYPE object_type,
*/
if (bIsWritable) {
fprintf(stdout, " Writable");
}
}
}
static const char *protocol_services_supported_text(size_t bit_index)
@@ -506,7 +506,7 @@ static bool PrettyPrintPropertyValue(
}
} else { /* not supported */
fprintf(stream, ",");
}
}
}
fprintf(stream, "\n ");
}
@@ -527,7 +527,7 @@ static bool PrettyPrintPropertyValue(
status = bacapp_print_value(stdout, object_value);
} else {
fprintf(stream, "? \n");
}
}
return status;
}
@@ -586,7 +586,7 @@ static void PrintReadPropertyData(BACNET_OBJECT_TYPE object_type,
}
if (object_type == OBJECT_DATETIME_VALUE) {
break; /* A special case - no braces for this pair */
}
}
/* Else, fall through to normal processing. */
default:
/* Normal array: open brace */
@@ -598,7 +598,7 @@ static void PrintReadPropertyData(BACNET_OBJECT_TYPE object_type,
if (!Using_Walked_List) {
Walked_List_Index = Walked_List_Length = 0; /* In case we need this. */
}
}
/* value(s) loop until there is no "next" ... */
while (value != NULL) {
object_value.object_property = rpm_property->propertyIdentifier;
@@ -620,12 +620,12 @@ static void PrintReadPropertyData(BACNET_OBJECT_TYPE object_type,
if (rpm_property->propertyIdentifier ==
PROP_OBJECT_LIST) {
Object_List_Length = value->type.Unsigned_Int;
}
}
break;
} else {
assert(Walked_List_Index ==
(uint32_t)rpm_property->propertyArrayIndex);
}
}
} else {
Walked_List_Index++;
/* If we got the whole Object List array in one RP call,
@@ -633,7 +633,7 @@ static void PrintReadPropertyData(BACNET_OBJECT_TYPE object_type,
* through. */
if (rpm_property->propertyIdentifier == PROP_OBJECT_LIST) {
Object_List_Length = ++Object_List_Index;
}
}
}
if (Walked_List_Index == 1) {
/* If the array is empty (nothing for this first entry),
@@ -651,7 +651,7 @@ static void PrintReadPropertyData(BACNET_OBJECT_TYPE object_type,
fprintf(stdout, "{ \n ");
} else {
fprintf(stdout, "\n ");
}
}
}
if (rpm_property->propertyIdentifier == PROP_OBJECT_LIST) {
@@ -701,11 +701,11 @@ static void PrintReadPropertyData(BACNET_OBJECT_TYPE object_type,
* braces */
if (isSequence) {
fprintf(stdout, "{");
}
}
bacapp_print_value(stdout, &object_value);
if (isSequence) {
fprintf(stdout, "}");
}
}
if ((Walked_List_Index < Walked_List_Length) ||
(value->next != NULL)) {
@@ -713,7 +713,7 @@ static void PrintReadPropertyData(BACNET_OBJECT_TYPE object_type,
fprintf(stdout, ", ");
if (!(Walked_List_Index % 3)) {
fprintf(stdout, "\n ");
}
}
} else {
fprintf(stdout, " } \n");
}
@@ -1091,10 +1091,10 @@ static int CheckCommandLineArgs(int argc, char *argv[])
if (Target_Address.mac_len == 0) {
fprintf(
stderr, "Must provide a Target MAC before DNET \n");
}
}
if (++i < argc) {
Target_Address.net = (uint16_t)strtol(argv[i], NULL, 0);
}
}
/* Used strtol so dest.net can be either 0x1234 or 4660 */
break;
case 't':
@@ -1231,7 +1231,7 @@ static void PrintHeading(void)
for (i = 0; i < len; i++) {
if (bitstring_bit(&value->type.Bit_String, (uint8_t)i)) {
printf(" %s\n", protocol_services_supported_text(i));
}
}
}
} else {
printf("-- use \'Initiate\' or \'Execute\' or both for services.\n");
@@ -1279,7 +1279,7 @@ static void PrintHeading(void)
for (i = 0; i < len; i++) {
if (bitstring_bit(&value->type.Bit_String, (uint8_t)i)) {
printf(" %s\n", bactext_object_type_name(i));
}
}
}
} else {
printf("-- possible objects in this device\n");
@@ -1501,7 +1501,7 @@ int main(int argc, char *argv[])
/* Update by adding the MAC address */
if (max_apdu == 0) {
max_apdu = MAX_APDU; /* Whatever set for this datalink. */
}
}
address_add_binding(
Target_Device_Object_Instance, max_apdu, &Target_Address);
}
@@ -1598,7 +1598,7 @@ int main(int argc, char *argv[])
myState = GET_LIST_OF_ALL_RESPONSE;
} else {
myState = GET_ALL_RESPONSE;
}
}
}
break;
@@ -1631,7 +1631,7 @@ int main(int argc, char *argv[])
Request_Invoke_ID = 0;
if (myState == GET_HEADING_RESPONSE) {
myState = PRINT_HEADING;
/* just press ahead without the data */
/* just press ahead without the data */
} else if (Error_Detected) {
if (Last_Error_Code ==
ERROR_CODE_REJECT_UNRECOGNIZED_SERVICE) {
@@ -1655,7 +1655,7 @@ int main(int argc, char *argv[])
myState = GET_ALL_REQUEST; /* Let's try again */
} else {
myState = GET_PROPERTY_REQUEST;
}
}
} else if (tsm_invoke_id_failed(Request_Invoke_ID)) {
fprintf(stderr, "\rError: TSM Timeout!\n");
tsm_free_invoke_id(Request_Invoke_ID);
@@ -1663,21 +1663,21 @@ int main(int argc, char *argv[])
elapsed_seconds = 0;
if (myState == GET_HEADING_RESPONSE) {
myState = PRINT_HEADING;
/* just press ahead without the data */
/* just press ahead without the data */
} else {
myState = GET_ALL_REQUEST; /* Let's try again */
}
}
} else if (Error_Detected) {
/* Don't think we'll ever actually reach this point. */
elapsed_seconds = 0;
Request_Invoke_ID = 0;
if (myState == GET_HEADING_RESPONSE) {
myState = PRINT_HEADING;
/* just press ahead without the data */
/* just press ahead without the data */
} else {
myState = NEXT_OBJECT;
}/* Give up and move on to the
next. */
} /* Give up and move on to the
next. */
Error_Count++;
}
break;
@@ -1696,7 +1696,7 @@ int main(int argc, char *argv[])
myState = NEXT_OBJECT; /* Move on to the next. */
} else {
myState = GET_PROPERTY_RESPONSE;
}
}
break;
case GET_PROPERTY_RESPONSE:
@@ -1813,7 +1813,7 @@ int main(int argc, char *argv[])
/* Don't re-list the Device Object among its objects */
if (myObject.type == OBJECT_DEVICE) {
continue;
}
}
/* Closing brace for the previous Object */
printf(" }, \n");
/* Opening brace for the new Object */
+33 -30
View File
@@ -224,23 +224,23 @@ static void print_help(char *filename)
"The event-type of the event.\n"
"\n");
printf("--mac A\n"
"Optional BACnet mac address."
"Valid ranges are from 00 to FF (hex) for MS/TP or ARCNET,\n"
"or an IP string with optional port number like 10.1.2.3:47808\n"
"or an Ethernet MAC in hex like 00:21:70:7e:32:bb\n"
"\n"
"--dnet N\n"
"Optional BACnet network number N for directed requests.\n"
"Valid range is from 0 to 65535 where 0 is the local connection\n"
"and 65535 is network broadcast.\n"
"\n"
"--dadr A\n"
"Optional BACnet mac address on the destination BACnet network "
"number.\n"
"Valid ranges are from 00 to FF (hex) for MS/TP or ARCNET,\n"
"or an IP string with optional port number like 10.1.2.3:47808\n"
"or an Ethernet MAC in hex like 00:21:70:7e:32:bb\n"
"\n");
"Optional BACnet mac address."
"Valid ranges are from 00 to FF (hex) for MS/TP or ARCNET,\n"
"or an IP string with optional port number like 10.1.2.3:47808\n"
"or an Ethernet MAC in hex like 00:21:70:7e:32:bb\n"
"\n"
"--dnet N\n"
"Optional BACnet network number N for directed requests.\n"
"Valid range is from 0 to 65535 where 0 is the local connection\n"
"and 65535 is network broadcast.\n"
"\n"
"--dadr A\n"
"Optional BACnet mac address on the destination BACnet network "
"number.\n"
"Valid ranges are from 00 to FF (hex) for MS/TP or ARCNET,\n"
"or an IP string with optional port number like 10.1.2.3:47808\n"
"or an Ethernet MAC in hex like 00:21:70:7e:32:bb\n"
"\n");
}
int main(int argc, char *argv[])
@@ -481,7 +481,8 @@ int main(int argc, char *argv[])
/* FIXME: add event type parameters */
} else if (event_data.eventType == EVENT_OUT_OF_RANGE) {
/* FIXME: add event type parameters */
} else if (event_data.eventType == EVENT_CHANGE_OF_LIFE_SAFETY) {
} else if (event_data.eventType ==
EVENT_CHANGE_OF_LIFE_SAFETY) {
/* FIXME: add event type parameters */
} else if (event_data.eventType == EVENT_EXTENDED) {
/* FIXME: add event type parameters */
@@ -495,17 +496,22 @@ int main(int argc, char *argv[])
/* FIXME: add event type parameters */
} else if (event_data.eventType == EVENT_SIGNED_OUT_OF_RANGE) {
/* FIXME: add event type parameters */
} else if (event_data.eventType == EVENT_UNSIGNED_OUT_OF_RANGE) {
} else if (event_data.eventType ==
EVENT_UNSIGNED_OUT_OF_RANGE) {
/* FIXME: add event type parameters */
} else if (event_data.eventType == EVENT_CHANGE_OF_CHARACTERSTRING) {
} else if (event_data.eventType ==
EVENT_CHANGE_OF_CHARACTERSTRING) {
/* FIXME: add event type parameters */
} else if (event_data.eventType == EVENT_CHANGE_OF_STATUS_FLAGS) {
} else if (event_data.eventType ==
EVENT_CHANGE_OF_STATUS_FLAGS) {
/* FIXME: add event type parameters */
} else if (event_data.eventType == EVENT_CHANGE_OF_RELIABILITY) {
} else if (event_data.eventType ==
EVENT_CHANGE_OF_RELIABILITY) {
/* FIXME: add event type parameters */
} else if (event_data.eventType == EVENT_NONE) {
/* FIXME: add event type parameters */
} else if (event_data.eventType == EVENT_CHANGE_OF_DISCRETE_VALUE) {
} else if (event_data.eventType ==
EVENT_CHANGE_OF_DISCRETE_VALUE) {
/* FIXME: add event type parameters */
} else if (event_data.eventType == EVENT_CHANGE_OF_TIMER) {
/* FIXME: add event type parameters */
@@ -587,7 +593,7 @@ int main(int argc, char *argv[])
}
if (Error_Detected) {
break;
}
}
/* wait until the device is bound, or timeout and quit */
if (!found) {
found = address_bind_request(
@@ -595,12 +601,9 @@ int main(int argc, char *argv[])
}
if (found) {
if (Request_Invoke_ID == 0) {
Request_Invoke_ID =
Send_CEvent_Notify_Address(
Handler_Transmit_Buffer,
sizeof(Handler_Transmit_Buffer),
&event_data,
&Target_Address);
Request_Invoke_ID = Send_CEvent_Notify_Address(
Handler_Transmit_Buffer, sizeof(Handler_Transmit_Buffer),
&event_data, &Target_Address);
} else if (tsm_invoke_id_free(Request_Invoke_ID)) {
break;
} else if (tsm_invoke_id_failed(Request_Invoke_ID)) {
+1 -1
View File
@@ -122,7 +122,7 @@ static void Initialize_Device_Addresses(void)
{
int i = 0; /* First entry is Gateway Device */
uint32_t virtual_mac = 0;
BACNET_ADDRESS virtual_address = {0};
BACNET_ADDRESS virtual_address = { 0 };
DEVICE_OBJECT_DATA *pDev = NULL;
/* Setup info for the main gateway device first */
pDev = Get_Routed_Device_Object(i);
+3 -3
View File
@@ -127,7 +127,7 @@ static void My_Get_Event_Ack_Handler(uint8_t *service_request,
BACNET_GET_EVENT_INFORMATION_DATA data[MAX_OBJ_IDS_IN_GE_ACK];
for (i = 0; i < MAX_OBJ_IDS_IN_GE_ACK - 1; i++) {
data[i].next = &data[i + 1];
}
}
printf("Recieved Ack. Saved invoke ID was %i, service returned %i\n",
Request_Invoke_ID, service_data->invoke_id);
@@ -143,7 +143,7 @@ static void My_Get_Event_Ack_Handler(uint8_t *service_request,
BACNET_GET_EVENT_INFORMATION_DATA *lastData = &(data[0]);
while (lastData->next) {
lastData = lastData->next;
}
}
LastReceivedObjectIdentifier = lastData->objectIdentifier;
}
}
@@ -287,6 +287,6 @@ int main(int argc, char *argv[])
}
if (Error_Detected) {
return 1;
}
}
return 0;
}
+1 -1
View File
@@ -365,7 +365,7 @@ int main(int argc, char *argv[])
}
if (Error_Detected) {
break;
}
}
/* increment timer - exit if timed out */
elapsed_seconds = current_seconds - last_seconds;
if (elapsed_seconds) {
+3 -3
View File
@@ -538,9 +538,9 @@ static void filename_create(char *filename)
if (filename) {
datetime_local(&bdate, &btime, NULL, NULL);
sprintf(filename, "mstp_%04d%02d%02d%02d%02d%02d.cap",
(int)bdate.year, (int)bdate.month, (int)bdate.day,
(int)btime.hour, (int)btime.min, (int)btime.sec);
sprintf(filename, "mstp_%04d%02d%02d%02d%02d%02d.cap", (int)bdate.year,
(int)bdate.month, (int)bdate.day, (int)btime.hour, (int)btime.min,
(int)btime.sec);
}
}
+6 -6
View File
@@ -119,8 +119,8 @@ static void My_Router_Handler(BACNET_ADDRESS *src,
that are sent with a local unicast address. */
if (npdu_len >= 2) {
len += decode_unsigned16(npdu, &dnet);
printf(": network number = %u. SNET=%u\n",
(unsigned)dnet, (unsigned)src->net);
printf(": network number = %u. SNET=%u\n", (unsigned)dnet,
(unsigned)src->net);
} else {
printf(": network number = missing! SNET=%u\n", src->net);
}
@@ -251,7 +251,8 @@ int main(int argc, char *argv[])
time_t timeout_seconds = 0;
if (argc < 3) {
printf("Usage: %s DNET status [MAC]\r\n", filename_remove_path(argv[0]));
printf(
"Usage: %s DNET status [MAC]\r\n", filename_remove_path(argv[0]));
return 0;
}
if ((argc > 1) && (strcmp(argv[1], "--help") == 0)) {
@@ -307,8 +308,7 @@ int main(int argc, char *argv[])
last_seconds = time(NULL);
timeout_seconds = apdu_timeout() / 1000;
/* send the request */
Send_Network_Number_Is(
&Target_Router_Address, Target_Network_Number,
Send_Network_Number_Is(&Target_Router_Address, Target_Network_Number,
Target_Network_Number_Status);
/* loop forever */
for (;;) {
@@ -322,7 +322,7 @@ int main(int argc, char *argv[])
}
if (Error_Detected) {
break;
}
}
/* increment timer - exit if timed out */
elapsed_seconds = current_seconds - last_seconds;
if (elapsed_seconds) {
+29 -27
View File
@@ -378,7 +378,7 @@ bool Device_Set_Object_Instance_Number(uint32_t object_id)
Device_Inc_Database_Revision();
} else {
status = false;
}
}
return status;
}
@@ -984,10 +984,12 @@ int Device_Read_Property_Local(BACNET_READ_PROPERTY_DATA *rpdata)
/* Array element zero is the number of objects in the list */
if (rpdata->array_index == 0) {
apdu_len = encode_application_unsigned(&apdu[0], count);
/* if no index was specified, then try to encode the entire list */
/* into one packet. Note that more than likely you will have */
/* to return an error if the number of encoded objects exceeds */
/* your maximum APDU size. */
/* if no index was specified, then try to encode the entire list
*/
/* into one packet. Note that more than likely you will have */
/* to return an error if the number of encoded objects exceeds
*/
/* your maximum APDU size. */
} else if (rpdata->array_index == BACNET_ARRAY_ALL) {
for (i = 1; i <= count; i++) {
found = Device_Object_List_Identifier(
@@ -1135,8 +1137,8 @@ bool Device_Write_Property_Local(BACNET_WRITE_PROPERTY_DATA *wp_data)
/* FIXME: len < application_data_len: more data? */
switch (wp_data->object_property) {
case PROP_OBJECT_IDENTIFIER:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_OBJECT_ID);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_OBJECT_ID);
if (status) {
if ((value.type.Object_Id.type == OBJECT_DEVICE) &&
(Device_Set_Object_Instance_Number(
@@ -1151,32 +1153,32 @@ bool Device_Write_Property_Local(BACNET_WRITE_PROPERTY_DATA *wp_data)
}
break;
case PROP_NUMBER_OF_APDU_RETRIES:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_UNSIGNED_INT);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
if (status) {
/* FIXME: bounds check? */
apdu_retries_set((uint8_t)value.type.Unsigned_Int);
}
break;
case PROP_APDU_TIMEOUT:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_UNSIGNED_INT);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
if (status) {
/* FIXME: bounds check? */
apdu_timeout_set((uint16_t)value.type.Unsigned_Int);
}
break;
case PROP_VENDOR_IDENTIFIER:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_UNSIGNED_INT);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
if (status) {
/* FIXME: bounds check? */
Device_Set_Vendor_Identifier((uint16_t)value.type.Unsigned_Int);
}
break;
case PROP_SYSTEM_STATUS:
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_ENUMERATED);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_ENUMERATED);
if (status) {
temp = Device_Set_System_Status(
(BACNET_DEVICE_STATUS)value.type.Enumerated, false);
@@ -1193,8 +1195,8 @@ bool Device_Write_Property_Local(BACNET_WRITE_PROPERTY_DATA *wp_data)
}
break;
case PROP_OBJECT_NAME:
status = write_property_string_valid(wp_data, &value,
characterstring_capacity(&My_Object_Name));
status = write_property_string_valid(
wp_data, &value, characterstring_capacity(&My_Object_Name));
if (status) {
/* All the object names in a device must be unique */
if (Device_Valid_Object_Name(&value.type.Character_String,
@@ -1214,8 +1216,8 @@ bool Device_Write_Property_Local(BACNET_WRITE_PROPERTY_DATA *wp_data)
}
break;
case PROP_LOCATION:
status = write_property_empty_string_valid(wp_data, &value,
MAX_DEV_LOC_LEN);
status = write_property_empty_string_valid(
wp_data, &value, MAX_DEV_LOC_LEN);
if (status) {
Device_Set_Location(
characterstring_value(&value.type.Character_String),
@@ -1224,8 +1226,8 @@ bool Device_Write_Property_Local(BACNET_WRITE_PROPERTY_DATA *wp_data)
break;
case PROP_DESCRIPTION:
status = write_property_empty_string_valid(wp_data, &value,
MAX_DEV_DESC_LEN);
status = write_property_empty_string_valid(
wp_data, &value, MAX_DEV_DESC_LEN);
if (status) {
Device_Set_Description(
characterstring_value(&value.type.Character_String),
@@ -1233,8 +1235,8 @@ bool Device_Write_Property_Local(BACNET_WRITE_PROPERTY_DATA *wp_data)
}
break;
case PROP_MODEL_NAME:
status = write_property_empty_string_valid(wp_data, &value,
MAX_DEV_MOD_LEN);
status = write_property_empty_string_valid(
wp_data, &value, MAX_DEV_MOD_LEN);
if (status) {
Device_Set_Model_Name(
characterstring_value(&value.type.Character_String),
@@ -1244,8 +1246,8 @@ bool Device_Write_Property_Local(BACNET_WRITE_PROPERTY_DATA *wp_data)
case PROP_MAX_INFO_FRAMES:
#if defined(BACDL_MSTP)
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_UNSIGNED_INT);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
if (status) {
if (value.type.Unsigned_Int <= 255) {
dlmstp_set_max_info_frames(
@@ -1260,8 +1262,8 @@ bool Device_Write_Property_Local(BACNET_WRITE_PROPERTY_DATA *wp_data)
#endif
case PROP_MAX_MASTER:
#if defined(BACDL_MSTP)
status = write_property_type_valid(wp_data, &value,
BACNET_APPLICATION_TAG_UNSIGNED_INT);
status = write_property_type_valid(
wp_data, &value, BACNET_APPLICATION_TAG_UNSIGNED_INT);
if (status) {
if ((value.type.Unsigned_Int > 0) &&
(value.type.Unsigned_Int <= 127)) {
+4 -4
View File
@@ -62,7 +62,7 @@ static void DecodeBlock(char cBlockNum, uint8_t *pData)
iLen += tag_len;
if (tag_number != BACNET_APPLICATION_TAG_UNSIGNED_INT) {
return;
}
}
iLen += decode_unsigned(&pData[iLen], len_value_type, &ulTemp);
Response.cMyByte1 = (char)ulTemp;
@@ -72,7 +72,7 @@ static void DecodeBlock(char cBlockNum, uint8_t *pData)
iLen += tag_len;
if (tag_number != BACNET_APPLICATION_TAG_UNSIGNED_INT) {
return;
}
}
iLen += decode_unsigned(&pData[iLen], len_value_type, &ulTemp);
Response.cMyByte2 = (char)ulTemp;
@@ -82,7 +82,7 @@ static void DecodeBlock(char cBlockNum, uint8_t *pData)
iLen += tag_len;
if (tag_number != BACNET_APPLICATION_TAG_REAL) {
return;
}
}
iLen += decode_real(&pData[iLen], &Response.fMyReal);
@@ -91,7 +91,7 @@ static void DecodeBlock(char cBlockNum, uint8_t *pData)
iLen += tag_len;
if (tag_number != BACNET_APPLICATION_TAG_CHARACTER_STRING) {
return;
}
}
iLen += decode_character_string(&pData[iLen], len_value_type, &bsName);
strncpy(
+10 -11
View File
@@ -100,12 +100,11 @@ static void MyErrorHandler(BACNET_ADDRESS *src,
}
/* complex error reply function */
static void MyPrivateTransferErrorHandler(
BACNET_ADDRESS * src,
uint8_t invoke_id,
uint8_t service_choice,
uint8_t * service_request,
uint16_t service_len)
static void MyPrivateTransferErrorHandler(BACNET_ADDRESS *src,
uint8_t invoke_id,
uint8_t service_choice,
uint8_t *service_request,
uint16_t service_len)
{
(void)src;
(void)invoke_id;
@@ -163,8 +162,8 @@ static void Init_Service_Handlers(void)
/* handle any errors coming back */
apdu_set_error_handler(SERVICE_CONFIRMED_READ_PROPERTY, MyErrorHandler);
apdu_set_complex_error_handler(SERVICE_CONFIRMED_PRIVATE_TRANSFER,
MyPrivateTransferErrorHandler);
apdu_set_complex_error_handler(
SERVICE_CONFIRMED_PRIVATE_TRANSFER, MyPrivateTransferErrorHandler);
apdu_set_abort_handler(MyAbortHandler);
apdu_set_reject_handler(MyRejectHandler);
}
@@ -317,12 +316,12 @@ int main(int argc, char *argv[])
}
if (Error_Detected) {
break;
}
}
/* wait until the device is bound, or timeout and quit */
if (!found) {
found = address_bind_request(
Target_Device_Object_Instance, &max_apdu, &Target_Address);
}
}
if (found) {
if (invoke_id == 0) { /* Safe to send a new request */
switch (iType) {
@@ -414,6 +413,6 @@ int main(int argc, char *argv[])
}
if (Error_Detected) {
return 1;
}
}
return 0;
}
+1 -1
View File
@@ -72,7 +72,7 @@ uint8_t Send_Private_Transfer_Request(uint32_t device_id,
/* is there a tsm available? */
if (status) {
invoke_id = tsm_next_free_invokeID();
}
}
if (invoke_id) {
/* encode the NPDU portion of the packet */
datalink_get_my_address(&my_address);
+1 -1
View File
@@ -173,7 +173,7 @@ int main(int argc, char *argv[])
}
if (Error_Detected) {
break;
}
}
/* increment timer - exit if timed out */
elapsed_seconds = current_seconds - last_seconds;
if (elapsed_seconds) {
+1 -1
View File
@@ -172,7 +172,7 @@ int main(int argc, char *argv[])
}
if (Error_Detected) {
break;
}
}
/* increment timer - exit if timed out */
elapsed_seconds = current_seconds - last_seconds;
if (elapsed_seconds) {
+4 -4
View File
@@ -134,8 +134,8 @@ static void AtomicReadFileAckHandler(uint8_t *service_request,
data.endOfFile = true;
}
} else {
result = fseek(pFile, data.type.stream.fileStartPosition,
SEEK_SET);
result = fseek(
pFile, data.type.stream.fileStartPosition, SEEK_SET);
if (result == 0) {
/* unit to write in bytes -
in our case, an octet is one byte */
@@ -150,8 +150,8 @@ static void AtomicReadFileAckHandler(uint8_t *service_request,
Target_File_Start_Position =
data.type.stream.fileStartPosition +
octets_written;
printf("\r%d bytes",
(int)Target_File_Start_Position);
printf(
"\r%d bytes", (int)Target_File_Start_Position);
}
fflush(pFile);
} else {
+4 -4
View File
@@ -297,8 +297,8 @@ int main(int argc, char *argv[])
Target_Device_Object_Instance = strtol(argv[argi], NULL, 0);
target_args++;
} else if (target_args == 1) {
if (bactext_object_type_strtol(
argv[argi], &object_type) == false) {
if (bactext_object_type_strtol(argv[argi], &object_type) ==
false) {
fprintf(stderr, "object-type=%s invalid\n", argv[argi]);
return 1;
}
@@ -308,8 +308,8 @@ int main(int argc, char *argv[])
Target_Object_Instance = strtol(argv[argi], NULL, 0);
target_args++;
} else if (target_args == 3) {
if (bactext_property_strtol(
argv[argi], &object_property) == false) {
if (bactext_property_strtol(argv[argi], &object_property) ==
false) {
fprintf(stderr, "property=%s invalid\n", argv[argi]);
return 1;
}
+13 -17
View File
@@ -143,7 +143,6 @@ static void My_Read_Property_Multiple_Ack_Handler(uint8_t *service_request,
while (rpm_data) {
rpm_ack_print_data(rpm_data);
rpm_data = rpm_data_free(rpm_data);
}
} else {
fprintf(stderr, "RPM Ack Malformed! Freeing memory...\n");
@@ -214,9 +213,7 @@ static void cleanup(void)
}
static void target_address_add(
long dnet,
BACNET_MAC_ADDRESS *mac,
BACNET_MAC_ADDRESS *adr)
long dnet, BACNET_MAC_ADDRESS *mac, BACNET_MAC_ADDRESS *adr)
{
BACNET_ADDRESS dest = { 0 };
@@ -416,17 +413,17 @@ int main(int argc, char *argv[])
} else if (target_args >= 1) {
if (tag_value_arg == 0) {
if (rpm_object) {
rpm_object->next = calloc(1,
sizeof(BACNET_READ_ACCESS_DATA));
rpm_object->next =
calloc(1, sizeof(BACNET_READ_ACCESS_DATA));
rpm_object = rpm_object->next;
} else {
Read_Access_Data = calloc(1,
sizeof(BACNET_READ_ACCESS_DATA));
Read_Access_Data =
calloc(1, sizeof(BACNET_READ_ACCESS_DATA));
rpm_object = Read_Access_Data;
atexit(cleanup);
}
status = bactext_object_type_strtol(
argv[argi], &object_type);
status =
bactext_object_type_strtol(argv[argi], &object_type);
if (status == false) {
fprintf(stderr, "Error: object-type=%s invalid\n",
argv[argi]);
@@ -445,7 +442,8 @@ int main(int argc, char *argv[])
if (rpm_object->object_instance > BACNET_MAX_INSTANCE) {
fprintf(stderr,
"object-instance=%u - it must be less than %u\n",
rpm_object->object_instance, BACNET_MAX_INSTANCE + 1);
rpm_object->object_instance,
BACNET_MAX_INSTANCE + 1);
return 1;
}
tag_value_arg++;
@@ -455,9 +453,8 @@ int main(int argc, char *argv[])
property_token = strtok(argv[argi], ",");
/* add all the properties and optional index to our list */
while (rpm_property) {
scan_count = sscanf(
property_token, "%u[%u]", &property_id,
&property_array_index);
scan_count = sscanf(property_token, "%u[%u]",
&property_id, &property_array_index);
if (scan_count > 0) {
rpm_property->propertyIdentifier = property_id;
if (rpm_property->propertyIdentifier >
@@ -489,7 +486,6 @@ int main(int argc, char *argv[])
/* start over with the next arg set */
tag_value_arg = 0;
}
}
}
}
@@ -538,7 +534,7 @@ int main(int argc, char *argv[])
}
if (Error_Detected) {
break;
}
}
/* wait until the device is bound, or timeout and quit */
if (!found) {
found = address_bind_request(
@@ -582,6 +578,6 @@ int main(int argc, char *argv[])
if (Error_Detected) {
return 1;
}
}
return 0;
}
+2 -2
View File
@@ -208,7 +208,7 @@ int main(int argc, char *argv[])
}
if (Error_Detected) {
break;
}
}
/* wait until the device is bound, or timeout and quit */
if (!found) {
found = address_bind_request(
@@ -243,6 +243,6 @@ int main(int argc, char *argv[])
if (Error_Detected) {
return 1;
}
}
return 0;
}
+6 -6
View File
@@ -100,8 +100,8 @@ static uint16_t BIP6_Net;
static uint8_t BIP_Rx_Buffer[BIP_MPDU_MAX];
static uint8_t BIP6_Rx_Buffer[BIP6_MPDU_MAX];
/* buffer for transmitting from any port */
#define MAX(a,b) (((a)>(b))?(a):(b))
static uint8_t Tx_Buffer[MAX(BIP_MPDU_MAX,BIP6_MPDU_MAX)];
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
static uint8_t Tx_Buffer[MAX(BIP_MPDU_MAX, BIP6_MPDU_MAX)];
/* main loop exit control */
static bool Exit_Requested;
@@ -1149,16 +1149,16 @@ int main(int argc, char *argv[])
/* input */
current_seconds = time(NULL);
/* returns 0 bytes on timeout */
pdu_len = bip_receive(&src, &BIP_Rx_Buffer[0],
sizeof(BIP_Rx_Buffer), 5);
pdu_len =
bip_receive(&src, &BIP_Rx_Buffer[0], sizeof(BIP_Rx_Buffer), 5);
/* process */
if (pdu_len) {
debug_printf("BACnet/IP Received packet\n");
my_routing_npdu_handler(BIP_Net, &src, &BIP_Rx_Buffer[0], pdu_len);
}
/* returns 0 bytes on timeout */
pdu_len = bip6_receive(&src, &BIP6_Rx_Buffer[0],
sizeof(BIP6_Rx_Buffer), 5);
pdu_len =
bip6_receive(&src, &BIP6_Rx_Buffer[0], sizeof(BIP6_Rx_Buffer), 5);
/* process */
if (pdu_len) {
debug_printf("BACnet/IPv6 Received packet\n");
+6 -6
View File
@@ -98,8 +98,8 @@ static uint16_t MSTP_Net;
static uint8_t BIP_Rx_Buffer[BIP_MPDU_MAX];
static uint8_t MSTP_Rx_Buffer[DLMSTP_MPDU_MAX];
/* buffer for transmitting from any port */
#define MAX(a,b) (((a)>(b))?(a):(b))
static uint8_t Tx_Buffer[MAX(DLMSTP_MPDU_MAX,BIP_MPDU_MAX)];
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
static uint8_t Tx_Buffer[MAX(DLMSTP_MPDU_MAX, BIP_MPDU_MAX)];
/* main loop exit control */
static bool Exit_Requested;
@@ -1160,16 +1160,16 @@ int main(int argc, char *argv[])
/* input */
current_seconds = time(NULL);
/* returns 0 bytes on timeout */
pdu_len = bip_receive(&src, &BIP_Rx_Buffer[0],
sizeof(BIP_Rx_Buffer), 5);
pdu_len =
bip_receive(&src, &BIP_Rx_Buffer[0], sizeof(BIP_Rx_Buffer), 5);
/* process */
if (pdu_len) {
debug_printf("BACnet/IP Received packet\n");
my_routing_npdu_handler(BIP_Net, &src, &BIP_Rx_Buffer[0], pdu_len);
}
/* returns 0 bytes on timeout */
pdu_len = dlmstp_receive(&src, &MSTP_Rx_Buffer[0],
sizeof(MSTP_Rx_Buffer), 5);
pdu_len =
dlmstp_receive(&src, &MSTP_Rx_Buffer[0], sizeof(MSTP_Rx_Buffer), 5);
/* process */
if (pdu_len) {
debug_printf("BACnet MS/TP Received packet\n");
+7 -6
View File
@@ -90,7 +90,7 @@ void *dl_ip_thread(void *pArgs)
&address.mac[0], &msg_data->dest.adr[0], MAX_MAC_LEN);
dl_ip_send(
&ip_data, &address, msg_data->pdu, msg_data->pdu_len);
&ip_data, &address, msg_data->pdu, msg_data->pdu_len);
check_data(msg_data);
@@ -181,15 +181,16 @@ bool dl_ip_init(ROUTER_PORT *port, IP_DATA *ip_data)
/* Bind to device so we don't get routing loops between our
different ports. */
status = setsockopt(ip_data->socket, SOL_SOCKET, SO_BINDTODEVICE,
port->iface, strlen(port->iface));
port->iface, strlen(port->iface));
if (status < 0) {
close(ip_data->socket);
return false;
close(ip_data->socket);
return false;
}
/* bind the socket to the local port number */
sin.sin_family = AF_INET;
/* sin.sin_addr.s_addr, ip_data->local_addr.s_addr;// = htonl(INADDR_ANY); */
/* sin.sin_addr.s_addr, ip_data->local_addr.s_addr;// =
* htonl(INADDR_ANY); */
sin.sin_addr.s_addr = htonl(INADDR_ANY);
sin.sin_port = ip_data->port;
@@ -309,7 +310,7 @@ int dl_ip_recv(
/* the signature of a BACnet/IP packet */
if (data->buff[0] != BVLL_TYPE_BACNET_IP) {
return 0;
}
}
switch (data->buff[1]) {
case BVLC_ORIGINAL_UNICAST_NPDU:
+4 -4
View File
@@ -272,7 +272,7 @@ bool read_config(char *filepath)
result = config_setting_lookup_string(port, "device", &iface);
if (result) {
current->iface =
(char *)calloc(sizeof(char), strlen(iface) + 1);
(char *)calloc(sizeof(char), strlen(iface) + 1);
strcpy(current->iface, iface);
/* check if interface is valid */
@@ -314,7 +314,7 @@ bool read_config(char *filepath)
result = config_setting_lookup_string(port, "device", &iface);
if (result) {
current->iface =
(char *)calloc(sizeof(char), strlen(iface) + 1);
(char *)calloc(sizeof(char), strlen(iface) + 1);
strcpy(current->iface, iface);
/* check if interface is valid */
@@ -569,7 +569,7 @@ bool parse_cmd(int argc, char *argv[])
current->route_info.mac[0]) {
current->params.mstp_params.max_master =
current->route_info.mac[0];
}
}
if (argv[optind + 1][0] != '-') {
current->params.mstp_params.max_frames =
@@ -781,7 +781,7 @@ uint16_t process_msg(BACMSG *msg, MSG_DATA *data, uint8_t **buff)
if (addr.net > 0 && addr.net < BACNET_BROADCAST_NETWORK &&
data->src.net != addr.net) {
memmove(&data->src, &addr, sizeof(BACNET_ADDRESS));
}
}
/* encode both source and destination for broadcast and router-to-router
* communication */
+1 -2
View File
@@ -62,8 +62,7 @@ BACMSG *recv_from_msgbox(MSGBOX_ID src, BACMSG *msg, int flags)
{
int recv_bytes;
recv_bytes =
msgrcv(src, msg, sizeof(BACMSG) - sizeof(MSGTYPE), 0, flags);
recv_bytes = msgrcv(src, msg, sizeof(BACMSG) - sizeof(MSGTYPE), 0, flags);
if (recv_bytes > 0) {
return msg;
} else {
+2 -2
View File
@@ -85,7 +85,7 @@ void *dl_mstp_thread(void *pArgs)
if (port->params.mstp_params.stopbits == 2) {
shared_port_data.RS485MOD |= CSTOPB;
}
}
mstp_port.UserData = (void *)&shared_port_data;
dlmstp_set_baud_rate(&mstp_port, port->params.mstp_params.baudrate);
@@ -94,7 +94,7 @@ void *dl_mstp_thread(void *pArgs)
dlmstp_set_max_master(&mstp_port, port->params.mstp_params.max_master);
if (!dlmstp_init(&mstp_port, port->iface)) {
printf("MSTP %s init failed. Stop.\n", port->iface);
}
}
port->port_id = create_msgbox();
if (port->port_id == INVALID_MSGBOX_ID) {
+5 -5
View File
@@ -133,14 +133,14 @@ uint16_t process_network_message(BACMSG *msg, MSG_DATA *data, uint8_t **buff)
i = data->pdu[apdu_offset + i + 3] + 4;
} else {
i = i + 4;
}
}
}
buff_len = create_network_message(
NETWORK_MESSAGE_INIT_RT_TABLE_ACK, data, buff, NULL);
} else {
buff_len = create_network_message(
NETWORK_MESSAGE_INIT_RT_TABLE_ACK, data, buff, &buff);
}
}
break;
case NETWORK_MESSAGE_INIT_RT_TABLE_ACK:
@@ -158,7 +158,7 @@ uint16_t process_network_message(BACMSG *msg, MSG_DATA *data, uint8_t **buff)
i = data->pdu[apdu_offset + i + 3] + 4;
} else {
i = i + 4;
}
}
}
}
break;
@@ -207,7 +207,7 @@ uint16_t create_network_message(
if (network_message_type == NETWORK_MESSAGE_INIT_RT_TABLE) {
data_expecting_reply = true;
}
}
init_npdu(&npdu_data, network_message_type, data_expecting_reply);
*buff = (uint8_t *)malloc(128); /* resolve different length */
@@ -282,7 +282,7 @@ uint16_t create_network_message(
}
} else {
(*buff)[buff_len++] = (uint8_t)0;
}
}
break;
case NETWORK_MESSAGE_INVALID:
+2 -2
View File
@@ -53,14 +53,14 @@ ROUTER_PORT *find_dnet(uint16_t net, BACNET_ADDRESS *addr)
/* for broadcast messages no search is needed */
if (net == BACNET_BROADCAST_NETWORK) {
return port;
}
}
while (port != NULL) {
/* check if DNET is directly connected to the router */
if (net == port->route_info.net) {
return port;
/* else search router ports DNET list */
/* else search router ports DNET list */
} else if (port->route_info.dnets) {
dnet = port->route_info.dnets;
while (dnet != NULL) {
+1 -1
View File
@@ -420,6 +420,6 @@ int main(int argc, char *argv[])
}
if (Error_Detected) {
return 1;
}
}
return 0;
}
+2 -2
View File
@@ -267,9 +267,9 @@ int main(int argc, char *argv[])
ucix_cleanup(ctx);
#endif /* defined(BAC_UCI) */
BACNET_CHARACTER_STRING DeviceName;
if (Device_Object_Name(Device_Object_Instance_Number(),&DeviceName)) {
if (Device_Object_Name(Device_Object_Instance_Number(), &DeviceName)) {
printf("BACnet Device Name: %s\n", DeviceName.value);
}
}
dlenv_init();
atexit(datalink_cleanup);
+1 -1
View File
@@ -260,7 +260,7 @@ int main(int argc, char *argv[])
atexit(datalink_cleanup);
mstimer_init();
/* send the request */
datetime_local(override_date?NULL:&bdate,override_time?NULL:&btime,
datetime_local(override_date ? NULL : &bdate, override_time ? NULL : &btime,
NULL, NULL);
Send_TimeSync_Remote(&dest, &bdate, &btime);
mstimer_set(&apdu_timer, apdu_timeout());
+3 -4
View File
@@ -183,8 +183,7 @@ int main(int argc, char *argv[])
cov_data.timeRemaining = strtol(argv[5], NULL, 0);
cov_data.listOfValues = &value_list;
value_list.next = NULL;
if (bactext_property_strtol(argv[6], &object_property) ==
false) {
if (bactext_property_strtol(argv[6], &object_property) == false) {
fprintf(stderr, "property=%s invalid\n", argv[6]);
return 1;
}
@@ -196,13 +195,13 @@ int main(int argc, char *argv[])
value_list.priority = strtol(argv[9], NULL, 0);
} else {
value_list.priority = BACNET_NO_PRIORITY;
}
}
/* optional index */
if (argc > 10) {
value_list.propertyArrayIndex = strtol(argv[10], NULL, 0);
} else {
value_list.propertyArrayIndex = BACNET_ARRAY_ALL;
}
}
if (cov_data.initiatingDeviceIdentifier >= BACNET_MAX_INSTANCE) {
fprintf(stderr, "device-instance=%u - it must be less than %u\r\n",
+2 -2
View File
@@ -317,7 +317,7 @@ int main(int argc, char *argv[])
}
if (Error_Detected) {
break;
}
}
/* wait until the device is bound, or timeout and quit */
if (!found) {
found = address_bind_request(
@@ -367,6 +367,6 @@ int main(int argc, char *argv[])
if (Error_Detected) {
return 1;
}
}
return 0;
}
+3 -3
View File
@@ -104,8 +104,8 @@ static void My_Router_Handler(BACNET_ADDRESS *src,
that are sent with a local unicast address. */
if (npdu_len >= 2) {
len += decode_unsigned16(npdu, &dnet);
printf(": network number = %u. SNET=%u\n",
(unsigned)dnet, (unsigned)src->net);
printf(": network number = %u. SNET=%u\n", (unsigned)dnet,
(unsigned)src->net);
} else {
printf(": network number = missing! SNET=%u\n", src->net);
}
@@ -278,7 +278,7 @@ int main(int argc, char *argv[])
}
if (Error_Detected) {
break;
}
}
/* increment timer - exit if timed out */
elapsed_seconds = current_seconds - last_seconds;
if (elapsed_seconds) {
+1 -1
View File
@@ -246,7 +246,7 @@ int main(int argc, char *argv[])
}
if (Error_Detected) {
break;
}
}
/* increment timer - exit if timed out */
elapsed_seconds += (current_seconds - last_seconds);
if (elapsed_seconds > timeout_seconds) {
+5 -5
View File
@@ -497,8 +497,8 @@ int main(int argc, char *argv[])
/* loop forever */
for (;;) {
/* returns 0 bytes on timeout */
pdu_len = datalink_receive(&src, &Rx_Buf[0], MAX_MPDU,
delay_milliseconds);
pdu_len =
datalink_receive(&src, &Rx_Buf[0], MAX_MPDU, delay_milliseconds);
/* process */
if (pdu_len) {
npdu_handler(&src, &Rx_Buf[0], pdu_len);
@@ -507,13 +507,13 @@ int main(int argc, char *argv[])
break;
}
if (mstimer_expired(&datalink_timer)) {
datalink_maintenance_timer(mstimer_interval(&datalink_timer)/1000);
datalink_maintenance_timer(
mstimer_interval(&datalink_timer) / 1000);
mstimer_reset(&datalink_timer);
}
if (mstimer_expired(&apdu_timer)) {
if (repeat_forever || retry_count) {
Send_WhoIs_To_Network(
&dest, Target_Object_Instance_Min,
Send_WhoIs_To_Network(&dest, Target_Object_Instance_Min,
Target_Object_Instance_Max);
retry_count--;
} else {
+1 -1
View File
@@ -293,7 +293,7 @@ int main(int argc, char *argv[])
}
if (Error_Detected) {
break;
}
}
/* increment timer - exit if timed out */
elapsed_seconds = current_seconds - last_seconds;
if (elapsed_seconds) {
+6 -8
View File
@@ -123,10 +123,9 @@ int main(int argc, char *argv[])
int c = 0;
uint16_t result_code = 0;
if (argc < 2) {
printf("Usage: %s IP port <IP:port[:mask]> [<IP:port[:mask]>]\r\n",
filename_remove_path(argv[0]));
filename_remove_path(argv[0]));
return 0;
}
if ((argc > 1) && (strcmp(argv[1], "--help") == 0)) {
@@ -148,8 +147,8 @@ int main(int argc, char *argv[])
if (argc > 1) {
argi = 1;
if (!bip_get_addr_by_name(argv[argi], &Target_BBMD_Address)) {
fprintf(stderr, "IP=%s - failed to convert address.\r\n",
argv[argi]);
fprintf(
stderr, "IP=%s - failed to convert address.\r\n", argv[argi]);
return 1;
}
}
@@ -172,8 +171,8 @@ int main(int argc, char *argv[])
argi = 3;
while (argc > argi) {
bdt_entry = &BBMD_Table_Entry[bdti];
c = sscanf(argv[argi], "%3u.%3u.%3u.%3u:%5u:%3u.%3u.%3u.%3u",
&a[0], &a[1], &a[2], &a[3], &p, &m[0], &m[1], &m[2], &m[3]);
c = sscanf(argv[argi], "%3u.%3u.%3u.%3u:%5u:%3u.%3u.%3u.%3u", &a[0],
&a[1], &a[2], &a[3], &p, &m[0], &m[1], &m[2], &m[3]);
if ((c == 4) || (c == 5) || (c == 9)) {
bvlc_address_set(&bdt_entry->dest_address, a[0], a[1], a[2], a[3]);
if ((c == 5) || (c == 9)) {
@@ -216,8 +215,7 @@ int main(int argc, char *argv[])
if (bvlc_get_function_code() != BVLC_INVALID) {
if (bvlc_get_function_code() == BVLC_RESULT) {
result_code = bvlc_get_last_result();
printf("BVLC Result: %s\n",
bvlc_result_code_name(result_code));
printf("BVLC Result: %s\n", bvlc_result_code_name(result_code));
break;
}
bvlc_set_function_code(BVLC_INVALID);
+9 -6
View File
@@ -292,7 +292,7 @@ int main(int argc, char *argv[])
Target_Object_Property_Index = strtol(argv[6], NULL, 0);
if (Target_Object_Property_Index == -1) {
Target_Object_Property_Index = BACNET_ARRAY_ALL;
}
}
if (Target_Device_Object_Instance > BACNET_MAX_INSTANCE) {
fprintf(stderr, "device-instance=%u - it must be less than %u\n",
Target_Device_Object_Instance, BACNET_MAX_INSTANCE + 1);
@@ -338,7 +338,8 @@ int main(int argc, char *argv[])
tag_value_arg++;
args_remaining--;
if (property_tag < 0) {
property_tag = bacapp_known_property_tag(Target_Object_Type, Target_Object_Property);
property_tag = bacapp_known_property_tag(
Target_Object_Type, Target_Object_Property);
} else if (property_tag >= MAX_BACNET_APPLICATION_TAG) {
fprintf(stderr, "Error: tag=%u - it must be less than %u\n",
property_tag, MAX_BACNET_APPLICATION_TAG);
@@ -354,8 +355,10 @@ int main(int argc, char *argv[])
}
} else {
/* FIXME: show the expected entry format for the tag */
fprintf(stderr, "Error: unable to parse the known property"
" \"%s\"\r\n", value_string);
fprintf(stderr,
"Error: unable to parse the known property"
" \"%s\"\r\n",
value_string);
return 1;
}
@@ -419,7 +422,7 @@ int main(int argc, char *argv[])
}
if (Error_Detected) {
break;
}
}
/* wait until the device is bound, or timeout and quit */
if (!found) {
found = address_bind_request(
@@ -465,6 +468,6 @@ int main(int argc, char *argv[])
}
if (Error_Detected) {
return 1;
}
}
return 0;
}
+12 -9
View File
@@ -70,11 +70,10 @@ static bool Error_Detected = false;
/* Used for verbose */
static bool Verbose = false;
static void MyWritePropertyMultipleErrorHandler(
BACNET_ADDRESS * src,
static void MyWritePropertyMultipleErrorHandler(BACNET_ADDRESS *src,
uint8_t invoke_id,
uint8_t service_choice,
uint8_t * service_request,
uint8_t *service_request,
uint16_t service_len)
{
int len = 0;
@@ -121,7 +120,6 @@ static void MyRejectHandler(
}
}
static void MyWritePropertyMultipleSimpleAckHandler(
BACNET_ADDRESS *src, uint8_t invoke_id)
{
@@ -428,7 +426,9 @@ int main(int argc, char *argv[])
printf("tag=%u value=%s\n", property_tag, value_string);
}
if (property_tag < 0) {
property_tag = bacapp_known_property_tag(wpm_object->object_type, wpm_property->propertyIdentifier);
property_tag =
bacapp_known_property_tag(wpm_object->object_type,
wpm_property->propertyIdentifier);
} else if (property_tag >= MAX_BACNET_APPLICATION_TAG) {
fprintf(stderr, "Error: tag=%u - it must be less than %u\n",
property_tag, MAX_BACNET_APPLICATION_TAG);
@@ -439,13 +439,16 @@ int main(int argc, char *argv[])
property_tag, value_string, &wpm_property->value);
if (!status) {
/* FIXME: show the expected entry format for the tag */
fprintf(stderr, "Error: unable to parse the tag value\n");
fprintf(
stderr, "Error: unable to parse the tag value\n");
return 1;
}
} else {
/* FIXME: show the expected entry format for the tag */
fprintf(stderr, "Error: unable to parse the known property"
" \"%s\"\r\n", value_string);
fprintf(stderr,
"Error: unable to parse the known property"
" \"%s\"\r\n",
value_string);
return 1;
}
wpm_property->value.next = NULL;
@@ -493,7 +496,7 @@ int main(int argc, char *argv[])
}
if (Error_Detected) {
break;
}
}
/* wait until the device is bound, or timeout and quit */
if (!found) {
found = address_bind_request(