Chore/bacnet-sc-unrelated-cleanup (#620)
* Added required linux Ethernet library for ethernet build * Added .obj to gitignore * Fixed BACnet port for APPLE to use BSD in CMake * Changed format in CMake to enable cleaner SC merge * Added create-object and delete-object recipes in GCC Makefile * Added datalink timer to all example OS apps * Changed most microcontroller ports to use BACAPP_MINIMAL to specify which datatypes can be written. * Fixed zephyr OS for BACnet/IP warning * Fixed zephyr OS log to not require log_strdup * Added writefile API to file object example * Added API to device-client to make it more robust. * Added API in network-port object for getting the ASCII object-name * Added debug print with a timestamp option * Added debug print with hex dump print * Added API to network port object for activate and discard * Added default define for debug with timestamp * Added prototype in header for disabled debug printf. * Added fifo peek ahead function to peek at more than one byte. * Added get-mac value for network port that uses buffer rather than octetstring
This commit is contained in:
@@ -274,10 +274,18 @@ apdu: $(BACNET_LIB_TARGET)
|
||||
blinkt:
|
||||
$(MAKE) -C $@
|
||||
|
||||
.PHONY: create-object
|
||||
create-object: $(BACNET_LIB_TARGET)
|
||||
$(MAKE) -B -C $@
|
||||
|
||||
.PHONY: dcc
|
||||
dcc: $(BACNET_LIB_TARGET)
|
||||
$(MAKE) -B -C $@
|
||||
|
||||
.PHONY: delete-object
|
||||
delete-object: $(BACNET_LIB_TARGET)
|
||||
$(MAKE) -B -C $@
|
||||
|
||||
.PHONY: epics
|
||||
epics: $(BACNET_LIB_TARGET)
|
||||
$(MAKE) -B -C $@
|
||||
|
||||
@@ -390,6 +390,7 @@ int main(int argc, char *argv[])
|
||||
if (current_seconds != last_seconds) {
|
||||
tsm_timer_milliseconds(
|
||||
(uint16_t)((current_seconds - last_seconds) * 1000));
|
||||
datalink_maintenance_timer(current_seconds - last_seconds);
|
||||
}
|
||||
if (Error_Detected) {
|
||||
break;
|
||||
|
||||
@@ -464,6 +464,8 @@ int main(int argc, char *argv[])
|
||||
if (mstimer_expired(&maintenance_timer)) {
|
||||
mstimer_reset(&maintenance_timer);
|
||||
tsm_timer_milliseconds(mstimer_interval(&maintenance_timer));
|
||||
datalink_maintenance_timer(
|
||||
mstimer_interval(&maintenance_timer)/1000L);
|
||||
}
|
||||
if (mstimer_expired(&apdu_timer)) {
|
||||
printf("\rError: APDU Timeout!\n");
|
||||
|
||||
@@ -370,6 +370,8 @@ int main(int argc, char *argv[])
|
||||
if (mstimer_expired(&maintenance_timer)) {
|
||||
mstimer_reset(&maintenance_timer);
|
||||
tsm_timer_milliseconds(mstimer_interval(&maintenance_timer));
|
||||
datalink_maintenance_timer(
|
||||
mstimer_interval(&maintenance_timer)/1000L);
|
||||
}
|
||||
if (mstimer_expired(&apdu_timer)) {
|
||||
MyPrintHandler(Target_Object_Type, Target_Object_Instance,
|
||||
|
||||
@@ -244,6 +244,7 @@ int main(int argc, char *argv[])
|
||||
if (current_seconds != last_seconds) {
|
||||
tsm_timer_milliseconds(
|
||||
(uint16_t)((current_seconds - last_seconds) * 1000));
|
||||
datalink_maintenance_timer(current_seconds - last_seconds);
|
||||
}
|
||||
if (Error_Detected) {
|
||||
break;
|
||||
|
||||
@@ -331,6 +331,8 @@ int main(int argc, char *argv[])
|
||||
if (mstimer_expired(&maintenance_timer)) {
|
||||
mstimer_reset(&maintenance_timer);
|
||||
tsm_timer_milliseconds(mstimer_interval(&maintenance_timer));
|
||||
datalink_maintenance_timer(
|
||||
mstimer_interval(&maintenance_timer)/1000L);
|
||||
}
|
||||
if (mstimer_expired(&apdu_timer)) {
|
||||
MyPrintHandler(ERROR_CLASS_COMMUNICATION,
|
||||
|
||||
+1
-1
@@ -1522,8 +1522,8 @@ int main(int argc, char *argv[])
|
||||
if (current_seconds != last_seconds) {
|
||||
tsm_timer_milliseconds(
|
||||
(uint16_t)((current_seconds - last_seconds) * 1000));
|
||||
datalink_maintenance_timer(current_seconds - last_seconds);
|
||||
}
|
||||
|
||||
/* OK to proceed; see what we are up to now */
|
||||
switch (myState) {
|
||||
case INITIAL_BINDING:
|
||||
|
||||
+1
-1
@@ -584,11 +584,11 @@ int main(int argc, char *argv[])
|
||||
for (;;) {
|
||||
/* increment timer - exit if timed out */
|
||||
current_seconds = time(NULL);
|
||||
|
||||
/* at least one second has passed */
|
||||
if (current_seconds != last_seconds) {
|
||||
tsm_timer_milliseconds(
|
||||
(uint16_t)((current_seconds - last_seconds) * 1000));
|
||||
datalink_maintenance_timer(current_seconds - last_seconds);
|
||||
}
|
||||
if (Error_Detected) {
|
||||
break;
|
||||
|
||||
@@ -237,8 +237,8 @@ int main(int argc, char *argv[])
|
||||
if (current_seconds != last_seconds) {
|
||||
tsm_timer_milliseconds(
|
||||
(uint16_t)((current_seconds - last_seconds) * 1000));
|
||||
datalink_maintenance_timer(current_seconds - last_seconds);
|
||||
}
|
||||
|
||||
if (Error_Detected) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -418,29 +418,25 @@ static void Wait_For_Answer_Or_Timeout(unsigned timeout_ms, waitAction action)
|
||||
|
||||
while (true) {
|
||||
time_t current_seconds = time(NULL);
|
||||
|
||||
/* If error was detected then bail out */
|
||||
if (Error_Detected) {
|
||||
LogError("Some other error occurred");
|
||||
break;
|
||||
}
|
||||
|
||||
if (elapsed_seconds > timeout_seconds) {
|
||||
LogError("APDU Timeout");
|
||||
break;
|
||||
}
|
||||
|
||||
/* Process PDU if one comes in */
|
||||
pdu_len = datalink_receive(&src, &Rx_Buf[0], MAX_MPDU, timeout_ms);
|
||||
if (pdu_len) {
|
||||
npdu_handler(&src, &Rx_Buf[0], pdu_len);
|
||||
}
|
||||
|
||||
/* at least one second has passed */
|
||||
if (current_seconds != last_seconds) {
|
||||
tsm_timer_milliseconds(((current_seconds - last_seconds) * 1000));
|
||||
datalink_maintenance_timer(current_seconds - last_seconds);
|
||||
}
|
||||
|
||||
if (action == waitAnswer) {
|
||||
/* Response was received. Exit. */
|
||||
if (tsm_invoke_id_free(Request_Invoke_ID)) {
|
||||
@@ -459,7 +455,6 @@ static void Wait_For_Answer_Or_Timeout(unsigned timeout_ms, waitAction action)
|
||||
LogError("Invalid waitAction requested");
|
||||
break;
|
||||
}
|
||||
|
||||
/* Keep track of time */
|
||||
elapsed_seconds += (current_seconds - last_seconds);
|
||||
last_seconds = current_seconds;
|
||||
|
||||
@@ -268,7 +268,6 @@ int main(int argc, char *argv[])
|
||||
|
||||
/* returns 0 bytes on timeout */
|
||||
pdu_len = datalink_receive(&src, &Rx_Buf[0], MAX_MPDU, timeout);
|
||||
|
||||
/* process */
|
||||
if (pdu_len) {
|
||||
npdu_handler(&src, &Rx_Buf[0], pdu_len);
|
||||
@@ -279,8 +278,8 @@ int main(int argc, char *argv[])
|
||||
last_seconds = current_seconds;
|
||||
tsm_timer_milliseconds(
|
||||
((current_seconds - last_seconds) * 1000));
|
||||
datalink_maintenance_timer(current_seconds - last_seconds);
|
||||
}
|
||||
|
||||
if (_kbhit()) {
|
||||
iKey = toupper(_getch());
|
||||
if (iKey == 'Q') {
|
||||
@@ -313,6 +312,7 @@ int main(int argc, char *argv[])
|
||||
if (current_seconds != last_seconds) {
|
||||
tsm_timer_milliseconds(
|
||||
((current_seconds - last_seconds) * 1000));
|
||||
datalink_maintenance_timer(current_seconds - last_seconds);
|
||||
}
|
||||
if (Error_Detected) {
|
||||
break;
|
||||
|
||||
@@ -338,6 +338,7 @@ int main(int argc, char *argv[])
|
||||
/* at least one second has passed */
|
||||
if (current_seconds != last_seconds) {
|
||||
tsm_timer_milliseconds(((current_seconds - last_seconds) * 1000));
|
||||
datalink_maintenance_timer(current_seconds - last_seconds);
|
||||
}
|
||||
/* wait until the device is bound, or timeout and quit */
|
||||
if (!found) {
|
||||
|
||||
@@ -194,8 +194,8 @@ static void print_help(char *filename)
|
||||
"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");
|
||||
"or an Ethernet MAC in hex like 00:21:70:7e:32:bb\n");
|
||||
printf("\n");
|
||||
printf("device-instance:\n"
|
||||
"BACnet Device Object Instance number that you are\n"
|
||||
"trying to communicate to. This number will be used\n"
|
||||
@@ -417,6 +417,7 @@ int main(int argc, char *argv[])
|
||||
if (current_seconds != last_seconds) {
|
||||
tsm_timer_milliseconds(
|
||||
(uint16_t)((current_seconds - last_seconds) * 1000));
|
||||
datalink_maintenance_timer(current_seconds - last_seconds);
|
||||
}
|
||||
if (Error_Detected) {
|
||||
break;
|
||||
|
||||
@@ -535,6 +535,7 @@ int main(int argc, char *argv[])
|
||||
/* at least one second has passed */
|
||||
if (current_seconds != last_seconds) {
|
||||
tsm_timer_milliseconds(((current_seconds - last_seconds) * 1000));
|
||||
datalink_maintenance_timer(current_seconds - last_seconds);
|
||||
}
|
||||
if (Error_Detected) {
|
||||
break;
|
||||
|
||||
@@ -368,6 +368,7 @@ int main(int argc, char *argv[])
|
||||
if (current_seconds != last_seconds) {
|
||||
tsm_timer_milliseconds(
|
||||
(uint16_t)((current_seconds - last_seconds) * 1000));
|
||||
datalink_maintenance_timer(current_seconds - last_seconds);
|
||||
}
|
||||
if (Error_Detected) {
|
||||
break;
|
||||
|
||||
@@ -204,6 +204,7 @@ int main(int argc, char *argv[])
|
||||
/* at least one second has passed */
|
||||
if (current_seconds != last_seconds) {
|
||||
tsm_timer_milliseconds(((current_seconds - last_seconds) * 1000));
|
||||
datalink_maintenance_timer(current_seconds - last_seconds);
|
||||
}
|
||||
if (Error_Detected) {
|
||||
break;
|
||||
|
||||
@@ -360,6 +360,7 @@ int main(int argc, char *argv[])
|
||||
delta_seconds = current_seconds - last_seconds;
|
||||
elapsed_seconds += delta_seconds;
|
||||
tsm_timer_milliseconds((delta_seconds * 1000));
|
||||
datalink_maintenance_timer(delta_seconds);
|
||||
/* keep track of time for next check */
|
||||
last_seconds = current_seconds;
|
||||
}
|
||||
|
||||
@@ -314,7 +314,8 @@ int main(int argc, char *argv[])
|
||||
/* increment timer - exit if timed out */
|
||||
delta_seconds = current_seconds - last_seconds;
|
||||
elapsed_seconds += delta_seconds;
|
||||
tsm_timer_milliseconds(((current_seconds - last_seconds) * 1000));
|
||||
tsm_timer_milliseconds(delta_seconds * 1000);
|
||||
datalink_maintenance_timer(delta_seconds);
|
||||
}
|
||||
if (Error_Detected) {
|
||||
break;
|
||||
|
||||
@@ -222,6 +222,7 @@ int main(int argc, char *argv[])
|
||||
/* at least one second has passed */
|
||||
if (current_seconds != last_seconds) {
|
||||
tsm_timer_milliseconds(((current_seconds - last_seconds) * 1000));
|
||||
datalink_maintenance_timer(current_seconds - last_seconds);
|
||||
}
|
||||
/* wait until the device is bound, or timeout and quit */
|
||||
if (!found) {
|
||||
|
||||
@@ -427,6 +427,7 @@ int main(int argc, char *argv[])
|
||||
if (current_seconds != last_seconds) {
|
||||
tsm_timer_milliseconds(
|
||||
(uint16_t)((current_seconds - last_seconds) * 1000));
|
||||
datalink_maintenance_timer(current_seconds - last_seconds);
|
||||
}
|
||||
if (Error_Detected) {
|
||||
break;
|
||||
|
||||
@@ -505,6 +505,7 @@ int main(int argc, char *argv[])
|
||||
/* at least one second has passed */
|
||||
if (current_seconds != last_seconds) {
|
||||
tsm_timer_milliseconds(((current_seconds - last_seconds) * 1000));
|
||||
datalink_maintenance_timer(current_seconds - last_seconds);
|
||||
}
|
||||
if (Error_Detected) {
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user