diff --git a/.github/workflows/gcc.yml b/.github/workflows/gcc.yml index d4e5e76c..8dbaee73 100644 --- a/.github/workflows/gcc.yml +++ b/.github/workflows/gcc.yml @@ -62,7 +62,7 @@ jobs: gcc --version make clean make LEGACY=true BBMD=client all - + gateway: runs-on: ubuntu-latest steps: @@ -127,7 +127,7 @@ jobs: run: | sudo apt-get update -qq sudo apt-get install -qq libconfig-dev - - name: Build BACnet/IPv6 Demos + - name: Build BACnet/IPv6 Demo Apps run: | gcc --version make clean @@ -141,7 +141,7 @@ jobs: run: | sudo apt-get update -qq sudo apt-get install -qq libconfig-dev - - name: Build MSTP Demos + - name: Build MSTP Demo Apps run: | gcc --version make clean @@ -155,7 +155,8 @@ jobs: run: | sudo apt-get update -qq sudo apt-get install -qq libconfig-dev - - name: Build Ethernet Demos + sudo apt-get install -qq libcap-dev + - name: Build Ethernet Demo Apps run: | gcc --version make clean @@ -195,7 +196,7 @@ jobs: arm-none-eabi-gcc --version make stm32f4xx-cmake make at91sam7s-cmake - + ports-avr: runs-on: ubuntu-latest steps: @@ -234,7 +235,7 @@ jobs: sudo apt-get update -qq sudo apt-get install -qq build-essential sudo apt-get install -qq mingw-w64 - - name: Build Win32 Demos + - name: Build Win32 Demo Apps run: | export CC=i686-w64-mingw32-gcc export LD=i686-w64-mingw32-ld diff --git a/.gitignore b/.gitignore index e67ed273..d3b11730 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ *.log *.a *.o +*.obj *.exe *.bak *~ diff --git a/CMakeLists.txt b/CMakeLists.txt index 83f7d676..50cb39c5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -597,6 +597,7 @@ elseif(WIN32) elseif(APPLE) message(STATUS "BACNET: building for APPLE") set(BACNET_PORT_DIRECTORY_PATH ${CMAKE_CURRENT_LIST_DIR}/ports/bsd) + add_compile_definitions(BACNET_PORT=bsd) target_sources(${PROJECT_NAME} PRIVATE ports/bsd/bacport.h @@ -617,7 +618,8 @@ elseif(${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD") endif() target_include_directories(${PROJECT_NAME} PUBLIC - $) + $ +) # # examples diff --git a/Makefile b/Makefile index 5e8bafcb..fe037d81 100644 --- a/Makefile +++ b/Makefile @@ -17,6 +17,17 @@ bsd: win32: $(MAKE) BACNET_PORT=win32 -s -C apps all +.PHONY: mingw32 +mingw32: + i686-w64-mingw32-gcc --version + ORIGINAL_CC=$(CC) ; \ + ORIGINAL_LD=$(LD) ; \ + export CC=i686-w64-mingw32-gcc ; \ + export LD=i686-w64-mingw32-ld ; \ + $(MAKE) BACNET_PORT=win32 -s -C apps all ; \ + export CC=$(ORIGINAL_CC) ; \ + export LD=$(ORIGINAL_LD) + .PHONY: mstpwin32 mstpwin32: $(MAKE) BACDL=mstp BACNET_PORT=win32 -s -C apps all @@ -85,10 +96,18 @@ apdu: blinkt: $(MAKE) -s -C apps $@ +.PHONY: create-object +create-object: + $(MAKE) -s -C apps $@ + .PHONY: dcc dcc: $(MAKE) -s -C apps $@ +.PHONY: delete-object +delete-object: + $(MAKE) -s -C apps $@ + .PHONY: epics epics: $(MAKE) -s -C apps $@ diff --git a/apps/Makefile b/apps/Makefile index 2cd26b5c..268ac228 100644 --- a/apps/Makefile +++ b/apps/Makefile @@ -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 $@ diff --git a/apps/ack-alarm/main.c b/apps/ack-alarm/main.c index 10898d0f..586205a2 100644 --- a/apps/ack-alarm/main.c +++ b/apps/ack-alarm/main.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; diff --git a/apps/add-list-element/main.c b/apps/add-list-element/main.c index ce419f6c..e0714d81 100644 --- a/apps/add-list-element/main.c +++ b/apps/add-list-element/main.c @@ -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"); diff --git a/apps/create-object/main.c b/apps/create-object/main.c index 0813eab1..67ba04ec 100644 --- a/apps/create-object/main.c +++ b/apps/create-object/main.c @@ -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, diff --git a/apps/dcc/main.c b/apps/dcc/main.c index 77c0ce49..aed455bf 100644 --- a/apps/dcc/main.c +++ b/apps/dcc/main.c @@ -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; diff --git a/apps/delete-object/main.c b/apps/delete-object/main.c index 236841f6..ebcb8923 100644 --- a/apps/delete-object/main.c +++ b/apps/delete-object/main.c @@ -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, diff --git a/apps/epics/main.c b/apps/epics/main.c index 7d73e82f..2b504b2d 100644 --- a/apps/epics/main.c +++ b/apps/epics/main.c @@ -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: diff --git a/apps/event/main.c b/apps/event/main.c index 911fba28..e8f44107 100644 --- a/apps/event/main.c +++ b/apps/event/main.c @@ -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; diff --git a/apps/getevent/main.c b/apps/getevent/main.c index b033d89b..48efa8c7 100644 --- a/apps/getevent/main.c +++ b/apps/getevent/main.c @@ -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; } diff --git a/apps/perl/perl_bindings.c b/apps/perl/perl_bindings.c index be6310b3..f382d16c 100644 --- a/apps/perl/perl_bindings.c +++ b/apps/perl/perl_bindings.c @@ -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; diff --git a/apps/ptransfer/main.c b/apps/ptransfer/main.c index d11ec410..e3a498dc 100644 --- a/apps/ptransfer/main.c +++ b/apps/ptransfer/main.c @@ -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; diff --git a/apps/readfile/main.c b/apps/readfile/main.c index 143aedb8..e5422859 100644 --- a/apps/readfile/main.c +++ b/apps/readfile/main.c @@ -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) { diff --git a/apps/readprop/main.c b/apps/readprop/main.c index a7461ce0..4378ccf4 100644 --- a/apps/readprop/main.c +++ b/apps/readprop/main.c @@ -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; diff --git a/apps/readpropm/main.c b/apps/readpropm/main.c index cbe222bc..5c8046ff 100644 --- a/apps/readpropm/main.c +++ b/apps/readpropm/main.c @@ -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; diff --git a/apps/readrange/main.c b/apps/readrange/main.c index fa959154..cfbe3bee 100644 --- a/apps/readrange/main.c +++ b/apps/readrange/main.c @@ -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; diff --git a/apps/reinit/main.c b/apps/reinit/main.c index 795acf36..a9395b36 100644 --- a/apps/reinit/main.c +++ b/apps/reinit/main.c @@ -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; diff --git a/apps/scov/main.c b/apps/scov/main.c index a04a0a95..7b0fd188 100644 --- a/apps/scov/main.c +++ b/apps/scov/main.c @@ -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; } diff --git a/apps/uptransfer/main.c b/apps/uptransfer/main.c index 94b0633e..2057e7f4 100644 --- a/apps/uptransfer/main.c +++ b/apps/uptransfer/main.c @@ -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; diff --git a/apps/writefile/main.c b/apps/writefile/main.c index 1b9fe06c..58f6f49d 100644 --- a/apps/writefile/main.c +++ b/apps/writefile/main.c @@ -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) { diff --git a/apps/writeprop/main.c b/apps/writeprop/main.c index fefbac60..7fc7d8a2 100644 --- a/apps/writeprop/main.c +++ b/apps/writeprop/main.c @@ -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; diff --git a/apps/writepropm/main.c b/apps/writepropm/main.c index b7ab9747..91ff26c2 100644 --- a/apps/writepropm/main.c +++ b/apps/writepropm/main.c @@ -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; diff --git a/ports/at91sam7s/CMakeLists.txt b/ports/at91sam7s/CMakeLists.txt index 43d41fce..1e562eb8 100644 --- a/ports/at91sam7s/CMakeLists.txt +++ b/ports/at91sam7s/CMakeLists.txt @@ -188,6 +188,7 @@ target_compile_definitions(${EXECUTABLE} PRIVATE -DPRINT_ENABLED=0 -DMAX_TSM_TRANSACTIONS=0 -DCRC_USE_TABLE + -DBACAPP_MINIMAL ) # inhibit pedantic warnings diff --git a/ports/at91sam7s/Makefile b/ports/at91sam7s/Makefile index 9a2eaa5f..d092d263 100644 --- a/ports/at91sam7s/Makefile +++ b/ports/at91sam7s/Makefile @@ -22,7 +22,7 @@ BACNET_FLAGS += -DMAX_OCTET_STRING_BYTES=64 BACNET_FLAGS += -DPRINT_ENABLED=0 BACNET_FLAGS += -DMAX_APDU=480 BACNET_FLAGS += -DCRC_USE_TABLE -#BACNET_FLAGS += -DDLMSTP_TEST +BACNET_FLAGS += -DBACAPP_MINIMAL ifeq (${LEGACY},true) # disable deprecated function warnings for legacy builds BACNET_FLAGS += -DBACNET_STACK_DEPRECATED_DISABLE diff --git a/ports/at91sam7s/bacnet.ewp b/ports/at91sam7s/bacnet.ewp index 9efa1d4a..095d006a 100644 --- a/ports/at91sam7s/bacnet.ewp +++ b/ports/at91sam7s/bacnet.ewp @@ -231,6 +231,7 @@ PRINT_ENABLED=0 MAX_APDU=480 CRC_USE_TABLE + BACAPP_MINIMAL