diff --git a/bacnet-stack/include/bacreal.h b/bacnet-stack/include/bacreal.h index c215bfae..d2713394 100644 --- a/bacnet-stack/include/bacreal.h +++ b/bacnet-stack/include/bacreal.h @@ -48,12 +48,20 @@ extern "C" { int encode_bacnet_real( float value, uint8_t * apdu); + int decode_double( + uint8_t * apdu, + double *real_value); + int encode_bacnet_double( + double value, + uint8_t * apdu); #ifdef TEST #include "ctest.h" void testBACreal( Test * pTest); + void testBACdouble( + Test * pTest); #endif #ifdef __cplusplus diff --git a/bacnet-stack/include/bvlc.h b/bacnet-stack/include/bvlc.h index 097d8580..c5993a4c 100644 --- a/bacnet-stack/include/bvlc.h +++ b/bacnet-stack/include/bvlc.h @@ -37,6 +37,7 @@ #include #include #include +#include #include "bacdef.h" #include "npdu.h" diff --git a/bacnet-stack/ports/win32/bacnet/bacnet.dsp b/bacnet-stack/ports/win32/bacnet/bacnet.dsp index fe8e9990..bf3b0733 100644 --- a/bacnet-stack/ports/win32/bacnet/bacnet.dsp +++ b/bacnet-stack/ports/win32/bacnet/bacnet.dsp @@ -42,7 +42,7 @@ RSC=rc.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\..\.." /I ".." /I "..\..\..\demo\object\\" /I "..\..\..\demo\handler\\" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "BACAPP_ALL" /D PRINT_ENABLED=1 /D BIG_ENDIAN=0 /D USE_INADDR=0 /D "BACDL_BIP" /FD /c +# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\..\.." /I ".." /I "..\..\..\demo\object\\" /I "..\..\..\demo\handler\\" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "BACAPP_ALL" /D PRINT_ENABLED=1 /D BIG_ENDIAN=0 /D "BACDL_BIP" /D USE_INADDR=1 /FD /c # SUBTRACT CPP /YX # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" @@ -67,7 +67,7 @@ LINK32=link.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c -# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\include\\" /I ".." /I "..\..\..\demo\object\\" /I "..\..\..\demo\handler\\" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "BACAPP_ALL" /D PRINT_ENABLED=1 /D BIG_ENDIAN=0 /D USE_INADDR=0 /D "BACDL_BIP" /FR /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\include\\" /I ".." /I "..\..\..\demo\object\\" /I "..\..\..\demo\handler\\" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "BACAPP_ALL" /D PRINT_ENABLED=1 /D BIG_ENDIAN=0 /D "BACDL_BIP" /D USE_INADDR=1 /FR /FD /GZ /c # SUBTRACT CPP /YX # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" @@ -177,6 +177,14 @@ SOURCE=..\..\..\demo\object\bv.c # End Source File # Begin Source File +SOURCE=..\..\..\src\bvlc.c +# End Source File +# Begin Source File + +SOURCE=..\..\..\src\cov.c +# End Source File +# Begin Source File + SOURCE=..\..\..\src\crc.c # End Source File # Begin Source File @@ -205,6 +213,10 @@ SOURCE=..\..\..\demo\handler\h_arf_a.c # End Source File # Begin Source File +SOURCE=..\..\..\demo\handler\h_cov.c +# End Source File +# Begin Source File + SOURCE=..\..\..\demo\handler\h_iam.c # End Source File # Begin Source File @@ -397,6 +409,10 @@ SOURCE=..\..\..\demo\object\bv.h # End Source File # Begin Source File +SOURCE=..\..\..\include\bvlc.h +# End Source File +# Begin Source File + SOURCE=..\..\..\include\bytes.h # End Source File # Begin Source File diff --git a/bacnet-stack/ports/win32/bacnet/bacnet.ncb b/bacnet-stack/ports/win32/bacnet/bacnet.ncb index 7ff5cbd2..86dabd74 100644 Binary files a/bacnet-stack/ports/win32/bacnet/bacnet.ncb and b/bacnet-stack/ports/win32/bacnet/bacnet.ncb differ diff --git a/bacnet-stack/ports/win32/bacnet/bacnet.opt b/bacnet-stack/ports/win32/bacnet/bacnet.opt index 53a12591..18c62edb 100644 Binary files a/bacnet-stack/ports/win32/bacnet/bacnet.opt and b/bacnet-stack/ports/win32/bacnet/bacnet.opt differ diff --git a/bacnet-stack/ports/win32/bacnet/bacnet.plg b/bacnet-stack/ports/win32/bacnet/bacnet.plg index d6be4236..a624e2bd 100644 --- a/bacnet-stack/ports/win32/bacnet/bacnet.plg +++ b/bacnet-stack/ports/win32/bacnet/bacnet.plg @@ -6,9 +6,9 @@ --------------------Configuration: bacnet - Win32 Debug--------------------

Command Lines

-Creating temporary file "C:\DOCUME~1\cbkargs\LOCALS~1\Temp\RSP35.tmp" with contents +Creating temporary file "C:\DOCUME~1\VMWare\LOCALS~1\Temp\RSP34.tmp" with contents [ -/nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\include\\" /I ".." /I "..\..\..\demo\object\\" /I "..\..\..\demo\handler\\" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "BACAPP_ALL" /D PRINT_ENABLED=1 /D BIG_ENDIAN=0 /D USE_INADDR=0 /D "BACDL_BIP" /FR"Debug/" /Fo"Debug/" /Fd"Debug/" /FD /GZ /c +/nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\..\..\include\\" /I ".." /I "..\..\..\demo\object\\" /I "..\..\..\demo\handler\\" /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "BACAPP_ALL" /D PRINT_ENABLED=1 /D BIG_ENDIAN=0 /D "BACDL_BIP" /D USE_INADDR=1 /FR"Debug/" /Fo"Debug/" /Fd"Debug/" /FD /GZ /c "C:\code\bacnet-stack\src\abort.c" "C:\code\bacnet-stack\src\address.c" "C:\code\bacnet-stack\demo\object\ai.c" @@ -16,34 +16,29 @@ Creating temporary file "C:\DOCUME~1\cbkargs\LOCALS~1\Temp\RSP35.tmp" with conte "C:\code\bacnet-stack\src\apdu.c" "C:\code\bacnet-stack\src\arf.c" "C:\code\bacnet-stack\demo\object\av.c" -"C:\code\bacnet-stack\src\bacaddr.c" "C:\code\bacnet-stack\src\bacapp.c" "C:\code\bacnet-stack\src\bacdcode.c" "C:\code\bacnet-stack\src\bacerror.c" "C:\code\bacnet-stack\demo\object\bacfile.c" -"C:\code\bacnet-stack\src\bacint.c" "C:\code\bacnet-stack\src\bacreal.c" -"C:\code\bacnet-stack\src\bacstr.c" -"C:\code\bacnet-stack\src\bactext.c" "C:\code\bacnet-stack\demo\object\bi.c" -"C:\code\bacnet-stack\src\bigend.c" "C:\code\bacnet-stack\ports\win32\bip-init.c" "C:\code\bacnet-stack\src\bip.c" "C:\code\bacnet-stack\demo\object\bo.c" "C:\code\bacnet-stack\demo\object\bv.c" -"C:\code\bacnet-stack\src\crc.c" -"C:\code\bacnet-stack\src\datetime.c" +"C:\code\bacnet-stack\src\bvlc.c" +"C:\code\bacnet-stack\src\cov.c" "C:\code\bacnet-stack\src\dcc.c" "C:\code\bacnet-stack\demo\object\device.c" "C:\code\bacnet-stack\demo\handler\h_arf.c" "C:\code\bacnet-stack\demo\handler\h_arf_a.c" +"C:\code\bacnet-stack\demo\handler\h_cov.c" "C:\code\bacnet-stack\demo\handler\h_iam.c" "C:\code\bacnet-stack\demo\handler\h_rp.c" "C:\code\bacnet-stack\demo\handler\h_rp_a.c" "C:\code\bacnet-stack\demo\handler\h_whois.c" "C:\code\bacnet-stack\demo\handler\h_wp.c" "C:\code\bacnet-stack\src\iam.c" -"C:\code\bacnet-stack\src\indtext.c" "C:\code\bacnet-stack\demo\object\lc.c" "C:\code\bacnet-stack\demo\object\lsp.c" "C:\code\bacnet-stack\ports\win32\main.c" @@ -51,22 +46,16 @@ Creating temporary file "C:\DOCUME~1\cbkargs\LOCALS~1\Temp\RSP35.tmp" with conte "C:\code\bacnet-stack\demo\handler\noserv.c" "C:\code\bacnet-stack\src\npdu.c" "C:\code\bacnet-stack\src\reject.c" -"C:\code\bacnet-stack\src\ringbuf.c" "C:\code\bacnet-stack\src\rp.c" "C:\code\bacnet-stack\demo\handler\s_rp.c" "C:\code\bacnet-stack\demo\handler\s_whois.c" "C:\code\bacnet-stack\demo\handler\s_wp.c" "C:\code\bacnet-stack\src\tsm.c" -"C:\code\bacnet-stack\demo\handler\txbuf.c" -"C:\code\bacnet-stack\src\version.c" "C:\code\bacnet-stack\src\whois.c" "C:\code\bacnet-stack\src\wp.c" -"C:\code\bacnet-stack\src\mstp.c" -"C:\code\bacnet-stack\ports\win32\dlmstp.c" -"C:\code\bacnet-stack\ports\win32\rs485.c" ] -Creating command line "cl.exe @C:\DOCUME~1\cbkargs\LOCALS~1\Temp\RSP35.tmp" -Creating temporary file "C:\DOCUME~1\cbkargs\LOCALS~1\Temp\RSP36.tmp" with contents +Creating command line "cl.exe @C:\DOCUME~1\VMWare\LOCALS~1\Temp\RSP34.tmp" +Creating temporary file "C:\DOCUME~1\VMWare\LOCALS~1\Temp\RSP35.tmp" with contents [ kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib /nologo /subsystem:console /incremental:yes /pdb:"Debug/bacnet.pdb" /debug /machine:I386 /out:"Debug/bacnet.exe" /pdbtype:sept ".\Debug\abort.obj" @@ -91,12 +80,16 @@ kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32 ".\Debug\bip.obj" ".\Debug\bo.obj" ".\Debug\bv.obj" +".\Debug\bvlc.obj" +".\Debug\cov.obj" ".\Debug\crc.obj" ".\Debug\datetime.obj" ".\Debug\dcc.obj" ".\Debug\device.obj" +".\Debug\dlmstp.obj" ".\Debug\h_arf.obj" ".\Debug\h_arf_a.obj" +".\Debug\h_cov.obj" ".\Debug\h_iam.obj" ".\Debug\h_rp.obj" ".\Debug\h_rp_a.obj" @@ -108,11 +101,13 @@ kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32 ".\Debug\lsp.obj" ".\Debug\main.obj" ".\Debug\mso.obj" +".\Debug\mstp.obj" ".\Debug\noserv.obj" ".\Debug\npdu.obj" ".\Debug\reject.obj" ".\Debug\ringbuf.obj" ".\Debug\rp.obj" +".\Debug\rs485.obj" ".\Debug\s_rp.obj" ".\Debug\s_whois.obj" ".\Debug\s_wp.obj" @@ -121,11 +116,8 @@ kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32 ".\Debug\version.obj" ".\Debug\whois.obj" ".\Debug\wp.obj" -".\Debug\mstp.obj" -".\Debug\dlmstp.obj" -".\Debug\rs485.obj" ] -Creating command line "link.exe @C:\DOCUME~1\cbkargs\LOCALS~1\Temp\RSP36.tmp" +Creating command line "link.exe @C:\DOCUME~1\VMWare\LOCALS~1\Temp\RSP35.tmp"

Output Window

Compiling... abort.c @@ -135,64 +127,50 @@ ao.c apdu.c arf.c av.c -bacaddr.c bacapp.c bacdcode.c bacerror.c bacfile.c -bacint.c bacreal.c -bacstr.c -bactext.c bi.c -bigend.c bip-init.c bip.c -Generating Code... -Compiling... bo.c bv.c -crc.c -datetime.c +bvlc.c +cov.c dcc.c +Generating Code... +Compiling... device.c h_arf.c h_arf_a.c +h_cov.c h_iam.c h_rp.c h_rp_a.c h_whois.c h_wp.c iam.c -indtext.c lc.c lsp.c main.c mso.c noserv.c -Generating Code... -Compiling... npdu.c reject.c -ringbuf.c rp.c s_rp.c s_whois.c +Generating Code... +Compiling... s_wp.c tsm.c -txbuf.c -version.c whois.c wp.c -mstp.c -dlmstp.c -rs485.c Generating Code... -c:\code\bacnet-stack\ports\win32\dlmstp.c(448) : warning C4761: integral size mismatch in argument; conversion supplied -c:\code\bacnet-stack\src\mstp.c(656) : warning C4761: integral size mismatch in argument; conversion supplied -c:\code\bacnet-stack\src\mstp.c(944) : warning C4761: integral size mismatch in argument; conversion supplied Linking... -Creating temporary file "C:\DOCUME~1\cbkargs\LOCALS~1\Temp\RSP38.tmp" with contents +Creating temporary file "C:\DOCUME~1\VMWare\LOCALS~1\Temp\RSP36.tmp" with contents [ /nologo /o"Debug/bacnet.bsc" ".\Debug\abort.sbr" @@ -217,12 +195,16 @@ Creating temporary file "C:\DOCUME~1\cbkargs\LOCALS~1\Temp\RSP38.tmp" with conte ".\Debug\bip.sbr" ".\Debug\bo.sbr" ".\Debug\bv.sbr" +".\Debug\bvlc.sbr" +".\Debug\cov.sbr" ".\Debug\crc.sbr" ".\Debug\datetime.sbr" ".\Debug\dcc.sbr" ".\Debug\device.sbr" +".\Debug\dlmstp.sbr" ".\Debug\h_arf.sbr" ".\Debug\h_arf_a.sbr" +".\Debug\h_cov.sbr" ".\Debug\h_iam.sbr" ".\Debug\h_rp.sbr" ".\Debug\h_rp_a.sbr" @@ -234,11 +216,13 @@ Creating temporary file "C:\DOCUME~1\cbkargs\LOCALS~1\Temp\RSP38.tmp" with conte ".\Debug\lsp.sbr" ".\Debug\main.sbr" ".\Debug\mso.sbr" +".\Debug\mstp.sbr" ".\Debug\noserv.sbr" ".\Debug\npdu.sbr" ".\Debug\reject.sbr" ".\Debug\ringbuf.sbr" ".\Debug\rp.sbr" +".\Debug\rs485.sbr" ".\Debug\s_rp.sbr" ".\Debug\s_whois.sbr" ".\Debug\s_wp.sbr" @@ -246,18 +230,15 @@ Creating temporary file "C:\DOCUME~1\cbkargs\LOCALS~1\Temp\RSP38.tmp" with conte ".\Debug\txbuf.sbr" ".\Debug\version.sbr" ".\Debug\whois.sbr" -".\Debug\wp.sbr" -".\Debug\mstp.sbr" -".\Debug\dlmstp.sbr" -".\Debug\rs485.sbr"] -Creating command line "bscmake.exe @C:\DOCUME~1\cbkargs\LOCALS~1\Temp\RSP38.tmp" +".\Debug\wp.sbr"] +Creating command line "bscmake.exe @C:\DOCUME~1\VMWare\LOCALS~1\Temp\RSP36.tmp" Creating browse info file...

