Added some print info the mstpcap demo like packet count, baud rate, and interface.
This commit is contained in:
@@ -27,8 +27,9 @@ ifeq (${BACNET_PORT},win32)
|
|||||||
TARGET_BIN = ${TARGET}.exe
|
TARGET_BIN = ${TARGET}.exe
|
||||||
LIBRARIES=-lws2_32,-lgcc,-lm,-liphlpapi
|
LIBRARIES=-lws2_32,-lgcc,-lm,-liphlpapi
|
||||||
endif
|
endif
|
||||||
DEBUGGING = -g
|
#DEBUGGING = -g
|
||||||
OPTIMIZATION = -O0
|
#OPTIMIZATION = -O0
|
||||||
|
OPTIMIZATION = -Os
|
||||||
CFLAGS = -Wall $(DEBUGGING) $(OPTIMIZATION) $(INCLUDES) $(DEFINES) -fdata-sections -ffunction-sections
|
CFLAGS = -Wall $(DEBUGGING) $(OPTIMIZATION) $(INCLUDES) $(DEFINES) -fdata-sections -ffunction-sections
|
||||||
LFLAGS = -Wl,-Map=$(TARGET).map,$(LIBRARIES),--gc-sections
|
LFLAGS = -Wl,-Map=$(TARGET).map,$(LIBRARIES),--gc-sections
|
||||||
|
|
||||||
|
|||||||
@@ -170,7 +170,7 @@ static void write_global_header(void)
|
|||||||
fprintf(stdout,"mstpcap: saving capture to %s\n",
|
fprintf(stdout,"mstpcap: saving capture to %s\n",
|
||||||
Capture_Filename);
|
Capture_Filename);
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr,"rx_fsm: failed to open %s: %s\n",
|
fprintf(stderr,"mstpcap: failed to open %s: %s\n",
|
||||||
Capture_Filename, strerror(errno));
|
Capture_Filename, strerror(errno));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -209,11 +209,11 @@ static void write_received_packet(
|
|||||||
fwrite(header,sizeof(header),1,pFile);
|
fwrite(header,sizeof(header),1,pFile);
|
||||||
if (mstp_port->DataLength) {
|
if (mstp_port->DataLength) {
|
||||||
fwrite(mstp_port->InputBuffer,mstp_port->DataLength,1,pFile);
|
fwrite(mstp_port->InputBuffer,mstp_port->DataLength,1,pFile);
|
||||||
fwrite(&(mstp_port->DataCRCActualMSB),1,1,pFile);
|
fwrite((char *)&mstp_port->DataCRCActualMSB,1,1,pFile);
|
||||||
fwrite(&(mstp_port->DataCRCActualLSB),1,1,pFile);
|
fwrite((char *)&mstp_port->DataCRCActualLSB,1,1,pFile);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr,"rx_fsm: failed to open %s: %s\n",
|
fprintf(stderr,"mstpcap: failed to open %s: %s\n",
|
||||||
Capture_Filename, strerror(errno));
|
Capture_Filename, strerror(errno));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -252,6 +252,7 @@ int main(
|
|||||||
volatile struct mstp_port_struct_t *mstp_port;
|
volatile struct mstp_port_struct_t *mstp_port;
|
||||||
int my_mac = 127;
|
int my_mac = 127;
|
||||||
long my_baud = 38400;
|
long my_baud = 38400;
|
||||||
|
uint32_t packet_count = 0;
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
unsigned long hThread = 0;
|
unsigned long hThread = 0;
|
||||||
uint32_t arg_value = 0;
|
uint32_t arg_value = 0;
|
||||||
@@ -287,6 +288,8 @@ int main(
|
|||||||
MSTP_Port.SilenceTimerReset = Timer_Silence_Reset;
|
MSTP_Port.SilenceTimerReset = Timer_Silence_Reset;
|
||||||
MSTP_Init(mstp_port);
|
MSTP_Init(mstp_port);
|
||||||
mstp_port->Lurking = true;
|
mstp_port->Lurking = true;
|
||||||
|
fprintf(stdout,"mstpcap: Using %s for capture at %lu bps.\n",
|
||||||
|
RS485_Interface(), RS485_Get_Baud_Rate());
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
hThread = _beginthread(milliseconds_task, 4096, &arg_value);
|
hThread = _beginthread(milliseconds_task, 4096, &arg_value);
|
||||||
if (hThread == 0) {
|
if (hThread == 0) {
|
||||||
@@ -309,10 +312,15 @@ int main(
|
|||||||
if (mstp_port->ReceivedValidFrame) {
|
if (mstp_port->ReceivedValidFrame) {
|
||||||
mstp_port->ReceivedValidFrame = false;
|
mstp_port->ReceivedValidFrame = false;
|
||||||
write_received_packet(mstp_port);
|
write_received_packet(mstp_port);
|
||||||
|
packet_count++;
|
||||||
} else if (mstp_port->ReceivedInvalidFrame) {
|
} else if (mstp_port->ReceivedInvalidFrame) {
|
||||||
mstp_port->ReceivedInvalidFrame = false;
|
mstp_port->ReceivedInvalidFrame = false;
|
||||||
fprintf(stderr, "ReceivedInvalidFrame\n");
|
fprintf(stderr, "ReceivedInvalidFrame\n");
|
||||||
write_received_packet(mstp_port);
|
write_received_packet(mstp_port);
|
||||||
|
packet_count++;
|
||||||
|
}
|
||||||
|
if (!(packet_count % 100)) {
|
||||||
|
fprintf(stdout,"\r%hu packets",packet_count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -80,7 +80,20 @@ void RS485_Set_Interface(
|
|||||||
char *ifname)
|
char *ifname)
|
||||||
{
|
{
|
||||||
/* note: expects a constant char, or char from the heap */
|
/* note: expects a constant char, or char from the heap */
|
||||||
RS485_Port_Name = ifname;
|
if (ifname) {
|
||||||
|
RS485_Port_Name = ifname;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*********************************************************************
|
||||||
|
* DESCRIPTION: Returns the interface name
|
||||||
|
* RETURN: none
|
||||||
|
* ALGORITHM: none
|
||||||
|
* NOTES: none
|
||||||
|
*********************************************************************/
|
||||||
|
const char *RS485_Interface(void)
|
||||||
|
{
|
||||||
|
return RS485_Port_Name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ extern "C" {
|
|||||||
|
|
||||||
void RS485_Set_Interface(
|
void RS485_Set_Interface(
|
||||||
char *ifname);
|
char *ifname);
|
||||||
|
const char * RS485_Interface(void);
|
||||||
|
|
||||||
void RS485_Initialize(
|
void RS485_Initialize(
|
||||||
void);
|
void);
|
||||||
|
|||||||
@@ -92,7 +92,14 @@ void RS485_Set_Interface(
|
|||||||
char *ifname)
|
char *ifname)
|
||||||
{
|
{
|
||||||
/* note: expects a constant char, or char from the heap */
|
/* note: expects a constant char, or char from the heap */
|
||||||
RS485_Port_Name = ifname;
|
if (ifname) {
|
||||||
|
RS485_Port_Name = ifname;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *RS485_Interface(void)
|
||||||
|
{
|
||||||
|
return RS485_Port_Name;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void RS485_Print_Error(
|
static void RS485_Print_Error(
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ extern "C" {
|
|||||||
|
|
||||||
void RS485_Set_Interface(
|
void RS485_Set_Interface(
|
||||||
char *ifname);
|
char *ifname);
|
||||||
|
const char * RS485_Interface(void);
|
||||||
|
|
||||||
void RS485_Initialize(
|
void RS485_Initialize(
|
||||||
void);
|
void);
|
||||||
|
|||||||
Reference in New Issue
Block a user