modbus_master: fix cmake build warning

Signed-off-by: Jorge Guzman <jorge.gzm@gmail.com>
This commit is contained in:
Jorge Guzman 2024-02-19 19:10:27 -03:00 committed by Xiang Xiao
parent faa8f6666f
commit 90ea9821df
4 changed files with 32 additions and 20 deletions

View File

@ -102,7 +102,6 @@ bool xMBMasterPortEventGet(eMBMasterEventType *eEvent)
if (eQueuedEvent & ~(WAITER_EVENTS)) if (eQueuedEvent & ~(WAITER_EVENTS))
{ {
/* Fetch events by priority */ /* Fetch events by priority */
if (eQueuedEvent & EV_MASTER_READY) if (eQueuedEvent & EV_MASTER_READY)
@ -136,9 +135,9 @@ bool xMBMasterPortEventGet(eMBMasterEventType *eEvent)
else else
{ {
/* Poll the serial device. The serial device timeouts if no characters /* Poll the serial device. The serial device timeouts if no characters
* have been received within for t3.5 during an active transmission or if * have been received within for t3.5 during an active transmission or
* nothing happens within a specified amount of time. Both timeouts are * if nothing happens within a specified amount of time. Both timeouts
* configured from the timer init functions. * are configured from the timer init functions.
*/ */
xMBMasterPortSerialPoll(); xMBMasterPortSerialPoll();
@ -188,6 +187,7 @@ bool xMBMasterRunResTake(int32_t lTimeOut)
{ {
return false; return false;
} }
return true; return true;
} }
else else
@ -198,6 +198,7 @@ bool xMBMasterRunResTake(int32_t lTimeOut)
{ {
return false; return false;
} }
return true; return true;
} }
} }
@ -274,7 +275,8 @@ void vMBMasterCBRequestSuccess(void)
xMBMasterPortEventPost(EV_MASTER_PROCESS_SUCCESS); xMBMasterPortEventPost(EV_MASTER_PROCESS_SUCCESS);
} }
/* This function will wait for Modbus Master request finish and return result. /* This function will wait for Modbus Master request finish
* and return result.
*/ */
eMBMasterReqErrCode eMBMasterWaitRequestFinish(void) eMBMasterReqErrCode eMBMasterWaitRequestFinish(void)
@ -303,6 +305,7 @@ eMBMasterReqErrCode eMBMasterWaitRequestFinish(void)
{ {
eErrStatus = MB_MRE_EXE_FUN; eErrStatus = MB_MRE_EXE_FUN;
} }
eQueuedEvent &= ~WAITER_EVENTS; eQueuedEvent &= ~WAITER_EVENTS;
} }

View File

@ -74,17 +74,21 @@ void vMBPortLogFile(FILE * fNewLogFile)
fLogFile = fNewLogFile; fLogFile = fNewLogFile;
} }
void vMBPortLog(eMBPortLogLevel eLevel, const char * szModule, const char * szFmt, ...) void vMBPortLog(eMBPortLogLevel eLevel, const char * szModule,
const char * szFmt, ...)
{ {
char szBuf[512]; char szBuf[512];
int i; int i;
va_list args; va_list args;
FILE *fOutput = fLogFile == NULL ? stderr : fLogFile; FILE *fOutput = fLogFile == NULL ? stderr : fLogFile;
static const char *arszLevel2Str[] = { "ERROR", "WARN", "INFO", "DEBUG" }; static const char *arszLevel2Str[] =
{
i = snprintf(szBuf, NELEMS(szBuf), "%s: %s: ", arszLevel2Str[eLevel], szModule); "ERROR", "WARN", "INFO", "DEBUG"
};
i = snprintf(szBuf, NELEMS(szBuf), "%s: %s: ",
arszLevel2Str[eLevel], szModule);
if (i != 0) if (i != 0)
{ {
va_start(args, szFmt); va_start(args, szFmt);
@ -106,7 +110,8 @@ void vMBPortEnterCritical(void)
int ret = pthread_mutex_lock(&xLock); int ret = pthread_mutex_lock(&xLock);
if (ret != 0) if (ret != 0)
{ {
vMBPortLog(MB_LOG_ERROR, "OTHER", "Locking primitive failed: %d\n", ret); vMBPortLog(MB_LOG_ERROR, "OTHER",
"Locking primitive failed: %d\n", ret);
} }
} }
@ -115,6 +120,7 @@ void vMBPortExitCritical(void)
int ret = pthread_mutex_unlock(&xLock); int ret = pthread_mutex_unlock(&xLock);
if (ret != 0) if (ret != 0)
{ {
vMBPortLog(MB_LOG_ERROR, "OTHER", "Locking primitive failed: %d\n", ret); vMBPortLog(MB_LOG_ERROR,
"OTHER", "Locking primitive failed: %d\n", ret);
} }
} }