Output Window

Results

-bacnet.exe - 0 error(s), 3 warning(s) +bacnet.exe - 0 error(s), 0 warning(s) diff --git a/bacnet-stack/ports/win32/bacnet/readme.txt b/bacnet-stack/ports/win32/bacnet/readme.txt index 6c7e1853..7b31139c 100644 --- a/bacnet-stack/ports/win32/bacnet/readme.txt +++ b/bacnet-stack/ports/win32/bacnet/readme.txt @@ -129,3 +129,18 @@ with MS/TP datalink enabled (BACDL_MSTP instead of BACDL_BIP): 3. Select the "C/C++" tab (3rd Tab) 4. Select the Category: Code Generation 5. Select the Multithreaded from the "Use runtime library" box options + +Q. error LNK2019: Verweis auf nicht aufgelöstes externes Symbol + "_GetAdaptersInfo@8" in Funktion "_getIpMaskForIpAddress". +A. There is the Iphlpapi.lib library missing from the VC++ project + (for the GetAdaptersInfo error) that you need to add: + http://msdn2.microsoft.com/en-us/library/aa916102.aspx + Note that Iphlpapi.lib/.h is not included with Visual C++ 6.0; + you would need to download the platform SDK to get it. +1. Select "Project" menu +2. Select "Settings..." +3. Select the "Link" tab (4th Tab) +4. You can see "Object/library modules:" edit box +5. Type Iphlpapi.lib in that edit box +6. Press OK +7. Compile the entire project again... diff --git a/bacnet-stack/ports/win32/net.h b/bacnet-stack/ports/win32/net.h index 5e811c36..52f338dc 100644 --- a/bacnet-stack/ports/win32/net.h +++ b/bacnet-stack/ports/win32/net.h @@ -30,7 +30,10 @@ #define STRICT 1 #include +#if (!defined(USE_INADDR) || (USE_INADDR == 0)) && \ + (!defined(USE_CLASSADDR) || (USE_CLASSADDR == 0)) #include +#endif #include #define close closesocket diff --git a/bacnet-stack/src/bvlc.c b/bacnet-stack/src/bvlc.c index 1c1855a9..3a677622 100644 --- a/bacnet-stack/src/bvlc.c +++ b/bacnet-stack/src/bvlc.c @@ -180,7 +180,7 @@ int bvlc_encode_bvlc_result( of the entire BVLL message, including the two octets of the length field itself, most significant octet first. */ encode_unsigned16(&pdu[2], 6); - encode_unsigned16(&pdu[4], result_code); + encode_unsigned16(&pdu[4], (uint16_t)result_code); } return 6; @@ -191,6 +191,7 @@ int bvlc_encode_write_bdt_init( unsigned entries) { int len = 0; + uint16_t BVLC_length = 0; if (pdu) { pdu[0] = BVLL_TYPE_BACNET_IP; @@ -198,7 +199,8 @@ int bvlc_encode_write_bdt_init( /* The 2-octet BVLC Length field is the length, in octets, of the entire BVLL message, including the two octets of the length field itself, most significant octet first. */ - encode_unsigned16(&pdu[2], 4 + entries * 10); + BVLC_length = 4 + (entries * 10); + encode_unsigned16(&pdu[2], BVLC_length); len = 4; } @@ -228,6 +230,7 @@ int bvlc_encode_read_bdt_ack_init( unsigned entries) { int len = 0; + uint16_t BVLC_length = 0; if (pdu) { pdu[0] = BVLL_TYPE_BACNET_IP; @@ -235,7 +238,8 @@ int bvlc_encode_read_bdt_ack_init( /* The 2-octet BVLC Length field is the length, in octets, of the entire BVLL message, including the two octets of the length field itself, most significant octet first. */ - encode_unsigned16(&pdu[2], 4 + entries * 10); + BVLC_length = 4 + (entries * 10); + encode_unsigned16(&pdu[2], BVLC_length); len = 4; } @@ -294,7 +298,7 @@ int bvlc_encode_forwarded_npdu( /* The 2-octet BVLC Length field is the length, in octets, of the entire BVLL message, including the two octets of the length field itself, most significant octet first. */ - encode_unsigned16(&pdu[2], 4 + 6 + npdu_length); + encode_unsigned16(&pdu[2], (uint16_t)(4 + 6 + npdu_length)); len = 4; address.s_addr = ntohl(sin->sin_addr.s_addr); port = ntohs(sin->sin_port); @@ -351,6 +355,7 @@ int bvlc_encode_read_fdt_ack_init( unsigned entries) { int len = 0; + uint16_t BVLC_length = 0; if (pdu) { pdu[0] = BVLL_TYPE_BACNET_IP; @@ -358,7 +363,8 @@ int bvlc_encode_read_fdt_ack_init( /* The 2-octet BVLC Length field is the length, in octets, of the entire BVLL message, including the two octets of the length field itself, most significant octet first. */ - encode_unsigned16(&pdu[2], 4 + entries * 10); + BVLC_length = 4 + (entries * 10); + encode_unsigned16(&pdu[2], BVLC_length); len = 4; } @@ -394,7 +400,7 @@ int bvlc_encode_read_fdt_ack( pdu_len += len; encode_unsigned16(&pdu[pdu_len], FD_Table[i].time_to_live); pdu_len += len; - encode_unsigned16(&pdu[pdu_len], FD_Table[i].seconds_remaining); + encode_unsigned16(&pdu[pdu_len], (uint16_t)FD_Table[i].seconds_remaining); pdu_len += len; } } @@ -432,6 +438,7 @@ int bvlc_encode_distribute_broadcast_to_network( { int len = 0; /* return value */ unsigned i; /* for loop counter */ + uint16_t BVLC_length = 0; if (pdu) { pdu[0] = BVLL_TYPE_BACNET_IP; @@ -439,7 +446,8 @@ int bvlc_encode_distribute_broadcast_to_network( /* The 2-octet BVLC Length field is the length, in octets, of the entire BVLL message, including the two octets of the length field itself, most significant octet first. */ - len = encode_unsigned16(&pdu[2], 4 + npdu_length) + 2; + BVLC_length = 4 + npdu_length; + len = encode_unsigned16(&pdu[2], BVLC_length) + 2; for (i = 0; i < npdu_length; i++) { pdu[len] = npdu[i]; len++; @@ -456,6 +464,7 @@ int bvlc_encode_original_unicast_npdu( { int len = 0; /* return value */ unsigned i = 0; /* loop counter */ + uint16_t BVLC_length = 0; if (pdu) { pdu[0] = BVLL_TYPE_BACNET_IP; @@ -463,7 +472,8 @@ int bvlc_encode_original_unicast_npdu( /* The 2-octet BVLC Length field is the length, in octets, of the entire BVLL message, including the two octets of the length field itself, most significant octet first. */ - len = encode_unsigned16(&pdu[2], 4 + npdu_length) + 2; + BVLC_length = 4 + npdu_length; + len = encode_unsigned16(&pdu[2], BVLC_length) + 2; for (i = 0; i < npdu_length; i++) { pdu[len] = npdu[i]; len++; @@ -480,6 +490,7 @@ int bvlc_encode_original_broadcast_npdu( { int len = 0; /* return value */ unsigned i = 0; /* loop counter */ + uint16_t BVLC_length = 0; if (pdu) { pdu[0] = BVLL_TYPE_BACNET_IP; @@ -487,7 +498,8 @@ int bvlc_encode_original_broadcast_npdu( /* The 2-octet BVLC Length field is the length, in octets, of the entire BVLL message, including the two octets of the length field itself, most significant octet first. */ - len = encode_unsigned16(&pdu[2], 4 + npdu_length) + 2; + BVLC_length = 4 + npdu_length; + len = encode_unsigned16(&pdu[2], BVLC_length) + 2; for (i = 0; i < npdu_length; i++) { pdu[len] = npdu[i]; len++; @@ -666,7 +678,7 @@ void bvlc_bdt_forward_npdu( uint16_t npdu_length) { /* length of the NPDU */ uint8_t mtu[MAX_MPDU] = { 0 }; - int mtu_len = 0; + uint16_t mtu_len = 0; int bytes_sent = 0; unsigned i = 0; /* loop counter */ struct sockaddr_in bip_dest; @@ -706,8 +718,9 @@ void bvlc_broadcast_forward_npdu( uint16_t npdu_len) { /* size of the NPDU */ uint8_t mtu[MAX_MPDU] = { 0 }; - int mtu_len = 0; + uint16_t mtu_len = 0; struct sockaddr_in bvlc_dest; + uint16_t BVLC_length = 0; /* FIXME: unused parameter */ sin = sin; @@ -716,10 +729,9 @@ void bvlc_broadcast_forward_npdu( mtu[1] = BVLC_ORIGINAL_BROADCAST_NPDU; bvlc_dest.sin_addr.s_addr = htonl(bip_get_broadcast_addr()); bvlc_dest.sin_port = htons(bip_get_port()); + BVLC_length = npdu_len + 4 /*inclusive */; mtu_len = 2; - mtu_len += - encode_unsigned16(&mtu[mtu_len], - (uint16_t) (npdu_len + 4 /*inclusive */ )); + mtu_len += encode_unsigned16(&mtu[mtu_len], BVLC_length); memcpy(&mtu[mtu_len], npdu, npdu_len); mtu_len += npdu_len; bvlc_send_mpdu(&bvlc_dest, mtu, mtu_len); @@ -731,7 +743,7 @@ void bvlc_fdt_forward_npdu( uint16_t max_npdu) { /* amount of space available in the NPDU */ uint8_t mtu[MAX_MPDU] = { 0 }; - int mtu_len = 0; + uint16_t mtu_len = 0; int bytes_sent = 0; unsigned i = 0; /* loop counter */ struct sockaddr_in bvlc_dest; @@ -755,7 +767,7 @@ void bvlc_register_with_bbmd( uint16_t time_to_live_seconds) { uint8_t mtu[MAX_MPDU] = { 0 }; - int mtu_len = 0; + uint16_t mtu_len = 0; Remote_BBMD.sin_addr.s_addr = bbmd_address; Remote_BBMD.sin_port = htons(bbmd_port); @@ -773,7 +785,7 @@ void bvlc_send_result( BACNET_BVLC_RESULT result_code) { uint8_t mtu[MAX_MPDU] = { 0 }; - int mtu_len = 0; + uint16_t mtu_len = 0; mtu_len = bvlc_encode_bvlc_result(&mtu[0], result_code); bvlc_send_mpdu(dest, mtu, mtu_len); @@ -785,7 +797,7 @@ int bvlc_send_bdt( struct sockaddr_in *dest) { uint8_t mtu[MAX_MPDU] = { 0 }; - int mtu_len = 0; + uint16_t mtu_len = 0; mtu_len = bvlc_encode_read_bdt_ack(&mtu[0], sizeof(mtu)); if (mtu_len) { @@ -799,7 +811,7 @@ int bvlc_send_fdt( struct sockaddr_in *dest) { uint8_t mtu[MAX_MPDU] = { 0 }; - int mtu_len = 0; + uint16_t mtu_len = 0; mtu_len = bvlc_encode_read_fdt_ack(&mtu[0], sizeof(mtu)); if (mtu_len) { @@ -1110,10 +1122,11 @@ int bvlc_send_pdu( { /* number of bytes of data */ struct sockaddr_in bvlc_dest; uint8_t mtu[MAX_MPDU] = { 0 }; - int mtu_len = 0; + uint16_t mtu_len = 0; /* addr and port in host format */ struct in_addr address; uint16_t port = 0; + uint16_t BVLC_length = 0; /* bip datalink doesn't need to know the npdu data */ (void) npdu_data; @@ -1139,10 +1152,9 @@ int bvlc_send_pdu( } bvlc_dest.sin_addr.s_addr = htonl(address.s_addr); bvlc_dest.sin_port = htons(port); + BVLC_length = pdu_len + 4 /*inclusive */; mtu_len = 2; - mtu_len += - encode_unsigned16(&mtu[mtu_len], - (uint16_t) (pdu_len + 4 /*inclusive */ )); + mtu_len += encode_unsigned16(&mtu[mtu_len], BVLC_length); memcpy(&mtu[mtu_len], pdu, pdu_len); mtu_len += pdu_len; return bvlc_send_mpdu(&bvlc_dest, mtu, mtu_len);