From 10e74470a59941e415beef445b648efab0e2d282 Mon Sep 17 00:00:00 2001 From: skarg Date: Sat, 2 Aug 2008 16:23:29 +0000 Subject: [PATCH] Updated the MS/TP Capture tool, and cleaned up the net.h defines. --- bacnet-stack/demo/mstpcap/Makefile | 1 + bacnet-stack/ports/win32/net.h | 9 ++++++--- bacnet-stack/src/mstp.c | 4 ++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/bacnet-stack/demo/mstpcap/Makefile b/bacnet-stack/demo/mstpcap/Makefile index e6935ac1..9ba1e011 100644 --- a/bacnet-stack/demo/mstpcap/Makefile +++ b/bacnet-stack/demo/mstpcap/Makefile @@ -37,6 +37,7 @@ SRCS = main.c \ ${BACNET_PORT_DIR}/rs485.c \ ${BACNET_SOURCE_DIR}/mstp.c \ ${BACNET_SOURCE_DIR}/mstptext.c \ + ${BACNET_SOURCE_DIR}/debug.c \ ${BACNET_SOURCE_DIR}/indtext.c \ ${BACNET_SOURCE_DIR}/crc.c diff --git a/bacnet-stack/ports/win32/net.h b/bacnet-stack/ports/win32/net.h index 3cb07d88..372ce2a3 100644 --- a/bacnet-stack/ports/win32/net.h +++ b/bacnet-stack/ports/win32/net.h @@ -69,15 +69,16 @@ 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_usec >= tp.tv_usec) { + if (abs_timeout->tv_nsec >= (tp.tv_usec*1000)) { dwMilliseconds += - ((abs_timeout->tv_usec - tp.tv_usec) / 1000); + ((abs_timeout->tv_nsec - (tp.tv_usec*1000)) / (1000*1000)); } } else { dwMilliseconds = 0; @@ -90,7 +91,7 @@ static inline int sem_timedwait(sem_t *sem, return -1; } -static inline int sem_init(sem_t *sem, int pshared, unsigned int value); +static inline int sem_init(sem_t *sem, int pshared, unsigned int value) { (void)pshared; *sem = CreateSemaphore( @@ -111,6 +112,8 @@ static inline int nanosleep(const struct timespec *rqtp, struct timespec *rmtp) (rqtp->tv_nsec / 1000); Sleep(dwMilliseconds); + + return 0; } #endif diff --git a/bacnet-stack/src/mstp.c b/bacnet-stack/src/mstp.c index d7e295b0..64c03b04 100644 --- a/bacnet-stack/src/mstp.c +++ b/bacnet-stack/src/mstp.c @@ -61,7 +61,7 @@ #if PRINT_ENABLED #undef PRINT_ENABLED_RECEIVE #undef PRINT_ENABLED_RECEIVE_DATA -#undef PRINT_ENABLED_RECEIVE_ERRORS +#define PRINT_ENABLED_RECEIVE_ERRORS #undef PRINT_ENABLED_MASTER #endif @@ -464,7 +464,7 @@ void MSTP_Receive_Frame_FSM( if (mstp_port->SilenceTimer() > Tframe_abort) { /* indicate that an error has occurred during the reception of a frame */ mstp_port->ReceivedInvalidFrame = true; - printf_receive_error("MSTP: Rx Data: SilenceTimer %d > %d\n", + printf_receive_error("MSTP: Rx Data: SilenceTimer %dms > %dms\n", mstp_port->SilenceTimer(), Tframe_abort); /* wait for the start of the next frame. */ mstp_port->receive_state = MSTP_RECEIVE_STATE_IDLE;}