View File

@ -84,7 +84,10 @@ void vMBMasterPortLog(eMBPortLogLevel eLevel, const char * szModule,
va_list args; va_list args;
FILE *fOutput = fLogFile == NULL ? stderr : fLogFile; FILE *fOutput = fLogFile == NULL ? stderr : fLogFile;
static const char *arszLevel2Str[] = { "ERROR", "WARN", "INFO", "DEBUG" }; static const char *arszLevel2Str[] =
{
"ERROR", "WARN", "INFO", "DEBUG"
};
i = snprintf(szBuf, NELEMS(szBuf), i = snprintf(szBuf, NELEMS(szBuf),
"%s: %s: ", arszLevel2Str[eLevel], szModule); "%s: %s: ", arszLevel2Str[eLevel], szModule);

View File

@ -75,7 +75,7 @@ bool bTimeoutEnable; /* timeout is active */
* Private Functions * Private Functions
****************************************************************************/ ****************************************************************************/
void vMBMasterPortTimersEnable( void ) void vMBMasterPortTimersEnable(void)
{ {
int res = gettimeofday(&xTimeLast, NULL); int res = gettimeofday(&xTimeLast, NULL);
@ -114,33 +114,33 @@ bool xMBMasterPortTimersInit(uint16_t usTimeOut50us)
return xMBMasterPortSerialSetTimeout(ulTimeOut); return xMBMasterPortSerialSetTimeout(ulTimeOut);
} }
void xMBMasterPortTimersClose() void xMBMasterPortTimersClose(void)
{ {
/* Does not use any hardware resources. */ /* Does not use any hardware resources. */
} }
INLINE void vMBMasterPortTimersT35Enable( void ) INLINE void vMBMasterPortTimersT35Enable(void)
{ {
vMBMasterPortTimersEnable(); vMBMasterPortTimersEnable();
ulTimeOut = ulTimeoutT35; ulTimeOut = ulTimeoutT35;
vMBMasterSetCurTimerMode(MB_TMODE_T35); vMBMasterSetCurTimerMode(MB_TMODE_T35);
} }
INLINE void vMBMasterPortTimersConvertDelayEnable( void ) INLINE void vMBMasterPortTimersConvertDelayEnable(void)
{ {
vMBMasterPortTimersEnable(); vMBMasterPortTimersEnable();
ulTimeOut = ulTimeoutConvertDelay; ulTimeOut = ulTimeoutConvertDelay;
vMBMasterSetCurTimerMode(MB_TMODE_CONVERT_DELAY); vMBMasterSetCurTimerMode(MB_TMODE_CONVERT_DELAY);
} }
INLINE void vMBMasterPortTimersRespondTimeoutEnable( void ) INLINE void vMBMasterPortTimersRespondTimeoutEnable(void)
{ {
vMBMasterPortTimersEnable(); vMBMasterPortTimersEnable();
ulTimeOut = ulTimeoutResponse; ulTimeOut = ulTimeoutResponse;
vMBMasterSetCurTimerMode( MB_TMODE_RESPOND_TIMEOUT ); vMBMasterSetCurTimerMode(MB_TMODE_RESPOND_TIMEOUT);
} }
void vMBMasterPortTimerPoll( void ) void vMBMasterPortTimerPoll(void)
{ {
uint32_t ulDeltaMS; uint32_t ulDeltaMS;
struct timeval xTimeCur; struct timeval xTimeCur;
@ -168,7 +168,7 @@ void vMBMasterPortTimerPoll( void )
} }
} }
void vMBMasterPortTimersDisable() void vMBMasterPortTimersDisable(void)
{ {
bTimeoutEnable = false; bTimeoutEnable = false;
} }