Added debugging.
This commit is contained in:
@@ -157,7 +157,6 @@ int main(
|
|||||||
bool found = false;
|
bool found = false;
|
||||||
|
|
||||||
if (argc < 3) {
|
if (argc < 3) {
|
||||||
/* note: priority 16 and 0 should produce the same end results... */
|
|
||||||
printf("Usage: %s device-instance state timeout [password]\r\n"
|
printf("Usage: %s device-instance state timeout [password]\r\n"
|
||||||
"Send BACnet DeviceCommunicationControl service to device.\r\n"
|
"Send BACnet DeviceCommunicationControl service to device.\r\n"
|
||||||
"\r\n" "The device-instance can be 0 to %d.\r\n"
|
"\r\n" "The device-instance can be 0 to %d.\r\n"
|
||||||
|
|||||||
+22
-2
@@ -231,6 +231,9 @@ uint16_t bip_receive(
|
|||||||
if ((sin.sin_addr.s_addr == htonl(BIP_Address.s_addr)) &&
|
if ((sin.sin_addr.s_addr == htonl(BIP_Address.s_addr)) &&
|
||||||
(sin.sin_port == htonl(BIP_Port))) {
|
(sin.sin_port == htonl(BIP_Port))) {
|
||||||
pdu_len = 0;
|
pdu_len = 0;
|
||||||
|
#if PRINT_ENABLED
|
||||||
|
fprintf(stderr,"BIP: src is me. Discarded!\n");
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
/* copy the source address
|
/* copy the source address
|
||||||
FIXME: IPv6? */
|
FIXME: IPv6? */
|
||||||
@@ -244,16 +247,33 @@ uint16_t bip_receive(
|
|||||||
/* subtract off the BVLC header */
|
/* subtract off the BVLC header */
|
||||||
pdu_len -= 4;
|
pdu_len -= 4;
|
||||||
if (pdu_len < max_pdu) {
|
if (pdu_len < max_pdu) {
|
||||||
|
#if 0
|
||||||
|
fprintf(stderr,"BIP: NPDU[%hu]:",pdu_len);
|
||||||
|
#endif
|
||||||
/* shift the buffer to return a valid PDU */
|
/* shift the buffer to return a valid PDU */
|
||||||
for (i = 0; i < pdu_len; i++) {
|
for (i = 0; i < pdu_len; i++) {
|
||||||
pdu[i] = pdu[i + 4];
|
pdu[i] = pdu[4 + i];
|
||||||
|
#if 0
|
||||||
|
fprintf(stderr,"%02X ",pdu[i]);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
#if 0
|
||||||
|
fprintf(stderr,"\n");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
/* ignore packets that are too large */
|
/* ignore packets that are too large */
|
||||||
/* clients should check my max-apdu first */
|
/* clients should check my max-apdu first */
|
||||||
else
|
else {
|
||||||
pdu_len = 0;
|
pdu_len = 0;
|
||||||
|
#if PRINT_ENABLED
|
||||||
|
fprintf(stderr,"BIP: PDU too large. Discarded!.\n");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
#if PRINT_ENABLED
|
||||||
|
fprintf(stderr,"BIP: BVLC discarded!\n");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
return pdu_len;
|
return pdu_len;
|
||||||
|
|||||||
@@ -41,6 +41,10 @@
|
|||||||
#include "npdu.h"
|
#include "npdu.h"
|
||||||
#include "apdu.h"
|
#include "apdu.h"
|
||||||
|
|
||||||
|
#if PRINT_ENABLED
|
||||||
|
#include <stdio.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
void npdu_copy_data(
|
void npdu_copy_data(
|
||||||
BACNET_NPDU_DATA * dest,
|
BACNET_NPDU_DATA * dest,
|
||||||
BACNET_NPDU_DATA * src)
|
BACNET_NPDU_DATA * src)
|
||||||
@@ -377,6 +381,9 @@ void npdu_handler(
|
|||||||
apdu_offset = npdu_decode(&pdu[0], &dest, src, &npdu_data);
|
apdu_offset = npdu_decode(&pdu[0], &dest, src, &npdu_data);
|
||||||
if (npdu_data.network_layer_message) {
|
if (npdu_data.network_layer_message) {
|
||||||
/*FIXME: network layer message received! Handle it! */
|
/*FIXME: network layer message received! Handle it! */
|
||||||
|
#if PRINT_ENABLED
|
||||||
|
fprintf(stderr,"NPDU: Network Layer Message discarded!\n");
|
||||||
|
#endif
|
||||||
} else if ((apdu_offset > 0) && (apdu_offset <= pdu_len)) {
|
} else if ((apdu_offset > 0) && (apdu_offset <= pdu_len)) {
|
||||||
/* only handle the version that we know how to handle */
|
/* only handle the version that we know how to handle */
|
||||||
if (npdu_data.protocol_version == BACNET_PROTOCOL_VERSION)
|
if (npdu_data.protocol_version == BACNET_PROTOCOL_VERSION)
|
||||||
|
|||||||
Reference in New Issue
Block a user