Updated the unit test make files. Fixed the init sections of MS/TP monitor (rx_fsm) modules. Corrected the rx_fsm code to check the correct return value of the read. Fixed the return value of the RS485 prototypes.
This commit is contained in:
@@ -195,7 +195,7 @@ void RS485_Check_UART_Data(struct mstp_port_struct_t *mstp_port)
|
||||
/* if error, */
|
||||
/* ReceiveError = TRUE; */
|
||||
/* return; */
|
||||
if (count) {
|
||||
if (count > 0) {
|
||||
mstp_port->DataRegister = buf[0];
|
||||
/* if data is ready, */
|
||||
mstp_port->DataAvailable = true;
|
||||
@@ -278,7 +278,7 @@ int main(int argc, char *argv[])
|
||||
written = write(RS485_Handle, wbuf, wlen);
|
||||
rlen = read(RS485_Handle,buf,sizeof(buf));
|
||||
/* print any characters received */
|
||||
if (rlen) {
|
||||
if (rlen > 0) {
|
||||
for (i = 0; i < rlen; i++) {
|
||||
fprintf(stderr,"%02X ",buf[i]);
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ extern "C" {
|
||||
uint8_t * buffer, /* frame to send (up to 501 bytes of data) */
|
||||
uint16_t nbytes); /* number of bytes of data (up to 501) */
|
||||
|
||||
uint8_t RS485_Check_UART_Data(
|
||||
void RS485_Check_UART_Data(
|
||||
volatile struct mstp_port_struct_t *mstp_port); /* port specific data */
|
||||
uint32_t RS485_Get_Baud_Rate(void);
|
||||
bool RS485_Set_Baud_Rate(uint32_t baud);
|
||||
|
||||
@@ -67,15 +67,15 @@ void *milliseconds_task(void *pArg)
|
||||
|
||||
for (;;) {
|
||||
nanosleep(&timeOut, &remains);
|
||||
dlmstp_millisecond_timer();
|
||||
INCREMENT_AND_LIMIT_UINT16(MSTP_Port.SilenceTimer);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void dlmstp_millisecond_timer(void)
|
||||
volatile uint16_t *dlmstp_millisecond_timer_address(void)
|
||||
{
|
||||
INCREMENT_AND_LIMIT_UINT16(MSTP_Port.SilenceTimer);
|
||||
return (&(MSTP_Port.SilenceTimer));
|
||||
}
|
||||
|
||||
/* functions used by the MS/TP state machine to put or get data */
|
||||
@@ -170,19 +170,28 @@ int main(int argc, char *argv[])
|
||||
volatile struct mstp_port_struct_t *mstp_port;
|
||||
int rc = 0;
|
||||
pthread_t hThread;
|
||||
|
||||
int my_mac = 127;
|
||||
|
||||
/* mimic our pointer in the state machine */
|
||||
mstp_port = &MSTP_Port;
|
||||
/* initialize our interface */
|
||||
if (argc > 1)
|
||||
if (argc > 1) {
|
||||
RS485_Set_Interface(argv[1]);
|
||||
}
|
||||
if (argc > 2) {
|
||||
my_mac = strtol(argv[2], NULL, 0);
|
||||
if (my_mac > 127)
|
||||
my_mac = 127;
|
||||
}
|
||||
RS485_Set_Baud_Rate(38400);
|
||||
RS485_Initialize();
|
||||
MSTP_Port.InputBuffer = &RxBuffer[0];
|
||||
MSTP_Port.InputBufferSize = sizeof(RxBuffer);
|
||||
MSTP_Port.OutputBuffer = &TxBuffer[0];
|
||||
MSTP_Port.OutputBufferSize = sizeof(TxBuffer);
|
||||
MSTP_Port.This_Station = my_mac;
|
||||
MSTP_Port.Nmax_info_frames = 1;
|
||||
MSTP_Port.Nmax_master = 127;
|
||||
MSTP_Init(mstp_port);
|
||||
mstp_port->Lurking = true;
|
||||
/* start our MilliSec task */
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
# Makefile for mingw32 on Linux
|
||||
# Written by Steve Karg <skarg@users.sourceforge.net> 06-Aug-2007
|
||||
|
||||
TARGET=bacnet
|
||||
|
||||
# Tools
|
||||
CC=i586-mingw32msvc-gcc
|
||||
RANLIB = /usr/i586-mingw32msvc/bin/ranlib
|
||||
ASM = /usr/i586-mingw32msvc/bin/as
|
||||
MKLIB = /usr/i586-mingw32msvc/bin/ar r
|
||||
DLLWRAP = /usr/bin/i586-mingw32msvc-dllwrap
|
||||
|
||||
BACNET_FLAGS = -DBACDL_MSTP
|
||||
BACNET_FLAGS += -DPRINT_ENABLED=0
|
||||
BACNET_FLAGS += -DBIG_ENDIAN=0
|
||||
BACNET_FLAGS += -DMAX_APDU=480
|
||||
#BACNET_FLAGS += -DDLMSTP_TEST
|
||||
|
||||
INCLUDES = -I. -I../.. -I../../demo/handler -I../../demo/object
|
||||
OPTIMIZATION = -O0
|
||||
#OPTIMIZATION = -Os
|
||||
CFLAGS = $(OPTIMIZATION) $(INCLUDES) $(BACNET_FLAGS) -Wall -g
|
||||
LIBRARY = lib$(TARGET).a
|
||||
# -Wl,<options> Pass comma-separated <options> on to the linker
|
||||
LIBRARIES=-lc,-lgcc,-lm,-lwsock32,-L=.,-l$(TARGET)
|
||||
LDFLAGS = -Wl,-nostdlib,-Map=$(TARGET).map,$(LIBRARIES)
|
||||
|
||||
PORTSRC = main.c \
|
||||
rs485.c \
|
||||
dlmstp.c \
|
||||
../../crc.c \
|
||||
../../mstp.c
|
||||
|
||||
DEMOSRC = ai.c \
|
||||
../../demo/object/av.c \
|
||||
../../demo/object/bi.c \
|
||||
../../demo/object/bv.c \
|
||||
../../demo/object/h_rp.c \
|
||||
../../demo/object/h_wp.c \
|
||||
../../demo/object/device.c \
|
||||
../../demo/handler/txbuf.c \
|
||||
../../demo/handler/h_whois.c \
|
||||
../../demo/handler/h_rd.c \
|
||||
../../demo/handler/h_dcc.c
|
||||
|
||||
CORESRC = ../../npdu.c \
|
||||
../../bacint.c \
|
||||
../../apdu.c \
|
||||
../../bacdcode.c \
|
||||
../../bacstr.c \
|
||||
../../abort.c \
|
||||
../../bacerror.c \
|
||||
../../reject.c \
|
||||
../../bacapp.c \
|
||||
../../datetime.c \
|
||||
../../rp.c \
|
||||
../../wp.c \
|
||||
../../dcc.c \
|
||||
../../rd.c \
|
||||
../../whois.c \
|
||||
../../iam.c \
|
||||
../../version.c
|
||||
|
||||
CSRC = $(PORTSRC) $(DEMOSRC)
|
||||
|
||||
COBJ = $(CSRC:.c=.o)
|
||||
COREOBJ = $(CORESRC:.c=.o)
|
||||
|
||||
all: $(TARGET).exe
|
||||
|
||||
$(TARGET).exe: $(COBJ) $(LIBRARY) Makefile
|
||||
$(CC) $(CFLAGS) $(COBJ) $(LDFLAGS) -o $@
|
||||
|
||||
lib: $(LIBRARY)
|
||||
|
||||
$(LIBRARY): $(COREOBJ) Makefile
|
||||
$(AR) rcs $@ $(COREOBJ)
|
||||
|
||||
.c.o:
|
||||
$(CC) -c $(CFLAGS) $*.c -o $@
|
||||
|
||||
.s.o:
|
||||
$(CC) -c $(AFLAGS) $*.s -o $@
|
||||
|
||||
clean:
|
||||
touch Makefile
|
||||
rm $(COBJ) $(COREOBJ)
|
||||
rm $(TARGET).exe
|
||||
rm $(LIBRARY)
|
||||
@@ -307,7 +307,7 @@ void RS485_Send_Frame(
|
||||
}
|
||||
|
||||
/* called by timer, interrupt(?) or other thread */
|
||||
void RS485_Check_UART_Data(struct mstp_port_struct_t *mstp_port)
|
||||
void RS485_Check_UART_Data(volatile struct mstp_port_struct_t *mstp_port)
|
||||
{
|
||||
char lpBuf[1];
|
||||
DWORD dwRead = 0;
|
||||
|
||||
@@ -51,7 +51,7 @@ extern "C" {
|
||||
uint8_t * buffer, /* frame to send (up to 501 bytes of data) */
|
||||
uint16_t nbytes); /* number of bytes of data (up to 501) */
|
||||
|
||||
uint8_t RS485_Check_UART_Data(volatile struct mstp_port_struct_t *mstp_port); /* port specific data */
|
||||
void RS485_Check_UART_Data(volatile struct mstp_port_struct_t *mstp_port); /* port specific data */
|
||||
|
||||
uint32_t RS485_Get_Baud_Rate(void);
|
||||
bool RS485_Set_Baud_Rate(uint32_t baud);
|
||||
|
||||
@@ -53,6 +53,8 @@
|
||||
|
||||
/* local port data - shared with RS-485 */
|
||||
volatile struct mstp_port_struct_t MSTP_Port;
|
||||
static uint8_t RxBuffer[MAX_MPDU];
|
||||
static uint8_t TxBuffer[MAX_MPDU];
|
||||
|
||||
void *milliseconds_task(void *pArg)
|
||||
{
|
||||
@@ -137,6 +139,7 @@ int main(int argc, char *argv[])
|
||||
int rc = 0;
|
||||
unsigned long hThread = 0;
|
||||
uint32_t arg_value = 0;
|
||||
int my_mac = 127;
|
||||
|
||||
/* mimic our pointer in the state machine */
|
||||
mstp_port = &MSTP_Port;
|
||||
@@ -144,11 +147,23 @@ int main(int argc, char *argv[])
|
||||
if (argc > 1) {
|
||||
Network_Interface = argv[1];
|
||||
}
|
||||
if (argc > 2) {
|
||||
my_mac = strtol(argv[2], NULL, 0);
|
||||
if (my_mac > 127)
|
||||
my_mac = 127;
|
||||
}
|
||||
/* initialize our interface */
|
||||
RS485_Set_Interface(Network_Interface);
|
||||
RS485_Set_Baud_Rate(38400);
|
||||
RS485_Initialize();
|
||||
MSTP_Init(mstp_port);
|
||||
MSTP_Port.InputBuffer = &RxBuffer[0];
|
||||
MSTP_Port.InputBufferSize = sizeof(RxBuffer);
|
||||
MSTP_Port.OutputBuffer = &TxBuffer[0];
|
||||
MSTP_Port.OutputBufferSize = sizeof(TxBuffer);
|
||||
MSTP_Port.This_Station = my_mac;
|
||||
MSTP_Port.Nmax_info_frames = 1;
|
||||
MSTP_Port.Nmax_master = 127;
|
||||
MSTP_Init(&MSTP_Port);
|
||||
mstp_port->Lurking = true;
|
||||
/* start our MilliSec task */
|
||||
hThread = _beginthread(milliseconds_task,4096,&arg_value);
|
||||
|
||||
Reference in New Issue
Block a user