Changed a bunch of debug and information printfs so that they have a better chance of working on systems where int is smaller than 32 bits also fixed the signed/unsigned type of some to match the type of the arguments.
This commit is contained in:
@@ -90,9 +90,9 @@ void handler_alarm_ack(
|
||||
*/
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr,
|
||||
"Alarm Ack Operation: Received acknowledge for object id %d from %s for process id %d for object %id\n",
|
||||
data.eventObjectIdentifier.instance, data.ackSource.value,
|
||||
data.ackProcessIdentifier, data.eventObjectIdentifier.instance);
|
||||
"Alarm Ack Operation: Received acknowledge for object id %lu from %s for process id %lu for object %lu\n",
|
||||
(unsigned long)data.eventObjectIdentifier.instance, data.ackSource.value,
|
||||
(unsigned long)data.ackProcessIdentifier, (unsigned long)data.eventObjectIdentifier.instance);
|
||||
#endif
|
||||
|
||||
len =
|
||||
|
||||
@@ -79,8 +79,8 @@ void handler_atomic_read_file_ack(
|
||||
octetstring_length(&data.fileData), 1,
|
||||
pFile) != 1) {
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr, "Failed to write to %s (%u)!\n",
|
||||
pFilename, instance);
|
||||
fprintf(stderr, "Failed to write to %s (%lu)!\n",
|
||||
pFilename, (unsigned long)instance);
|
||||
#endif
|
||||
}
|
||||
fclose(pFile);
|
||||
|
||||
@@ -385,8 +385,8 @@ void handler_cov_task(
|
||||
if (lifetime_seconds >= elapsed_seconds) {
|
||||
COV_Subscriptions[index].lifetime -= elapsed_seconds;
|
||||
#if 0
|
||||
fprintf(stderr, "COVtask: subscription[%d].lifetime=%d\n",
|
||||
index, COV_Subscriptions[index].lifetime);
|
||||
fprintf(stderr, "COVtask: subscription[%d].lifetime=%lu\n",
|
||||
index, (unsigned long)COV_Subscriptions[index].lifetime);
|
||||
#endif
|
||||
} else {
|
||||
COV_Subscriptions[index].lifetime = 0;
|
||||
|
||||
@@ -52,7 +52,7 @@ void handler_i_am_add(
|
||||
#endif
|
||||
if (len != -1) {
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr, " from %u, MAC = %d.%d.%d.%d.%d.%d\n", device_id,
|
||||
fprintf(stderr, " from %lu, MAC = %d.%d.%d.%d.%d.%d\n", (unsigned long)device_id,
|
||||
src->mac[0], src->mac[1], src->mac[2], src->mac[3], src->mac[4],
|
||||
src->mac[5]);
|
||||
#endif
|
||||
|
||||
@@ -45,11 +45,11 @@ void handler_i_have(
|
||||
len = ihave_decode_service_request(service_request, service_len, &data);
|
||||
if (len != -1) {
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr, "I-Have: %s %d from %s %u!\r\n",
|
||||
fprintf(stderr, "I-Have: %s %lu from %s %lu!\r\n",
|
||||
bactext_object_type_name(data.object_id.type),
|
||||
data.object_id.instance,
|
||||
(unsigned long)data.object_id.instance,
|
||||
bactext_object_type_name(data.device_id.type),
|
||||
data.device_id.instance);
|
||||
(unsigned long)data.device_id.instance);
|
||||
#endif
|
||||
} else {
|
||||
#if PRINT_ENABLED
|
||||
|
||||
@@ -89,8 +89,8 @@ void handler_lso(
|
||||
*/
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr,
|
||||
"Life Safety Operation: Received operation %d from process id %d for object %id\n",
|
||||
data.operation, data.processId, data.targetObject.instance);
|
||||
"Life Safety Operation: Received operation %d from process id %lu for object %lu\n",
|
||||
data.operation, (unsigned long)data.processId, (unsigned long)data.targetObject.instance);
|
||||
#endif
|
||||
|
||||
len =
|
||||
|
||||
@@ -62,12 +62,12 @@ void npdu_handler(
|
||||
} else {
|
||||
if (dest.net) {
|
||||
#if PRINT_ENABLED
|
||||
printf("NPDU: DNET=%d. Discarded!\n", dest.net);
|
||||
printf("NPDU: DNET=%u. Discarded!\n", (unsigned)dest.net);
|
||||
#endif
|
||||
} else {
|
||||
#if PRINT_ENABLED
|
||||
printf("NPDU: BACnet Protocol Version=%d. Discarded!\n",
|
||||
npdu_data.protocol_version);
|
||||
printf("NPDU: BACnet Protocol Version=%u. Discarded!\n",
|
||||
(unsigned)npdu_data.protocol_version);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,13 +166,13 @@ void ProcessPTA(
|
||||
cBlockNumber = (char) ulTemp;
|
||||
DecodeBlock(cBlockNumber, &data->serviceParameters[iLen]);
|
||||
} else { /* Read error */
|
||||
printf("Private Transfer read operation returned error code: %u\n",
|
||||
uiErrorCode);
|
||||
printf("Private Transfer read operation returned error code: %lu\n",
|
||||
(unsigned long)uiErrorCode);
|
||||
return;
|
||||
}
|
||||
} else { /* Write I/O block - should just be an OK type message */
|
||||
printf("Private Transfer write operation returned error code: %u\n",
|
||||
uiErrorCode);
|
||||
printf("Private Transfer write operation returned error code: %lu\n",
|
||||
(unsigned long)uiErrorCode);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -55,14 +55,14 @@ static void PrintReadPropertyData(
|
||||
if (data) {
|
||||
#if 0
|
||||
if (data->array_index == BACNET_ARRAY_ALL)
|
||||
fprintf(stderr, "%s #%u %s\n",
|
||||
fprintf(stderr, "%s #%lu %s\n",
|
||||
bactext_object_type_name(data->object_type),
|
||||
data->object_instance,
|
||||
(unsigned long)data->object_instance,
|
||||
bactext_property_name(data->object_property));
|
||||
else
|
||||
fprintf(stderr, "%s #%u %s[%d]\n",
|
||||
fprintf(stderr, "%s #%lu %s[%d]\n",
|
||||
bactext_object_type_name(data->object_type),
|
||||
data->object_instance,
|
||||
(unsigned long)data->object_instance,
|
||||
bactext_property_name(data->object_property),
|
||||
data->array_index);
|
||||
#endif
|
||||
|
||||
@@ -198,9 +198,9 @@ static void PrintReadPropertyMultipleData(
|
||||
|
||||
if (rpm_data) {
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stdout, "%s #%u\r\n",
|
||||
fprintf(stdout, "%s #%lu\r\n",
|
||||
bactext_object_type_name(rpm_data->object_type),
|
||||
rpm_data->object_instance);
|
||||
(unsigned long)rpm_data->object_instance);
|
||||
fprintf(stdout, "{\r\n");
|
||||
#endif
|
||||
listOfProperties = rpm_data->listOfProperties;
|
||||
@@ -212,7 +212,7 @@ static void PrintReadPropertyMultipleData(
|
||||
propertyIdentifier));
|
||||
} else {
|
||||
fprintf(stdout, " proprietary %u: ",
|
||||
listOfProperties->propertyIdentifier);
|
||||
(unsigned)listOfProperties->propertyIdentifier);
|
||||
}
|
||||
#endif
|
||||
if (listOfProperties->propertyArrayIndex != BACNET_ARRAY_ALL) {
|
||||
|
||||
@@ -87,9 +87,9 @@ void handler_write_property(
|
||||
#if PRINT_ENABLED
|
||||
if (len > 0)
|
||||
fprintf(stderr,
|
||||
"WP: type=%u instance=%u property=%u priority=%u index=%d\n",
|
||||
wp_data.object_type, wp_data.object_instance,
|
||||
wp_data.object_property, wp_data.priority, wp_data.array_index);
|
||||
"WP: type=%lu instance=%lu property=%lu priority=%lu index=%ld\n",
|
||||
(unsigned long)wp_data.object_type, (unsigned long)wp_data.object_instance,
|
||||
(unsigned long)wp_data.object_property, (unsigned long)wp_data.priority, (long)wp_data.array_index);
|
||||
else
|
||||
fprintf(stderr, "WP: Unable to decode Request!\n");
|
||||
#endif
|
||||
|
||||
@@ -91,8 +91,8 @@ OBJECT_DEVICE_T *objects_device_new(
|
||||
Keylist_Data_Add(Device_List, key, pDevice);
|
||||
} else {
|
||||
fprintf(stderr,
|
||||
"Objects: Unable to allocate device %d buffer\n",
|
||||
device_instance);
|
||||
"Objects: Unable to allocate device %lu buffer\n",
|
||||
(unsigned long)device_instance);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -109,8 +109,8 @@ OBJECT_DEVICE_T *objects_device_delete(
|
||||
if (Device_List) {
|
||||
pDevice = Keylist_Data_Delete_By_Index(Device_List, index);
|
||||
if (pDevice) {
|
||||
fprintf(stderr, "Objects: removing device %d",
|
||||
pDevice->Object_Identifier.instance);
|
||||
fprintf(stderr, "Objects: removing device %lu",
|
||||
(unsigned long)pDevice->Object_Identifier.instance);
|
||||
if (pDevice->Object_List) {
|
||||
do {
|
||||
pObject =
|
||||
|
||||
@@ -133,7 +133,7 @@ char *Analog_Input_Name(
|
||||
static char text_string[32] = ""; /* okay for single thread */
|
||||
|
||||
if (object_instance < MAX_ANALOG_INPUTS) {
|
||||
sprintf(text_string, "ANALOG INPUT %u", object_instance);
|
||||
sprintf(text_string, "ANALOG INPUT %lu", (unsigned long)object_instance);
|
||||
return text_string;
|
||||
}
|
||||
|
||||
|
||||
@@ -256,7 +256,7 @@ char *Analog_Output_Name(
|
||||
static char text_string[32] = ""; /* okay for single thread */
|
||||
|
||||
if (object_instance < MAX_ANALOG_OUTPUTS) {
|
||||
sprintf(text_string, "ANALOG OUTPUT %u", object_instance);
|
||||
sprintf(text_string, "ANALOG OUTPUT %lu", (unsigned long)object_instance);
|
||||
return text_string;
|
||||
}
|
||||
|
||||
|
||||
@@ -215,7 +215,7 @@ char *Analog_Value_Name(
|
||||
static char text_string[32] = ""; /* okay for single thread */
|
||||
|
||||
if (object_instance < MAX_ANALOG_VALUES) {
|
||||
sprintf(text_string, "ANALOG VALUE %u", object_instance);
|
||||
sprintf(text_string, "ANALOG VALUE %lu", (unsigned long)object_instance);
|
||||
return text_string;
|
||||
}
|
||||
|
||||
|
||||
@@ -203,7 +203,7 @@ int bacfile_encode_property_apdu(
|
||||
object_instance);
|
||||
break;
|
||||
case PROP_OBJECT_NAME:
|
||||
sprintf(text_string, "FILE %d", object_instance);
|
||||
sprintf(text_string, "FILE %lu", (unsigned long)object_instance);
|
||||
characterstring_init_ansi(&char_string, text_string);
|
||||
apdu_len =
|
||||
encode_application_character_string(&apdu[0], &char_string);
|
||||
|
||||
@@ -279,7 +279,7 @@ char *Binary_Input_Name(
|
||||
static char text_string[32] = ""; /* okay for single thread */
|
||||
|
||||
if (object_instance < MAX_BINARY_INPUTS) {
|
||||
sprintf(text_string, "BINARY INPUT %u", object_instance);
|
||||
sprintf(text_string, "BINARY INPUT %lu", (unsigned long)object_instance);
|
||||
return text_string;
|
||||
}
|
||||
|
||||
|
||||
@@ -179,7 +179,7 @@ char *Binary_Output_Name(
|
||||
static char text_string[32] = ""; /* okay for single thread */
|
||||
|
||||
if (object_instance < MAX_BINARY_OUTPUTS) {
|
||||
sprintf(text_string, "BINARY OUTPUT %u", object_instance);
|
||||
sprintf(text_string, "BINARY OUTPUT %lu", (unsigned long)object_instance);
|
||||
return text_string;
|
||||
}
|
||||
|
||||
|
||||
@@ -176,7 +176,7 @@ char *Binary_Value_Name(
|
||||
static char text_string[32] = ""; /* okay for single thread */
|
||||
|
||||
if (object_instance < MAX_BINARY_VALUES) {
|
||||
sprintf(text_string, "BINARY VALUE %u", object_instance);
|
||||
sprintf(text_string, "BINARY VALUE %lu", (unsigned long)object_instance);
|
||||
return text_string;
|
||||
}
|
||||
|
||||
|
||||
@@ -97,7 +97,7 @@
|
||||
|
||||
/* some modules have debugging enabled using PRINT_ENABLED */
|
||||
#if !defined(PRINT_ENABLED)
|
||||
#define PRINT_ENABLED 0
|
||||
#define PRINT_ENABLED 1
|
||||
#endif
|
||||
|
||||
/* BACAPP decodes WriteProperty service requests
|
||||
|
||||
@@ -74,10 +74,10 @@ static long gethostaddr(
|
||||
return -1;
|
||||
if (BIP_Debug) {
|
||||
printf("host: %s at %u.%u.%u.%u\n", host_name,
|
||||
((uint8_t *) host_ent->h_addr)[0],
|
||||
((uint8_t *) host_ent->h_addr)[1],
|
||||
((uint8_t *) host_ent->h_addr)[2],
|
||||
((uint8_t *) host_ent->h_addr)[3]);
|
||||
(unsigned)((uint8_t *) host_ent->h_addr)[0],
|
||||
(unsigned)((uint8_t *) host_ent->h_addr)[1],
|
||||
(unsigned)((uint8_t *) host_ent->h_addr)[2],
|
||||
(unsigned)((uint8_t *) host_ent->h_addr)[3]);
|
||||
}
|
||||
/* note: network byte order */
|
||||
return *(long *) host_ent->h_addr;
|
||||
|
||||
@@ -664,7 +664,7 @@ bool dlmstp_init(
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr, "MS/TP MAC: %02X\n", MSTP_Port.This_Station);
|
||||
fprintf(stderr, "MS/TP Max_Master: %02X\n", MSTP_Port.Nmax_master);
|
||||
fprintf(stderr, "MS/TP Max_Info_Frames: %u\n", MSTP_Port.Nmax_info_frames);
|
||||
fprintf(stderr, "MS/TP Max_Info_Frames: %u\n", (unsigned)MSTP_Port.Nmax_info_frames);
|
||||
#endif
|
||||
/* start the threads */
|
||||
hThread = _beginthread(dlmstp_millisecond_task, 4096, &arg_value);
|
||||
|
||||
+17
-17
@@ -822,10 +822,10 @@ bool bacapp_print_value(
|
||||
fprintf(stream, "%s", value->type.Boolean ? "TRUE" : "FALSE");
|
||||
break;
|
||||
case BACNET_APPLICATION_TAG_UNSIGNED_INT:
|
||||
fprintf(stream, "%u", value->type.Unsigned_Int);
|
||||
fprintf(stream, "%lu", (unsigned long)value->type.Unsigned_Int);
|
||||
break;
|
||||
case BACNET_APPLICATION_TAG_SIGNED_INT:
|
||||
fprintf(stream, "%d", value->type.Signed_Int);
|
||||
fprintf(stream, "%ld", (long)value->type.Signed_Int);
|
||||
break;
|
||||
case BACNET_APPLICATION_TAG_REAL:
|
||||
fprintf(stream, "%f", (double) value->type.Real);
|
||||
@@ -878,11 +878,11 @@ bool bacapp_print_value(
|
||||
bactext_object_type_name(value->type.
|
||||
Enumerated));
|
||||
} else if (value->type.Enumerated < 128) {
|
||||
fprintf(stream, "reserved %u",
|
||||
value->type.Enumerated);
|
||||
fprintf(stream, "reserved %lu",
|
||||
(unsigned long)value->type.Enumerated);
|
||||
} else {
|
||||
fprintf(stream, "proprietary %u",
|
||||
value->type.Enumerated);
|
||||
fprintf(stream, "proprietary %lu",
|
||||
(unsigned long)value->type.Enumerated);
|
||||
}
|
||||
break;
|
||||
case PROP_EVENT_STATE:
|
||||
@@ -895,8 +895,8 @@ bool bacapp_print_value(
|
||||
bactext_engineering_unit_name(value->
|
||||
type.Enumerated));
|
||||
} else {
|
||||
fprintf(stream, "proprietary %u",
|
||||
value->type.Enumerated);
|
||||
fprintf(stream, "proprietary %lu",
|
||||
(unsigned long)value->type.Enumerated);
|
||||
}
|
||||
break;
|
||||
case PROP_PRESENT_VALUE:
|
||||
@@ -918,7 +918,7 @@ bool bacapp_print_value(
|
||||
bactext_segmentation_name(value->type.Enumerated));
|
||||
break;
|
||||
default:
|
||||
fprintf(stream, "%u", value->type.Enumerated);
|
||||
fprintf(stream, "%lu", (unsigned long)value->type.Enumerated);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@@ -962,17 +962,17 @@ bool bacapp_print_value(
|
||||
break;
|
||||
case BACNET_APPLICATION_TAG_OBJECT_ID:
|
||||
if (value->type.Object_Id.type < MAX_ASHRAE_OBJECT_TYPE) {
|
||||
fprintf(stream, "(%s, %u)",
|
||||
fprintf(stream, "(%s, %lu)",
|
||||
bactext_object_type_name(value->type.Object_Id.type),
|
||||
value->type.Object_Id.instance);
|
||||
(unsigned long)value->type.Object_Id.instance);
|
||||
} else if (value->type.Object_Id.type < 128) {
|
||||
fprintf(stream, "(reserved %u, %u)",
|
||||
value->type.Object_Id.type,
|
||||
value->type.Object_Id.instance);
|
||||
fprintf(stream, "(reserved %u, %lu)",
|
||||
(unsigned)value->type.Object_Id.type,
|
||||
(unsigned long)value->type.Object_Id.instance);
|
||||
} else {
|
||||
fprintf(stream, "(proprietary %u, %u)",
|
||||
value->type.Object_Id.type,
|
||||
value->type.Object_Id.instance);
|
||||
fprintf(stream, "(proprietary %u, %lu)",
|
||||
(unsigned)value->type.Object_Id.type,
|
||||
(unsigned long)value->type.Object_Id.instance);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -2007,7 +2007,7 @@ void testBACDCodeUnsignedValue(
|
||||
len = decode_unsigned(&array[len], len_value, &decoded_value);
|
||||
ct_test(pTest, decoded_value == value);
|
||||
if (decoded_value != value) {
|
||||
printf("value=%u decoded_value=%u\n", value, decoded_value);
|
||||
printf("value=%lu decoded_value=%lu\n", (unsigned long)value, (unsigned long)decoded_value);
|
||||
print_apdu(&array[0], sizeof(array));
|
||||
}
|
||||
encode_application_unsigned(&encoded_array[0], decoded_value);
|
||||
@@ -2075,14 +2075,14 @@ void testBACDCodeSignedValue(
|
||||
ct_test(pTest, tag_number == BACNET_APPLICATION_TAG_SIGNED_INT);
|
||||
ct_test(pTest, decoded_value == value);
|
||||
if (decoded_value != value) {
|
||||
printf("value=%d decoded_value=%d\n", value, decoded_value);
|
||||
printf("value=%ld decoded_value=%ld\n", (long)value, (long)decoded_value);
|
||||
print_apdu(&array[0], sizeof(array));
|
||||
}
|
||||
encode_application_signed(&encoded_array[0], decoded_value);
|
||||
diff = memcmp(&array[0], &encoded_array[0], sizeof(array));
|
||||
ct_test(pTest, diff == 0);
|
||||
if (diff) {
|
||||
printf("value=%d decoded_value=%d\n", value, decoded_value);
|
||||
printf("value=%ld decoded_value=%ld\n", (long)value, (long)decoded_value);
|
||||
print_apdu(&array[0], sizeof(array));
|
||||
print_apdu(&encoded_array[0], sizeof(array));
|
||||
}
|
||||
|
||||
@@ -348,8 +348,8 @@ void MSTP_Receive_Frame_FSM(
|
||||
mstp_port->ReceivedInvalidFrame = true;
|
||||
/* wait for the start of a frame. */
|
||||
mstp_port->receive_state = MSTP_RECEIVE_STATE_IDLE;
|
||||
printf_receive_error("MSTP: Rx Header: SilenceTimer %d > %d\n",
|
||||
mstp_port->SilenceTimer(), Tframe_abort);
|
||||
printf_receive_error("MSTP: Rx Header: SilenceTimer %u > %d\n",
|
||||
(unsigned)mstp_port->SilenceTimer(), Tframe_abort);
|
||||
}
|
||||
/* Error */
|
||||
else if (mstp_port->ReceiveError == true) {
|
||||
@@ -438,8 +438,8 @@ void MSTP_Receive_Frame_FSM(
|
||||
/* FrameTooLong */
|
||||
if (mstp_port->DataLength) {
|
||||
printf_receive_error
|
||||
("MSTP: Rx Header: FrameTooLong %d\n",
|
||||
mstp_port->DataLength);
|
||||
("MSTP: Rx Header: FrameTooLong %u\n",
|
||||
(unsigned)mstp_port->DataLength);
|
||||
/* indicate that a frame with an illegal or */
|
||||
/* unacceptable data length has been received */
|
||||
mstp_port->ReceivedInvalidFrame = true;
|
||||
@@ -471,8 +471,8 @@ void MSTP_Receive_Frame_FSM(
|
||||
/* indicate that an error has occurred during */
|
||||
/* the reception of a frame */
|
||||
mstp_port->ReceivedInvalidFrame = true;
|
||||
printf_receive_error("MSTP: Rx Data: BadIndex %d\n",
|
||||
mstp_port->Index);
|
||||
printf_receive_error("MSTP: Rx Data: BadIndex %u\n",
|
||||
(unsigned)mstp_port->Index);
|
||||
/* wait for the start of a frame. */
|
||||
mstp_port->receive_state = MSTP_RECEIVE_STATE_IDLE;
|
||||
}
|
||||
@@ -488,8 +488,8 @@ void MSTP_Receive_Frame_FSM(
|
||||
/* indicate that an error has occurred during the reception of a frame */
|
||||
mstp_port->ReceivedInvalidFrame = true;
|
||||
printf_receive_error
|
||||
("MSTP: Rx Data: SilenceTimer %dms > %dms\n",
|
||||
mstp_port->SilenceTimer(), Tframe_abort);
|
||||
("MSTP: Rx Data: SilenceTimer %ums > %dms\n",
|
||||
(unsigned)mstp_port->SilenceTimer(), Tframe_abort);
|
||||
/* wait for the start of the next frame. */
|
||||
mstp_port->receive_state = MSTP_RECEIVE_STATE_IDLE;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user