debug modbus slave

This commit is contained in:
wmano
2025-09-10 23:03:11 +08:00
parent 7b764c34b9
commit 485e535c4d
28 changed files with 507 additions and 449 deletions
+4 -2
View File
@@ -32,7 +32,7 @@
#define _MB_ASCII_H
#ifdef __cplusplus
PR_BEGIN_EXTERN_C
extern "C" {
#endif
#if MB_SLAVE_ASCII_ENABLED > 0
@@ -51,6 +51,8 @@ BOOL xMBASCIITimerT1SExpired( void );
#endif
#ifdef __cplusplus
PR_END_EXTERN_C
}
#endif
#endif
+4 -2
View File
@@ -34,7 +34,7 @@
#include "port.h"
#ifdef __cplusplus
PR_BEGIN_EXTERN_C
extern "C" {
#endif
#include "mbport.h"
@@ -412,6 +412,8 @@ eMBErrorCode eMBRegDiscreteCB( UCHAR * pucRegBuffer, USHORT usAddress,
USHORT usNDiscrete );
#ifdef __cplusplus
PR_END_EXTERN_C
}
#endif
#endif
+4 -2
View File
@@ -32,7 +32,7 @@
#define _MB_M_H
#ifdef __cplusplus
PR_BEGIN_EXTERN_C
extern "C" {
#endif
/*! \defgroup modbus Modbus
@@ -409,6 +409,8 @@ eMBMasterReqErrCode eMBMasterWaitRequestFinish( void );
/* ----------------------- Callback -----------------------------------------*/
#ifdef __cplusplus
PR_END_EXTERN_C
}
#endif
#endif
+4 -2
View File
@@ -33,7 +33,7 @@
#define _MB_CONFIG_H
#ifdef __cplusplus
PR_BEGIN_EXTERN_C
extern "C" {
#endif
/* ----------------------- Defines ------------------------------------------*/
/*! \defgroup modbus_cfg Modbus Configuration
@@ -124,7 +124,7 @@ PR_BEGIN_EXTERN_C
#define MB_FUNC_READWRITE_HOLDING_ENABLED ( 1 )
/*! @} */
#ifdef __cplusplus
PR_END_EXTERN_C
}
#endif
#if MB_MASTER_RTU_ENABLED > 0 || MB_MASTER_ASCII_ENABLED > 0
@@ -141,3 +141,5 @@ PR_BEGIN_EXTERN_C
#endif
#endif
+4 -2
View File
@@ -32,7 +32,7 @@
#define _MB_FRAME_H
#ifdef __cplusplus
PR_BEGIN_EXTERN_C
extern "C" {
#endif
/*!
@@ -82,6 +82,8 @@ typedef eMBErrorCode( *peMBFrameSend ) ( UCHAR slaveAddress,
typedef void( *pvMBFrameClose ) ( void );
#ifdef __cplusplus
PR_END_EXTERN_C
}
#endif
#endif
+4 -2
View File
@@ -32,7 +32,7 @@
#define _MB_FUNC_H
#ifdef __cplusplus
PR_BEGIN_EXTERN_C
extern "C" {
#endif
#if MB_FUNC_OTHER_REP_SLAVEID_BUF > 0
eMBException eMBFuncReportSlaveID( UCHAR * pucFrame, USHORT * usLen );
@@ -75,6 +75,8 @@ eMBException eMBFuncReadWriteMultipleHoldingRegister( UCHAR * pucFrame, USHOR
#endif
#ifdef __cplusplus
PR_END_EXTERN_C
}
#endif
#endif
+4 -2
View File
@@ -33,7 +33,7 @@
#define _MB_PORT_H
#ifdef __cplusplus
PR_BEGIN_EXTERN_C
extern "C" {
#endif
/* ----------------------- Defines ------------------------------------------*/
@@ -200,6 +200,8 @@ BOOL xMBTCPPortGetRequest( UCHAR **ppucMBTCPFrame, USHORT * usTCPLeng
BOOL xMBTCPPortSendResponse( const UCHAR *pucMBTCPFrame, USHORT usTCPLength );
#ifdef __cplusplus
PR_END_EXTERN_C
}
#endif
#endif
+4 -2
View File
@@ -32,7 +32,7 @@
#define _MB_PROTO_H
#ifdef __cplusplus
PR_BEGIN_EXTERN_C
extern "C" {
#endif
/* ----------------------- Defines ------------------------------------------*/
#define MB_ADDRESS_BROADCAST ( 0 ) /*! Modbus broadcast address. */
@@ -78,6 +78,8 @@ typedef struct
} xMBFunctionHandler;
#ifdef __cplusplus
PR_END_EXTERN_C
}
#endif
#endif
+4 -2
View File
@@ -32,7 +32,7 @@
#define _MB_UTILS_H
#ifdef __cplusplus
PR_BEGIN_EXTERN_C
extern "C" {
#endif
/*! \defgroup modbus_utils Utilities
*
@@ -103,6 +103,8 @@ UCHAR xMBUtilGetBits( UCHAR * ucByteBuf, USHORT usBitOffset,
/*! @} */
#ifdef __cplusplus
PR_END_EXTERN_C
}
#endif
#endif
+3 -3
View File
@@ -61,7 +61,7 @@
/* ----------------------- Static variables ---------------------------------*/
static UCHAR ucMBAddress;
static eMBMode eMBCurrentMode;
//static eMBMode eMBCurrentMode;
static enum
{
@@ -188,7 +188,7 @@ eMBInit( eMBMode eMode, UCHAR ucSlaveAddress, UCHAR ucPort, ULONG ulBaudRate, eM
}
else
{
eMBCurrentMode = eMode;
// eMBCurrentMode = eMode;
eMBState = STATE_DISABLED;
}
}
@@ -219,7 +219,7 @@ eMBTCPInit( USHORT ucTCPPort )
peMBFrameSendCur = eMBTCPSend;
pvMBFrameCloseCur = MB_PORT_HAS_CLOSE ? vMBTCPPortClose : NULL;
ucMBAddress = MB_TCP_PSEUDO_ADDRESS;
eMBCurrentMode = MB_TCP;
// eMBCurrentMode = MB_TCP;
eMBState = STATE_DISABLED;
}
return eStatus;
+4 -2
View File
@@ -34,7 +34,7 @@
#define _MB_RTU_H
#ifdef __cplusplus
PR_BEGIN_EXTERN_C
extern "C" {
#endif
eMBErrorCode eMBRTUInit( UCHAR slaveAddress, UCHAR ucPort, ULONG ulBaudRate,
eMBParity eParity );
@@ -59,6 +59,8 @@ BOOL xMBMasterRTUTimerExpired( void );
#endif
#ifdef __cplusplus
PR_END_EXTERN_C
}
#endif
#endif
+4 -2
View File
@@ -32,7 +32,7 @@
#define _MB_TCP_H
#ifdef __cplusplus
PR_BEGIN_EXTERN_C
extern "C" {
#endif
/* ----------------------- Defines ------------------------------------------*/
@@ -48,6 +48,8 @@ eMBErrorCode eMBTCPSend( UCHAR _unused, const UCHAR * pucFrame,
USHORT usLength );
#ifdef __cplusplus
PR_END_EXTERN_C
}
#endif
#endif