diff --git a/examples/modbusmaster/mbmaster_main.c b/examples/modbusmaster/mbmaster_main.c index 70e0aa239..4f80f1267 100644 --- a/examples/modbusmaster/mbmaster_main.c +++ b/examples/modbusmaster/mbmaster_main.c @@ -280,7 +280,7 @@ int main(int argc, FAR char *argv[]) if (ret != OK) { - fprintf(stderr, "mbmaster_main: ", + fprintf(stderr, "mbmaster_main: " "ERROR: mbmaster_initialize failed: %d\n", ret); goto errout; } @@ -292,11 +292,15 @@ int main(int argc, FAR char *argv[]) if (ret != OK) { - fprintf(stderr, "mbmaster_main: ", + fprintf(stderr, "mbmaster_main: " "ERROR: mbmaster_pollthread create failed: %d\n", ret); goto errout_with_initialize; } + /* Work around to give time to pthread_create run the modbus poller */ + + usleep(100000); + printf("Sending %d requests to slave %d\n", MBMASTER_REQUESTS_COUNT, SLAVE_ID); diff --git a/include/modbus/mbport.h b/include/modbus/mbport.h index ab4a374f9..eabf23072 100644 --- a/include/modbus/mbport.h +++ b/include/modbus/mbport.h @@ -126,7 +126,7 @@ bool xMBPortEventGet(eMBEventType *eEvent); bool xMBMasterPortEventInit(void); bool xMBMasterPortEventPost(eMBMasterEventType eEvent); -bool xMBMasterPortEventGet(eMBMasterEventType * eEvent); +bool xMBMasterPortEventGet(eMBMasterEventType *eEvent); void vMBMasterOsResInit(void); bool xMBMasterRunResTake(int32_t time); void vMBMasterRunResRelease(void); @@ -138,7 +138,7 @@ bool xMBPortSerialInit(uint8_t ucPort, speed_t ulBaudRate, void vMBPortClose(void); void xMBPortSerialClose(void); void vMBPortSerialEnable(bool xRxEnable, bool xTxEnable); -bool xMBPortSerialGetByte(int8_t * pucByte); +bool xMBPortSerialGetByte(int8_t *pucByte); bool xMBPortSerialPutByte(int8_t ucByte); bool xMBMasterPortSerialInit(uint8_t ucPort, speed_t ulBaudRate, @@ -146,7 +146,7 @@ bool xMBMasterPortSerialInit(uint8_t ucPort, speed_t ulBaudRate, void vMBMasterPortClose(void); void xMBMasterPortSerialClose(void); void vMBMasterPortSerialEnable(bool xRxEnable, bool xTxEnable); -bool xMBMasterPortSerialGetByte(int8_t * pucByte); +bool xMBMasterPortSerialGetByte(int8_t *pucByte); bool xMBMasterPortSerialPutByte(int8_t ucByte); /* Timers functions */ diff --git a/modbus/mb_m.c b/modbus/mb_m.c index 336181136..16323d770 100644 --- a/modbus/mb_m.c +++ b/modbus/mb_m.c @@ -429,6 +429,13 @@ eMBErrorCode eMBMasterPoll(void) vMBMasterRunResRelease(); break; + + case EV_MASTER_PROCESS_SUCCESS: + case EV_MASTER_ERROR_RESPOND_TIMEOUT: + case EV_MASTER_ERROR_RECEIVE_DATA: + case EV_MASTER_ERROR_EXECUTE_FUNCTION: + default: + break; } } diff --git a/modbus/nuttx/portevent_m.c b/modbus/nuttx/portevent_m.c index cc7dd824e..e201ab284 100644 --- a/modbus/nuttx/portevent_m.c +++ b/modbus/nuttx/portevent_m.c @@ -94,7 +94,7 @@ bool xMBMasterPortEventPost(eMBMasterEventType eEvent) return true; } -bool xMBMasterPortEventGet(eMBMasterEventType * eEvent) +bool xMBMasterPortEventGet(eMBMasterEventType *eEvent) { bool xEventHappened = false; @@ -227,7 +227,7 @@ void vMBMasterRunResRelease(void) */ void vMBMasterErrorCBRespondTimeout(uint8_t ucDestAddress, - const uint8_t * pucPDUData, + const uint8_t *pucPDUData, uint16_t usPDULength) { xMBMasterPortEventPost(EV_MASTER_ERROR_RESPOND_TIMEOUT); @@ -243,7 +243,7 @@ void vMBMasterErrorCBRespondTimeout(uint8_t ucDestAddress, */ void vMBMasterErrorCBReceiveData(uint8_t ucDestAddress, - const uint8_t * pudPDUData, + const uint8_t *pudPDUData, uint16_t usPDULength) { xMBMasterPortEventPost(EV_MASTER_ERROR_RECEIVE_DATA); @@ -259,7 +259,7 @@ void vMBMasterErrorCBReceiveData(uint8_t ucDestAddress, */ void vMBMasterErrorCBExecuteFunction(uint8_t ucDestAddress, - const uint8_t * pucPDUData, + const uint8_t *pucPDUData, uint16_t usPDULength) { xMBMasterPortEventPost(EV_MASTER_ERROR_EXECUTE_FUNCTION); diff --git a/modbus/rtu/mbrtu_m.c b/modbus/rtu/mbrtu_m.c index d835b5a7f..3fde50670 100644 --- a/modbus/rtu/mbrtu_m.c +++ b/modbus/rtu/mbrtu_m.c @@ -278,7 +278,7 @@ bool xMBMasterRTUReceiveFSM(void) /* Always read the character. */ - xMBMasterPortSerialGetByte((uint8_t *) & ucByte); + xMBMasterPortSerialGetByte((int8_t *) & ucByte); switch (eRcvState) { @@ -397,6 +397,10 @@ bool xMBMasterRTUTransmitFSM(void) } } break; + + case STATE_M_TX_XFWR: + default: + break; } return xNeedPoll;