Feature/mstp valid frame not for us stats (#1053)
* Fixed ISO C90 forbids mixed declarations and code warning. * Fixed the MS/TP invalid frame counter that was incremented for valid frames not for us.
This commit is contained in:
@@ -67,6 +67,7 @@ static struct mstimer Valid_Frame_Timer;
|
||||
/* callbacks for monitoring */
|
||||
static dlmstp_hook_frame_rx_start_cb Preamble_Callback;
|
||||
static dlmstp_hook_frame_rx_complete_cb Valid_Frame_Rx_Callback;
|
||||
static dlmstp_hook_frame_rx_complete_cb Valid_Frame_Not_For_Us_Rx_Callback;
|
||||
static dlmstp_hook_frame_rx_complete_cb Invalid_Frame_Rx_Callback;
|
||||
static DLMSTP_STATISTICS DLMSTP_Statistics;
|
||||
|
||||
@@ -498,6 +499,7 @@ static void *dlmstp_thread(void *pArg)
|
||||
while (thread_alive) {
|
||||
/* only do receive state machine while we don't have a frame */
|
||||
if ((MSTP_Port.ReceivedValidFrame == false) &&
|
||||
(MSTP_Port.ReceivedValidFrameNotForUs == false) &&
|
||||
(MSTP_Port.ReceivedInvalidFrame == false)) {
|
||||
RS485_Check_UART_Data(&MSTP_Port);
|
||||
MSTP_Receive_Frame_FSM(&MSTP_Port);
|
||||
@@ -516,6 +518,15 @@ static void *dlmstp_thread(void *pArg)
|
||||
MSTP_Port.DataLength);
|
||||
}
|
||||
run_master = true;
|
||||
} else if (MSTP_Port.ReceivedValidFrameNotForUs) {
|
||||
DLMSTP_Statistics.receive_valid_frame_not_for_us_counter++;
|
||||
if (Valid_Frame_Not_For_Us_Rx_Callback) {
|
||||
Valid_Frame_Not_For_Us_Rx_Callback(
|
||||
MSTP_Port.SourceAddress, MSTP_Port.DestinationAddress,
|
||||
MSTP_Port.FrameType, MSTP_Port.InputBuffer,
|
||||
MSTP_Port.DataLength);
|
||||
}
|
||||
run_master = true;
|
||||
} else if (MSTP_Port.ReceivedInvalidFrame) {
|
||||
if (Invalid_Frame_Rx_Callback) {
|
||||
DLMSTP_Statistics.receive_invalid_frame_counter++;
|
||||
@@ -872,6 +883,26 @@ void dlmstp_set_frame_rx_complete_callback(
|
||||
Valid_Frame_Rx_Callback = cb_func;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set the MS/TP Frame Complete callback
|
||||
* @param cb_func - callback function to be called when a frame is received
|
||||
*/
|
||||
void dlmstp_set_frame_not_for_us_rx_complete_callback(
|
||||
dlmstp_hook_frame_rx_complete_cb cb_func)
|
||||
{
|
||||
Valid_Frame_Not_For_Us_Rx_Callback = cb_func;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set the MS/TP Frame Complete callback
|
||||
* @param cb_func - callback function to be called when a frame is received
|
||||
*/
|
||||
void dlmstp_set_invalid_frame_rx_complete_callback(
|
||||
dlmstp_hook_frame_rx_complete_cb cb_func)
|
||||
{
|
||||
Invalid_Frame_Rx_Callback = cb_func;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set the MS/TP Frame Complete callback
|
||||
* @param cb_func - callback function to be called when a frame is received
|
||||
|
||||
Reference in New Issue
Block a user