From 2328f0fe5919c54f860908038798248e4f1dedbd Mon Sep 17 00:00:00 2001 From: skarg Date: Thu, 14 Aug 2008 16:35:26 +0000 Subject: [PATCH] Updated makefiles and build scripts for Borland tools. --- bacnet-stack/borland.bat | 7 ++ bacnet-stack/build.bat | 7 +- bacnet-stack/demo/dcc/makefile.b32 | 2 +- bacnet-stack/demo/epics/makefile.b32 | 2 +- bacnet-stack/demo/mstpcap/main.c | 32 ++++++++ bacnet-stack/demo/readfile/makefile.b32 | 2 +- bacnet-stack/demo/readprop/makefile.b32 | 2 +- bacnet-stack/demo/reinit/makefile.b32 | 2 +- bacnet-stack/demo/server/makefile.b32 | 2 +- bacnet-stack/demo/timesync/makefile.b32 | 2 +- bacnet-stack/demo/ucov/makefile.b32 | 2 +- bacnet-stack/demo/whohas/makefile.b32 | 2 +- bacnet-stack/demo/whois/makefile.b32 | 2 +- bacnet-stack/demo/writefile/makefile.b32 | 2 +- bacnet-stack/demo/writeprop/makefile.b32 | 2 +- bacnet-stack/include/debug.h | 3 +- bacnet-stack/lib/makefile.b32 | 7 +- bacnet-stack/ports/win32/bacnet/bacnet.dsp | 8 ++ bacnet-stack/ports/win32/net.h | 88 ++-------------------- bacnet-stack/ports/win32/rs485.h | 1 + bacnet-stack/src/mstp.c | 4 + 21 files changed, 78 insertions(+), 103 deletions(-) create mode 100644 bacnet-stack/borland.bat diff --git a/bacnet-stack/borland.bat b/bacnet-stack/borland.bat new file mode 100644 index 00000000..937fc38e --- /dev/null +++ b/bacnet-stack/borland.bat @@ -0,0 +1,7 @@ +@echo off +echo Build for Borland 5.5 tools +set BORLAND_DIR=c:\borland\bcc55 +%BORLAND_DIR%\bin\make -f makefile.b32 clean +%BORLAND_DIR%\bin\make -f makefile.b32 all + + diff --git a/bacnet-stack/build.bat b/bacnet-stack/build.bat index d5c4228e..077b4022 100644 --- a/bacnet-stack/build.bat +++ b/bacnet-stack/build.bat @@ -1,10 +1,5 @@ @echo off -rem Build for Borland 5.5 tools -rem set BORLAND_DIR=c:\borland\bcc55 -rem %BORLAND_DIR%\bin\make -f makefile.b32 clean -rem %BORLAND_DIR%\bin\make -f makefile.b32 all - -rem Build for MinGW +echo Build with MinGW make BACNET_PORT=win32 OPTIMIZATION=-Os DEBUGGING= clean all rem Build for MinGW debug rem make BACNET_PORT=win32 clean all diff --git a/bacnet-stack/demo/dcc/makefile.b32 b/bacnet-stack/demo/dcc/makefile.b32 index 94c9fdc0..27415875 100644 --- a/bacnet-stack/demo/dcc/makefile.b32 +++ b/bacnet-stack/demo/dcc/makefile.b32 @@ -35,7 +35,7 @@ INCLUDES = \ # BACNET_DEFINES = -DPRINT_ENABLED=1 -DBACAPP_ALL #BACDL_DEFINE=-DBACDL_MSTP=1 -BACDL_DEFINE=-DBACDL_BIP=1 +BACDL_DEFINE=-DBACDL_BIP=1 -DUSE_INADDR=1 DEFINES = $(BACNET_DEFINES) $(BACDL_DEFINE) SRCS = main.c diff --git a/bacnet-stack/demo/epics/makefile.b32 b/bacnet-stack/demo/epics/makefile.b32 index 05cd2548..2deb7dfa 100644 --- a/bacnet-stack/demo/epics/makefile.b32 +++ b/bacnet-stack/demo/epics/makefile.b32 @@ -35,7 +35,7 @@ INCLUDES = \ # BACNET_DEFINES = -DPRINT_ENABLED=1 -DBACAPP_ALL #BACDL_DEFINE=-DBACDL_MSTP=1 -BACDL_DEFINE=-DBACDL_BIP=1 +BACDL_DEFINE=-DBACDL_BIP=1 -DUSE_INADDR=1 DEFINES = $(BACNET_DEFINES) $(BACDL_DEFINE) SRCS = main.c \ diff --git a/bacnet-stack/demo/mstpcap/main.c b/bacnet-stack/demo/mstpcap/main.c index c6d05d17..4f191ae6 100644 --- a/bacnet-stack/demo/mstpcap/main.c +++ b/bacnet-stack/demo/mstpcap/main.c @@ -54,6 +54,38 @@ static uint8_t RxBuffer[MAX_MPDU]; static uint8_t TxBuffer[MAX_MPDU]; static uint16_t SilenceTime; #define INCREMENT_AND_LIMIT_UINT16(x) {if (x < 0xFFFF) x++;} + +#if defined (_WIN32) +struct timespec { + time_t tv_sec; /* Seconds */ + long tv_nsec; /* Nanoseconds [0 .. 999999999] */ +}; + +static int gettimeofday( + struct timeval *tp, + void *tzp) +{ + struct _timeb timebuffer; + + _ftime(&timebuffer); + tp->tv_sec = timebuffer.time; + tp->tv_usec = timebuffer.millitm * 1000; + + return 0; +} + +static int nanosleep( + const struct timespec *rqtp, + struct timespec *rmtp) +{ + DWORD dwMilliseconds = (rqtp->tv_sec * 1000) + (rqtp->tv_nsec / 1000); + + Sleep(dwMilliseconds); + + return 0; +} +#endif + static uint16_t Timer_Silence( void) { diff --git a/bacnet-stack/demo/readfile/makefile.b32 b/bacnet-stack/demo/readfile/makefile.b32 index 6a22894b..1b95c5e3 100644 --- a/bacnet-stack/demo/readfile/makefile.b32 +++ b/bacnet-stack/demo/readfile/makefile.b32 @@ -34,7 +34,7 @@ INCLUDES = \ # BACNET_DEFINES = -DPRINT_ENABLED=1 -DBACAPP_ALL #BACDL_DEFINE=-DBACDL_MSTP=1 -BACDL_DEFINE=-DBACDL_BIP=1 +BACDL_DEFINE=-DBACDL_BIP=1 -DUSE_INADDR=1 DEFINES = $(BACNET_DEFINES) $(BACDL_DEFINE) SRCS = main.c diff --git a/bacnet-stack/demo/readprop/makefile.b32 b/bacnet-stack/demo/readprop/makefile.b32 index e033ae97..b0893dc4 100644 --- a/bacnet-stack/demo/readprop/makefile.b32 +++ b/bacnet-stack/demo/readprop/makefile.b32 @@ -34,7 +34,7 @@ INCLUDES = \ # BACNET_DEFINES = -DPRINT_ENABLED=1 -DBACAPP_ALL #BACDL_DEFINE=-DBACDL_MSTP=1 -BACDL_DEFINE=-DBACDL_BIP=1 +BACDL_DEFINE=-DBACDL_BIP=1 -DUSE_INADDR=1 DEFINES = $(BACNET_DEFINES) $(BACDL_DEFINE) SRCS = main.c diff --git a/bacnet-stack/demo/reinit/makefile.b32 b/bacnet-stack/demo/reinit/makefile.b32 index 3c20ae44..6ad75f28 100644 --- a/bacnet-stack/demo/reinit/makefile.b32 +++ b/bacnet-stack/demo/reinit/makefile.b32 @@ -34,7 +34,7 @@ INCLUDES = \ # BACNET_DEFINES = -DPRINT_ENABLED=1 -DBACAPP_ALL #BACDL_DEFINE=-DBACDL_MSTP=1 -BACDL_DEFINE=-DBACDL_BIP=1 +BACDL_DEFINE=-DBACDL_BIP=1 -DUSE_INADDR=1 DEFINES = $(BACNET_DEFINES) $(BACDL_DEFINE) SRCS = main.c diff --git a/bacnet-stack/demo/server/makefile.b32 b/bacnet-stack/demo/server/makefile.b32 index 752f8dfb..8babf4e5 100644 --- a/bacnet-stack/demo/server/makefile.b32 +++ b/bacnet-stack/demo/server/makefile.b32 @@ -37,7 +37,7 @@ INCLUDES = \ # BACNET_DEFINES = -DPRINT_ENABLED=1 -DBACFILE -DBACAPP_ALL #BACDL_DEFINE=-DBACDL_MSTP -DCRC_USE_TABLE -BACDL_DEFINE=-DBACDL_BIP +BACDL_DEFINE=-DBACDL_BIP=1 -DUSE_INADDR=1 DEFINES = $(BACNET_DEFINES) $(BACDL_DEFINE) SRCS = main.c diff --git a/bacnet-stack/demo/timesync/makefile.b32 b/bacnet-stack/demo/timesync/makefile.b32 index 3db44fed..a607f5cf 100644 --- a/bacnet-stack/demo/timesync/makefile.b32 +++ b/bacnet-stack/demo/timesync/makefile.b32 @@ -34,7 +34,7 @@ INCLUDES = \ # BACNET_DEFINES = -DPRINT_ENABLED=1 -DBACAPP_ALL #BACDL_DEFINE=-DBACDL_MSTP=1 -BACDL_DEFINE=-DBACDL_BIP=1 +BACDL_DEFINE=-DBACDL_BIP=1 -DUSE_INADDR=1 DEFINES = $(BACNET_DEFINES) $(BACDL_DEFINE) SRCS = main.c diff --git a/bacnet-stack/demo/ucov/makefile.b32 b/bacnet-stack/demo/ucov/makefile.b32 index 8317ae77..0b2b17ae 100644 --- a/bacnet-stack/demo/ucov/makefile.b32 +++ b/bacnet-stack/demo/ucov/makefile.b32 @@ -34,7 +34,7 @@ INCLUDES = \ # BACNET_DEFINES = -DPRINT_ENABLED=1 -DBACAPP_ALL #BACDL_DEFINE=-DBACDL_MSTP=1 -BACDL_DEFINE=-DBACDL_BIP=1 +BACDL_DEFINE=-DBACDL_BIP=1 -DUSE_INADDR=1 DEFINES = $(BACNET_DEFINES) $(BACDL_DEFINE) SRCS = main.c diff --git a/bacnet-stack/demo/whohas/makefile.b32 b/bacnet-stack/demo/whohas/makefile.b32 index e36ff487..c1e4021c 100644 --- a/bacnet-stack/demo/whohas/makefile.b32 +++ b/bacnet-stack/demo/whohas/makefile.b32 @@ -34,7 +34,7 @@ INCLUDES = \ # BACNET_DEFINES = -DPRINT_ENABLED=1 -DBACAPP_ALL #BACDL_DEFINE=-DBACDL_MSTP=1 -BACDL_DEFINE=-DBACDL_BIP=1 +BACDL_DEFINE=-DBACDL_BIP=1 -DUSE_INADDR=1 DEFINES = $(BACNET_DEFINES) $(BACDL_DEFINE) SRCS = main.c diff --git a/bacnet-stack/demo/whois/makefile.b32 b/bacnet-stack/demo/whois/makefile.b32 index 64f9a42b..3d271f13 100644 --- a/bacnet-stack/demo/whois/makefile.b32 +++ b/bacnet-stack/demo/whois/makefile.b32 @@ -34,7 +34,7 @@ INCLUDES = \ # BACNET_DEFINES = -DPRINT_ENABLED=1 -DBACAPP_ALL #BACDL_DEFINE=-DBACDL_MSTP=1 -BACDL_DEFINE=-DBACDL_BIP=1 +BACDL_DEFINE=-DBACDL_BIP=1 -DUSE_INADDR=1 DEFINES = $(BACNET_DEFINES) $(BACDL_DEFINE) SRCS = main.c diff --git a/bacnet-stack/demo/writefile/makefile.b32 b/bacnet-stack/demo/writefile/makefile.b32 index 5b16c5d4..3bf83a50 100644 --- a/bacnet-stack/demo/writefile/makefile.b32 +++ b/bacnet-stack/demo/writefile/makefile.b32 @@ -34,7 +34,7 @@ INCLUDES = \ # BACNET_DEFINES = -DPRINT_ENABLED=1 -DBACAPP_ALL #BACDL_DEFINE=-DBACDL_MSTP=1 -BACDL_DEFINE=-DBACDL_BIP=1 +BACDL_DEFINE=-DBACDL_BIP=1 -DUSE_INADDR=1 DEFINES = $(BACNET_DEFINES) $(BACDL_DEFINE) SRCS = main.c diff --git a/bacnet-stack/demo/writeprop/makefile.b32 b/bacnet-stack/demo/writeprop/makefile.b32 index 4c1949cc..d121bd6d 100644 --- a/bacnet-stack/demo/writeprop/makefile.b32 +++ b/bacnet-stack/demo/writeprop/makefile.b32 @@ -34,7 +34,7 @@ INCLUDES = \ # BACNET_DEFINES = -DPRINT_ENABLED=1 -DBACAPP_ALL #BACDL_DEFINE=-DBACDL_MSTP=1 -BACDL_DEFINE=-DBACDL_BIP=1 +BACDL_DEFINE=-DBACDL_BIP=1 -DUSE_INADDR=1 DEFINES = $(BACNET_DEFINES) $(BACDL_DEFINE) SRCS = main.c diff --git a/bacnet-stack/include/debug.h b/bacnet-stack/include/debug.h index 3e3ef714..7b293727 100644 --- a/bacnet-stack/include/debug.h +++ b/bacnet-stack/include/debug.h @@ -47,7 +47,8 @@ void debug_printf( static void debug_printf( const char *format, ...) -{ +{ + format=format; } #endif diff --git a/bacnet-stack/lib/makefile.b32 b/bacnet-stack/lib/makefile.b32 index df33a67c..6dc74f73 100644 --- a/bacnet-stack/lib/makefile.b32 +++ b/bacnet-stack/lib/makefile.b32 @@ -19,8 +19,7 @@ TLIB = $(BORLAND_DIR)\bin\tlib MAKE = $(BORLAND_DIR)\bin\make BACNET_DEFINES = -DPRINT_ENABLED=1 -DBACFILE -DBACAPP_ALL -#BACDL_DEFINE=-DBACDL_MSTP -DCRC_USE_TABLE -#BACDL_DEFINE=-DBACDL_BIP +BACDL_DEFINE=-DBACDL_BIP=1 -DUSE_INADDR=1 DEFINES = $(BACNET_DEFINES) $(BACDL_DEFINE) # directories @@ -112,10 +111,10 @@ OBJECT_SRC = $(BACNET_OBJECT)\device.c \ $(BACNET_OBJECT)\bacfile.c PORT_SRC = $(BACNET_PORT)\bip-init.c \ - $(BACNET_PORT)\dlmstp.c \ $(BACNET_PORT)\rs485.c \ - $(BACNET_CORE)\mstp.c \ + $(BACNET_PORT)\dlmstp.c \ $(BACNET_CORE)\crc.c \ + $(BACNET_CORE)\mstp.c \ $(BACNET_CORE)\bvlc.c \ $(BACNET_CORE)\bip.c diff --git a/bacnet-stack/ports/win32/bacnet/bacnet.dsp b/bacnet-stack/ports/win32/bacnet/bacnet.dsp index c7e88cda..e0787212 100644 --- a/bacnet-stack/ports/win32/bacnet/bacnet.dsp +++ b/bacnet-stack/ports/win32/bacnet/bacnet.dsp @@ -273,6 +273,10 @@ SOURCE=..\..\..\src\mstp.c # End Source File # Begin Source File +SOURCE=..\..\..\src\mstptext.c +# End Source File +# Begin Source File + SOURCE=..\..\..\demo\handler\noserv.c # End Source File # Begin Source File @@ -461,6 +465,10 @@ SOURCE=..\..\..\include\mstp.h # End Source File # Begin Source File +SOURCE=..\..\..\include\mstptext.h +# End Source File +# Begin Source File + SOURCE=..\..\..\include\npdu.h # End Source File # Begin Source File diff --git a/bacnet-stack/ports/win32/net.h b/bacnet-stack/ports/win32/net.h index 19e99dd0..543ea213 100644 --- a/bacnet-stack/ports/win32/net.h +++ b/bacnet-stack/ports/win32/net.h @@ -38,88 +38,16 @@ #include #include +#ifdef __MSC_VER +#define inline __inline +#endif + +#ifdef __BORLANDC__ +#define inline __inline +#endif + #define close closesocket typedef int socklen_t; -typedef HANDLE sem_t; - -#define sem_post(x) ReleaseSemaphore(*(x), 1, NULL) -#define sem_close(x) CloseHandle(*(x)) - -struct timespec { - time_t tv_sec; /* Seconds */ - long tv_nsec; /* Nanoseconds [0 .. 999999999] */ -}; - - -static inline int gettimeofday( - struct timeval *tp, - void *tzp) -{ - struct _timeb timebuffer; - - _ftime(&timebuffer); - tp->tv_sec = timebuffer.time; - tp->tv_usec = timebuffer.millitm * 1000; - - return 0; -} - -/* FIXME: not a complete implementation of the posix function */ -static inline int sem_timedwait( - sem_t * sem, - const struct timespec *abs_timeout) -{ - struct timeval tp; - DWORD wait_status = 0; - DWORD dwMilliseconds = - (abs_timeout->tv_sec * 1000) + (abs_timeout->tv_nsec / 1000); - - gettimeofday(&tp, NULL); - if (abs_timeout->tv_sec >= tp.tv_sec) { - dwMilliseconds = (abs_timeout->tv_sec - tp.tv_sec) * 1000; - if (abs_timeout->tv_nsec >= (tp.tv_usec * 1000)) { - dwMilliseconds += - ((abs_timeout->tv_nsec - (tp.tv_usec * 1000)) / (1000 * 1000)); - } - } else { - dwMilliseconds = 0; - } - - wait_status = WaitForSingleObject(*sem, dwMilliseconds); - if (wait_status == WAIT_OBJECT_0) { - return 0; - } - return -1; -} - -static inline int sem_init( - sem_t * sem, - int pshared, - unsigned int value) -{ - (void) pshared; - *sem = CreateSemaphore(NULL /*lpSecurityDescriptor */ , - value /* lInitialCount */ , - 1 /* lMaximumCount */ , - NULL /* lpName */ ); - if ((*sem) == NULL) { - return -1; - } - - return 0; -} - -static inline int nanosleep( - const struct timespec *rqtp, - struct timespec *rmtp) -{ - DWORD dwMilliseconds = (rqtp->tv_sec * 1000) + (rqtp->tv_nsec / 1000); - - Sleep(dwMilliseconds); - - return 0; -} - #endif diff --git a/bacnet-stack/ports/win32/rs485.h b/bacnet-stack/ports/win32/rs485.h index c4f161ec..5d048266 100644 --- a/bacnet-stack/ports/win32/rs485.h +++ b/bacnet-stack/ports/win32/rs485.h @@ -38,6 +38,7 @@ #include #include "mstp.h" +#include "net.h" #ifdef __cplusplus extern "C" { diff --git a/bacnet-stack/src/mstp.c b/bacnet-stack/src/mstp.c index a2437d42..a072680a 100644 --- a/bacnet-stack/src/mstp.c +++ b/bacnet-stack/src/mstp.c @@ -72,6 +72,7 @@ static inline void printf_receive( const char *format, ...) { + format=format; } #endif @@ -82,6 +83,7 @@ static inline void printf_receive_data( const char *format, ...) { + format=format; } #endif @@ -92,6 +94,7 @@ static inline void printf_receive_error( const char *format, ...) { + format=format; } #endif @@ -102,6 +105,7 @@ static inline void printf_master( const char *format, ...) { + format=format; } #endif