Menu

Help compiling (I am reletively noob-ish)

Help
2022-05-08
2022-08-14
  • Lance Tollenaar

    Lance Tollenaar - 2022-05-08

    Hi Steve and team,

    After cloning the master repo I cannot for the life of me get anything to compile.

    I remember a few months ago I managed to get the demo apps to compile into .exe files for windows, but after cleaning my machine and re-cloning the repo I can't even do that. I remember I mucked around editing the makefiles directly, I'm sure that's the wrong way to go about it.

    My ultimate goal is to get the Arduino Uno port working, then transition everything to a Microchip Studio project for AVR devices.

    I have MinGW/MSYS2 installed, with a whole bunch of the w64_x86 packages/tool chains installed, and a whole bunch of pacman -Syu commands etc. to get everything up to date.

    My PATH variable has C:\msys64\mingw64\include and C:\msys64\usr\include added.

    The initial error was something about asm/types.h couldn't be found, but this was to do with the linux port which I don't car about at the moment, so just deleting that folder made that error go away.

    Now I run build.bat from the bacnet-stack root, I get:

    C:\Users\lance\OneDrive\Documents\GitHub\bacnet-stack>build.bat
    Build with MinGW and MSYS: mingw.sourceforge.net
    make -s -C ports/atmega168 clean
    The system cannot find the path specified.
    make -s -C ports/bdk-atxx4-mstp clean
    The system cannot find the path specified.
    make -s -C ports/at91sam7s clean
    The system cannot find the path specified.
    make -s -C ports/stm32f10x clean
    The system cannot find the path specified.
    make -s -C ports/stm32f4xx clean
    The system cannot find the path specified.
    make -s -C src clean
    make -s -C apps clean
    process_begin: CreateProcess(NULL, uname -s, ...) failed.
    make -s -C apps/router clean
    make -s -C apps/router-ipv6 clean
    make -s -C apps/router-mstp clean
    make -s -C apps/gateway clean
    make -s -C ports/lwip clean
    make -s -C test clean
    rm -rf ./build
    make -s -C apps all
    process_begin: CreateProcess(NULL, uname -s, ...) failed.
    In file included from C:/Users/lance/OneDrive/Documents/GitHub/bacnet-stack/ports/win32/bip-init.c:46:
    C:/Users/lance/OneDrive/Documents/GitHub/bacnet-stack/ports/win32/bacport.h:76:10: warning: 'timezone' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
       76 | long int timezone;
          |          ^~~~~~~~
    In file included from C:/Users/lance/OneDrive/Documents/GitHub/bacnet-stack/ports/win32/mstimer-init.c:32:
    C:/Users/lance/OneDrive/Documents/GitHub/bacnet-stack/ports/win32/bacport.h:76:10: warning: 'timezone' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
       76 | long int timezone;
          |          ^~~~~~~~
    In file included from C:/Users/lance/OneDrive/Documents/GitHub/bacnet-stack/ports/win32/datetime-init.c:18:
    C:/Users/lance/OneDrive/Documents/GitHub/bacnet-stack/ports/win32/bacport.h:76:10: warning: 'timezone' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
       76 | long int timezone;
          |          ^~~~~~~~
    In file included from main.c:49:
    C:/Users/lance/OneDrive/Documents/GitHub/bacnet-stack/ports/win32/bacport.h:76:10: warning: 'timezone' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
       76 | long int timezone;
          |          ^~~~~~~~
    In file included from C:/Users/lance/OneDrive/Documents/GitHub/bacnet-stack/src/bacnet/basic/object/client/device-client.c:35:
    C:/Users/lance/OneDrive/Documents/GitHub/bacnet-stack/ports/win32/bacport.h:76:10: warning: 'timezone' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
       76 | long int timezone;
          |          ^~~~~~~~
    C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/lance/OneDrive/Documents/GitHub/bacnet-stack/src/bacnet/basic/object/client/device-client.o:device-client.:(.data$timezone+0x0): multiple definition of `timezone'; main.o:main.c:(.data$timezone+0x0): first defined here
    C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/lance/OneDrive/Documents/GitHub/bacnet-stack/apps/lib/libbacnet.a(bip-init.o):bip-init.c:(.data$timezone+0x0): multiple definition of `timezone'; main.o:main.c:(.data$timezone+0x0): first defined here
    C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/lance/OneDrive/Documents/GitHub/bacnet-stack/apps/lib/libbacnet.a(datetime-init.o):datetime-init.:(.data$timezone+0x0): multiple definition of `timezone'; main.o:main.c:(.data$timezone+0x0): first defined here
    collect2.exe: error: ld returned 1 exit status
    make[2]: *** [bacrp.exe] Error 1
    make[1]: *** [readprop.all] Error 2
    make: *** [apps] Error 2
    
    C:\Users\lance\OneDrive\Documents\GitHub\bacnet-stack>
    

    if I just run directly the command make clean all I get:

    C:\Users\lance\OneDrive\Documents\GitHub\bacnet-stack>make clean all
    make -s -C ports/atmega168 clean
    The system cannot find the path specified.
    make -s -C ports/bdk-atxx4-mstp clean
    The system cannot find the path specified.
    make -s -C ports/at91sam7s clean
    The system cannot find the path specified.
    make -s -C ports/stm32f10x clean
    The system cannot find the path specified.
    make -s -C ports/stm32f4xx clean
    The system cannot find the path specified.
    make -s -C src clean
    make -s -C apps clean
    process_begin: CreateProcess(NULL, uname -s, ...) failed.
    make -s -C apps/router clean
    make -s -C apps/router-ipv6 clean
    make -s -C apps/router-mstp clean
    make -s -C apps/gateway clean
    make -s -C ports/lwip clean
    make -s -C test clean
    rm -rf ./build
    make -s -C apps all
    process_begin: CreateProcess(NULL, uname -s, ...) failed.
    make[2]: *** No rule to make target `/bip-init.o', needed by `C:/Users/lance/OneDrive/Documents/GitHub/bacnet-stack/apps/lib/libbacnet.a'.  Stop.
    make[1]: *** [lib.all] Error 2
    make: *** [apps] Error 2
    
    C:\Users\lance\OneDrive\Documents\GitHub\bacnet-stack>
    

    but I assume that's something to do with not setting the BACNET_PORT variable, as the .bat does?

    Further, I can't even see how you would compile the arduino port. Would you please be able to point me in the right direction here?

    Do I need to setup some config files or something?

    Do I have MinGW installed incorrectly or some packages missing? Maybe I should try MinGW32 instead of 64?

    Sorry I'm a bit of a noob, I'm used to a nice IDE and just hitting the "upload" button... hahaha

     
  • Steve Karg

    Steve Karg - 2022-05-09

    The apps/Makefile does some substitution for the targeted ports/ folder files, and needs a bit of help to compile on a native setup (can also be used to cross-compile). I created a 'win32' target in the root makefile to accomplish this on Windows. Traditionally, Makefile are used on POSIX systems (Linux, BSD, etc), so the default 'make' without tweaking only works on POSIX.

    To build the example command line applications for BACnet/IP under Windows use git bash.
    git bash: https://git-scm.com/downloads
    $ make win32

    Unfortunately, I have not kept the Makefile builds working under Windows command line and Power Shell (not sure what I broke from 0.8.x branch)

     
  • Steve Karg

    Steve Karg - 2022-05-09

    re: arduino port - hasn't been kept up to date since it's contribution by Miguel Fernandes - sorry!

     
  • Lance Tollenaar

    Lance Tollenaar - 2022-05-12

    Hi Steve,

    Thanks for your reply, I appreciate you taking the time to answer my question.

    Unfortunately I could not get the Git bash shell to do anything different from CMD.exe or MinGW64 on my machine - still the same complaint about timezone being declared in multiple places.

    Then I faffed around with the PATH variable, and removed the mingw64\bin folder... now "make" is pointing to usr\bin\make.exe? Then I get the following gobbledegook:

    $ make win32
    make BACNET_PORT=win32 -s -C apps all
    In file included from /C/users/lance/OneDrive/Documents/GitHub/bacnet-stack/src/bacnet/bacstr.c:40:
    /C/users/lance/OneDrive/Documents/GitHub/bacnet-stack/src/bacnet/bacstr.c: In function octetstring_init_ascii_hex’:
    /C/users/lance/OneDrive/Documents/GitHub/bacnet-stack/src/bacnet/bacstr.c:1014:39: warning: array subscript has type char [-Wchar-subscripts]
     1014 |                 if (!isalnum(ascii_hex[index])) {
          |                              ~~~~~~~~~^~~~~~~
    In file included from /usr/include/w32api/winsock2.h:56,
                     from /C/users/lance/OneDrive/Documents/GitHub/bacnet-stack/ports/win32/bacport.h:49,
                     from main.c:49:
    /usr/include/w32api/psdk_inc/_fd_types.h:100:2: warning: #warning "fd_set and associated macros have been defined in sys/types.      This can cause runtime problems with W32 sockets" [-Wcpp]
      100 | #warning "fd_set and associated macros have been defined in sys/types.  \
          |  ^~~~~~~
    In file included from /C/users/lance/OneDrive/Documents/GitHub/bacnet-stack/ports/win32/bacport.h:49,
                     from main.c:49:
    /usr/include/w32api/winsock2.h:1031:34: error: conflicting types for ‘select’; have ‘int(int,  fd_set *, fd_set *, fd_set *, struct __ms_timeval * const)’
     1031 |   WINSOCK_API_LINKAGE int WSAAPI select(int nfds,fd_set *readfds,fd_set *writefds,fd_set *exceptfds,const PTIMEVAL timeout);
          |                                  ^~~~~~
    In file included from /usr/include/sys/types.h:50,
                     from /usr/include/stdio.h:61,
                     from main.c:28:
    /usr/include/sys/select.h:76:5: note: previous declaration of ‘select’ with type ‘int(int,  fd_set *, fd_set *, fd_set *, struct timeval *)’
       76 | int select __P ((int __n, fd_set *__readfds, fd_set *__writefds,
          |     ^~~~~~
    In file included from main.c:49:
    /C/users/lance/OneDrive/Documents/GitHub/bacnet-stack/ports/win32/bacport.h:62: warning: ignoring ‘#pragma warning ’ [-Wunknown-pragmas]
       62 | #pragma warning(disable : 4996)
          |
    /C/users/lance/OneDrive/Documents/GitHub/bacnet-stack/ports/win32/bacport.h:64: warning: ignoring ‘#pragma comment ’ [-Wunknown-pragmas]
       64 | #pragma comment(lib, "winmm.lib")
          |
    make[2]: *** [Makefile:27: main.o] Error 1
    make[1]: *** [Makefile:163: readprop.all] Error 2
    make: *** [Makefile:18: win32] Error 2
    

    So I'm assuming I'm just an idiot for trying to use gcc on Windows? Maybe I'll get my act together and get a Linux dual boot going at some point... haha

    However, on a more positive note I was able to compile the atmega168 port:

    $ make atmega168
    make -s -C ports/atmega168 clean all
    ../../src/bacnet/bacreal.c: In function 'encode_bacnet_double':
    ../../src/bacnet/bacreal.c:180:31: warning: 'my_data.byte[7]' is used uninitialized in this function [-Wuninitialized]
             apdu[0] = my_data.byte[7];
                       ~~~~~~~~~~~~^~~
    ../../src/bacnet/bacreal.c:181:31: warning: 'my_data.byte[6]' is used uninitialized in this function [-Wuninitialized]
             apdu[1] = my_data.byte[6];
                       ~~~~~~~~~~~~^~~
    ../../src/bacnet/bacreal.c:182:31: warning: 'my_data.byte[5]' is used uninitialized in this function [-Wuninitialized]
             apdu[2] = my_data.byte[5];
                       ~~~~~~~~~~~~^~~
    ../../src/bacnet/bacreal.c:183:31: warning: 'my_data.byte[4]' is used uninitialized in this function [-Wuninitialized]
             apdu[3] = my_data.byte[4];
                       ~~~~~~~~~~~~^~~
    device.c: In function 'Device_Read_Property':
    device.c:315:9: warning: case value '513' not in enumerated type 'BACNET_PROPERTY_ID' {aka 'enum <anonymous>'} [-Wswitch]
             case (BACNET_PROPERTY_ID)513:
             ^~~~
    device.c:308:9: warning: case value '9600' not in enumerated type 'BACNET_PROPERTY_ID' {aka 'enum <anonymous>'} [-Wswitch]
             case (BACNET_PROPERTY_ID)9600:
             ^~~~
    device.c: In function 'Device_Write_Property':
    device.c:435:9: warning: case value '9600' not in enumerated type 'BACNET_PROPERTY_ID' {aka 'enum <anonymous>'} [-Wswitch]
             case (BACNET_PROPERTY_ID)9600:
             ^~~~
    
       text    data     bss     dec     hex filename
      20246     114     347   20707    50e3 bacnet.elf
    

    There is also a nice Atmel project file there that miraculously opened on my machine OK. I was able to get the project building & writing to my Arduino Uno using avrdude. I have it half working (using "MS/TP", except really it's just a USB cable to the Uno... I guess the Uno's USB chip kind of takes the place of a serial-to-COM port adapter in this case, haha) - the device is discovered but I can't read any properties & Yabe reports a lot of garbage data... see attached image if you're interested.

    I think from here I'll be able to bring in the IP datalink & WizNet5100 libraries & get it working on BACnet/IP myself :)

    I may come back and ask you for help at some point, if that's OK!

    Cheers
    Lance

     
  • Steve Karg

    Steve Karg - 2022-05-12

    Sometimes I make changes in my environment and forget that others cannot follow that. I checked my git bash .bashrc file:

    $ cat ~/.bashrc
    alias make=mingw32-make.exe
    PATH=/c/MinGW/bin:$PATH
    export MAKE=mingw32-make.exe
    export CC=mingw32-gcc.exe
    export OBJCOPY=objcopy.exe
    export AR=ar.exe
    export SIZE=size.exe
    

    I probably ended up force-using mingw32 after spending days trying to get mingw64 to do the same. Does that get win32 to compile for you?

     
  • Lance Tollenaar

    Lance Tollenaar - 2022-05-13

    Ah ha. From Microsoft's documentation: "You cannot run a doskey macro from a batch program"

    Not to worry, what I did here is make a copy of mingw32-make.exe and call it make.exe.

    Then I had to modify the files as follows - adding the x86_64-w64- prefix to the binaries:

    build.bat:

    @echo off
    echo Build with MinGW32 and MSYS: mingw.sourceforge.net
    set PATH=C:\msys64\mingw64\bin;%PATH%
    rem assumes rm, cp, size are already in path
    set CC=x86_64-w64-mingw32-gcc.exe
    set AR=x86_64-w64-mingw32-gcc-ar.exe
    set NM=x86_64-w64-mingw32-gcc-nm.exe
    set OBJCOPY=objcopy.exe
    set SIZE=size.exe
    set MAKE=make.exe
    
    rem doskey make=mingw32-make.exe $*
    
    make BACNET_PORT=win32 clean
    make BACNET_PORT=win32 BUILD=release clean all
    
    rem Build for MinGW debug
    rem make BACNET_PORT=win32 BUILD=debug clean all
    
    rem Build for MinGW MS/TP
    rem make BACNET_PORT=win32 BACDL_DEFINE=-DBACDL_MSTP=1 clean all
    rem make BACNET_PORT=win32 BACDL_DEFINE=-DBACDL_BIP6=1 clean all
    
    rem On Linux, install mingw32 and use this:
    rem make BACNET_PORT=win32 CC=i586-mingw32msvc-gcc AR=i586-mingw32msvc-ar clean all
    

    build.sh:

    #!/bin/sh
    
    alias make=mingw32-make.exe
    PATH=/c/msys64/mingw64/bin:$PATH
    export MAKE=mingw32-make.exe
    #export CC=mingw32-gcc.exe
    export OBJCOPY=objcopy.exe
    #export AR=ar.exe
    #export SIZE=size.exe
    export CC=x86_64-w64-mingw32-gcc.exe
    export AR=x86_64-w64-mingw32-gcc-ar.exe
    export NM=x86_64-w64-mingw32-gcc-nm.exe
    
    #make clean
    #make all
    
    make BACNET_PORT=win32 clean
    make BACNET_PORT=win32 BUILD=release clean all
    

    It seems like I got a whole lot further this time! However, after half of the .o files were created, it STILL crashed... don't panic - keep reading! ...with the following error, again, complaining apout multiple definitions of timezone:

    lance.t@WGTNLAP06 MINGW64 /c/users/lance.t/source/GitHub/BACSTACK_C/bacnet-stack
    $ ./build.sh
    mingw32-make.exe -s -C ports/atmega168 clean
    mingw32-make.exe -s -C ports/bdk-atxx4-mstp clean
    mingw32-make.exe -s -C ports/at91sam7s clean
    mingw32-make.exe -s -C ports/stm32f10x clean
    mingw32-make.exe -s -C ports/stm32f4xx clean
    mingw32-make.exe -s -C src clean
    mingw32-make.exe -s -C apps clean
    mingw32-make.exe -s -C apps/router clean
    mingw32-make.exe -s -C apps/router-ipv6 clean
    mingw32-make.exe -s -C apps/router-mstp clean
    mingw32-make.exe -s -C apps/gateway clean
    mingw32-make.exe -s -C ports/lwip clean
    mingw32-make.exe -s -C test clean
    rm -rf ./build
    mingw32-make.exe -s -C ports/atmega168 clean
    mingw32-make.exe -s -C ports/bdk-atxx4-mstp clean
    mingw32-make.exe -s -C ports/at91sam7s clean
    mingw32-make.exe -s -C ports/stm32f10x clean
    mingw32-make.exe -s -C ports/stm32f4xx clean
    mingw32-make.exe -s -C src clean
    mingw32-make.exe -s -C apps clean
    mingw32-make.exe -s -C apps/router clean
    mingw32-make.exe -s -C apps/router-ipv6 clean
    mingw32-make.exe -s -C apps/router-mstp clean
    mingw32-make.exe -s -C apps/gateway clean
    mingw32-make.exe -s -C ports/lwip clean
    mingw32-make.exe -s -C test clean
    rm -rf ./build
    mingw32-make.exe -s -C apps all
    In file included from C:/users/lance.t/source/GitHub/BACSTACK_C/bacnet-stack/ports/win32/bip-init.c:46:
    C:/users/lance.t/source/GitHub/BACSTACK_C/bacnet-stack/ports/win32/bacport.h:76:10: warning: 'timezone' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
       76 | long int timezone;
          |          ^~~~~~~~
    In file included from C:/users/lance.t/source/GitHub/BACSTACK_C/bacnet-stack/ports/win32/mstimer-init.c:32:
    C:/users/lance.t/source/GitHub/BACSTACK_C/bacnet-stack/ports/win32/bacport.h:76:10: warning: 'timezone' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
       76 | long int timezone;
          |          ^~~~~~~~
    In file included from C:/users/lance.t/source/GitHub/BACSTACK_C/bacnet-stack/ports/win32/datetime-init.c:18:
    C:/users/lance.t/source/GitHub/BACSTACK_C/bacnet-stack/ports/win32/bacport.h:76:10: warning: 'timezone' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
       76 | long int timezone;
          |          ^~~~~~~~
    In file included from main.c:49:
    C:/users/lance.t/source/GitHub/BACSTACK_C/bacnet-stack/ports/win32/bacport.h:76:10: warning: 'timezone' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
       76 | long int timezone;
          |          ^~~~~~~~
    In file included from C:/users/lance.t/source/GitHub/BACSTACK_C/bacnet-stack/src/bacnet/basic/object/client/device-client.c:35:
    C:/users/lance.t/source/GitHub/BACSTACK_C/bacnet-stack/ports/win32/bacport.h:76:10: warning: 'timezone' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
       76 | long int timezone;
          |          ^~~~~~~~
    C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/users/lance.t/source/GitHub/BACSTACK_C/bacnet-stack/src/bacnet/basic/object/client/device-client.o:device-client.:(.data$timezone+0x0): multiple definition of `timezone'; main.o:main.c:(.data$timezone+0x0): first defined here
    C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/users/lance.t/source/GitHub/BACSTACK_C/bacnet-stack/apps/lib/libbacnet.a(bip-init.o):bip-init.c:(.data$timezone+0x0): multiple definition of `timezone'; main.o:main.c:(.data$timezone+0x0): first defined here
    C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/users/lance.t/source/GitHub/BACSTACK_C/bacnet-stack/apps/lib/libbacnet.a(datetime-init.o):datetime-init.:(.data$timezone+0x0): multiple definition of `timezone'; main.o:main.c:(.data$timezone+0x0): first defined here
    collect2.exe: error: ld returned 1 exit status
    mingw32-make[2]: *** [Makefile:19: bacrp.exe] Error 1
    mingw32-make[1]: *** [Makefile:163: readprop.all] Error 2
    mingw32-make: *** [Makefile:42: apps] Error 2
    

    So actually, the solution was to comment out the line long int timezone; in bacport.h and datetime-init.h in the win32 port folder! Judging by the comments around that line, it was added in as a hack to get around some error with time.h, which now appears fixed.

    lance.t@WGTNLAP06 MINGW64 /c/users/lance.t/source/GitHub/BACSTACK_C/bacnet-stack
    $ ./build.sh
    mingw32-make.exe -s -C ports/atmega168 clean
    mingw32-make.exe -s -C ports/bdk-atxx4-mstp clean
    mingw32-make.exe -s -C ports/at91sam7s clean
    mingw32-make.exe -s -C ports/stm32f10x clean
    mingw32-make.exe -s -C ports/stm32f4xx clean
    mingw32-make.exe -s -C src clean
    mingw32-make.exe -s -C apps clean
    mingw32-make.exe -s -C apps/router clean
    mingw32-make.exe -s -C apps/router-ipv6 clean
    mingw32-make.exe -s -C apps/router-mstp clean
    mingw32-make.exe -s -C apps/gateway clean
    mingw32-make.exe -s -C ports/lwip clean
    mingw32-make.exe -s -C test clean
    rm -rf ./build
    mingw32-make.exe -s -C ports/atmega168 clean
    mingw32-make.exe -s -C ports/bdk-atxx4-mstp clean
    mingw32-make.exe -s -C ports/at91sam7s clean
    mingw32-make.exe -s -C ports/stm32f10x clean
    mingw32-make.exe -s -C ports/stm32f4xx clean
    mingw32-make.exe -s -C src clean
    mingw32-make.exe -s -C apps clean
    mingw32-make.exe -s -C apps/router clean
    mingw32-make.exe -s -C apps/router-ipv6 clean
    mingw32-make.exe -s -C apps/router-mstp clean
    mingw32-make.exe -s -C apps/gateway clean
    mingw32-make.exe -s -C ports/lwip clean
    mingw32-make.exe -s -C test clean
    rm -rf ./build
    mingw32-make.exe -s -C apps all
       text    data     bss     dec     hex filename
     213540  425556    3168  642264   9ccd8 bacrp.exe
       text    data     bss     dec     hex filename
     213776  521364    3168  738308   b4404 bacwp.exe
       text    data     bss     dec     hex filename
     212016  425616    3168  640800   9c720 bacarf.exe
       text    data     bss     dec     hex filename
     210248  427132    3168  640548   9c624 bacawf.exe
       text    data     bss     dec     hex filename
     209392  425492    3168  638052   9bc64 bacrd.exe
       text    data     bss     dec     hex filename
     356692 1229216    3168 1589076  183f54 bacserv.exe
       text    data     bss     dec     hex filename
     210976  425524    3168  639668   9c2b4 bacdcc.exe
       text    data     bss     dec     hex filename
     209720  425492    3168  638380   9bdac bacwh.exe
       text    data     bss     dec     hex filename
     211248  425688    3168  640104   9c468 bacwi.exe
       text    data     bss     dec     hex filename
     209184  425432    3168  637784   9bb58 baciam.exe
       text    data     bss     dec     hex filename
     215020  423832    3168  642020   9cbe4 bacucov.exe
       text    data     bss     dec     hex filename
     218152  425556    3168  646876   9dedc bacscov.exe
       text    data     bss     dec     hex filename
     212416  426168    3168  641752   9cad8 bacts.exe
       text    data     bss     dec     hex filename
     244812  426576    3168  674556   a4afc bacepics.exe
       text    data     bss     dec     hex filename
     217088  425524    3168  645780   9da94 bacrpm.exe
       text    data     bss     dec     hex filename
     214744  425652    3168  643564   9d1ec bacrr.exe
       text    data     bss     dec     hex filename
     215680  425540    3168  644388   9d524 bacwpm.exe
       text    data     bss     dec     hex filename
     213016  522804    3168  738988   b46ac bacupt.exe
       text    data     bss     dec     hex filename
     211524  433844    3168  648536   9e558 bacge.exe
       text    data     bss     dec     hex filename
     215868  423860    3168  642896   9cf50 bacuevent.exe
       text    data     bss     dec     hex filename
     208072  423896    3168  635136   9b100 bacabort.exe
       text    data     bss     dec     hex filename
     208180  423896    3168  635244   9b16c bacerror.exe
       text    data     bss     dec     hex filename
     219868  425524    3168  648560   9e570 bacevent.exe
       text    data     bss     dec     hex filename
     213808  425524    3168  642500   9cdc4 bacackalarm.exe
       text    data     bss     dec     hex filename
     208884  425460    3168  637512   9ba48 bacwir.exe
       text    data     bss     dec     hex filename
     207884  424088    3168  635140   9b104 baciamr.exe
       text    data     bss     dec     hex filename
     209248  425460    3168  637876   9bbb4 bacinitr.exe
       text    data     bss     dec     hex filename
     207284  425428    3168  635880   9b3e8 bacrbdt.exe
       text    data     bss     dec     hex filename
     207252  425428    3168  635848   9b3c8 bacrfdt.exe
       text    data     bss     dec     hex filename
     208024  428500    3168  639692   9c2cc bacwbdt.exe
       text    data     bss     dec     hex filename
     111988   30636    3168  145792   23980 mstpcap.exe
       text    data     bss     dec     hex filename
      36632    8788    2912   48332    bccc mstpcrc.exe
    

    using set BACNET_IFACE=xxx.xxx.xxx.xxx and baciam.exe 1111 from command prompt, I see the entry pop into Yabe, as expected.

    Thanks for your help!

     
  • Lance Tollenaar

    Lance Tollenaar - 2022-05-29

    Update for those interested,

    Got BACnet MS/TP working on an Arduino Uno using a Microchip Studio project with AVRDUDE setup as an External Tool, and the ATMega168 port in the ports folder.

    Without an RS485 line driver there is garbage on the data lines, as the code sends 4 octets of 0xFF (plus 4x start & 4x stop bits) with the RS485 TX Enable pin LOW in order to "busy wait" for exactly 40 bit times.

    There was also a bug that stopped the PROP_OBJECT_LIST from working correctly - the reference to Handler_Transmit_Buffer was not being used at all inside the Encode_Property_APDU method. NOTE: This specifically refers to the h_rp.c file in the ATMega168 port folder.

    /* most cases will be error */
        ack_len = rp_ack_encode_apdu_init(
            &Handler_Transmit_Buffer[pdu_len], service_data->invoke_id, &data);
        /* FIXME: add buffer len as passed into function or use smart buffer */
        data.error_class = ERROR_CLASS_OBJECT;
        data.error_code = ERROR_CODE_UNKNOWN_OBJECT;
        property_len = Encode_Property_APDU(
            &Handler_Transmit_Buffer[pdu_len + ack_len], &data);
    

    Works when changed to:

    /* most cases will be error */
        ack_len = rp_ack_encode_apdu_init(
            &Handler_Transmit_Buffer[pdu_len], service_data->invoke_id, &data);
        /* configure our storage */
        data.application_data = &Handler_Transmit_Buffer[pdu_len + ack_len];
        /* FIXME: add buffer len as passed into function or use smart buffer */
        data.error_class = ERROR_CLASS_OBJECT;
        data.error_code = ERROR_CODE_UNKNOWN_OBJECT;
        property_len = Encode_Property_APDU(&data);
    

    Screenshot shows the device being browsed & polled in Yabe.

     
    • Steve Karg

      Steve Karg - 2022-08-14

      Thank you for posting the resulting solution! I pushed a fix into ports/atmega168 today.
      https://github.com/bacnet-stack/bacnet-stack/pull/323

       

Log in to post a comment.