From e0102243f5599a62be55e3814f87f82bec738624 Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Tue, 10 Nov 2020 18:40:01 +1100 Subject: [PATCH] Whitespace: Automated whitespace fixes (large commit) Apply the pre-commit hook whitespace fixes to all files in the repo. (Line endings, blank lines at end of file, trailing whitespace) * Original commit: espressif/esp-idf@66fb5a29bbdc2482d67c52e6f66b303378c9b789 --- .../freemodbus/common/esp_modbus_master.c | 22 +++--- .../freemodbus/common/esp_modbus_slave.c | 44 ++++++------ .../common/esp_modbus_slave_serial.c | 1 - .../common/include/esp_modbus_common.h | 1 - components/freemodbus/component.mk | 4 +- components/freemodbus/modbus/ascii/mbascii.c | 6 +- components/freemodbus/modbus/ascii/mbascii.h | 2 +- .../freemodbus/modbus/ascii/mbascii_m.c | 42 ++++++------ .../freemodbus/modbus/functions/mbfunccoils.c | 8 +-- .../modbus/functions/mbfunccoils_m.c | 4 +- .../freemodbus/modbus/functions/mbfuncdiag.c | 2 +- .../freemodbus/modbus/functions/mbfuncdisc.c | 4 +- .../modbus/functions/mbfuncdisc_m.c | 2 +- .../modbus/functions/mbfuncholding.c | 4 +- .../modbus/functions/mbfuncholding_m.c | 3 +- .../freemodbus/modbus/functions/mbfuncinput.c | 4 +- .../modbus/functions/mbfuncinput_m.c | 2 +- .../freemodbus/modbus/functions/mbfuncother.c | 2 +- .../freemodbus/modbus/functions/mbutils.c | 2 +- components/freemodbus/modbus/include/mb.h | 40 +++++------ components/freemodbus/modbus/include/mb_m.h | 18 ++--- .../freemodbus/modbus/include/mbconfig.h | 4 +- .../freemodbus/modbus/include/mbframe.h | 2 +- components/freemodbus/modbus/include/mbfunc.h | 2 +- components/freemodbus/modbus/include/mbport.h | 2 +- .../freemodbus/modbus/include/mbproto.h | 2 +- .../freemodbus/modbus/include/mbutils.h | 2 +- components/freemodbus/modbus/mb.c | 6 +- components/freemodbus/modbus/mb_m.c | 4 +- components/freemodbus/modbus/rtu/mbcrc.c | 12 ++-- components/freemodbus/modbus/rtu/mbcrc.h | 2 +- components/freemodbus/modbus/rtu/mbrtu.c | 2 +- components/freemodbus/modbus/rtu/mbrtu.h | 2 +- components/freemodbus/modbus/rtu/mbrtu_m.c | 6 +- components/freemodbus/modbus/tcp/mbtcp.c | 14 ++-- components/freemodbus/modbus/tcp/mbtcp.h | 2 +- components/freemodbus/modbus/tcp/mbtcp_m.c | 14 ++-- components/freemodbus/modbus/tcp/mbtcp_m.h | 2 +- components/freemodbus/port/portevent.c | 5 +- components/freemodbus/port/portevent_m.c | 6 +- components/freemodbus/port/portother.c | 4 +- components/freemodbus/port/portother_m.c | 1 - components/freemodbus/port/portserial.c | 3 +- .../modbus_controller/mbc_serial_master.c | 68 +++++++++---------- .../modbus_controller/mbc_serial_master.h | 1 - .../modbus_controller/mbc_serial_slave.c | 19 +++--- .../modbus_controller/mbc_serial_slave.h | 1 - .../modbus_controller/mbc_tcp_master.c | 2 +- .../modbus_controller/mbc_tcp_master.h | 1 - .../modbus_controller/mbc_tcp_slave.h | 1 - .../tcp_slave/port/port_tcp_slave.c | 1 - .../modbus/mb_example_common/CMakeLists.txt | 2 +- .../modbus/mb_example_common/component.mk | 2 +- .../modbus/mb_example_common/modbus_params.c | 1 - .../modbus/serial/mb_master/Makefile | 1 - .../serial/mb_master/main/CMakeLists.txt | 1 - .../modbus/serial/mb_master/main/master.c | 14 ++-- .../protocols/modbus/serial/mb_slave/Makefile | 1 - .../serial/mb_slave/main/CMakeLists.txt | 2 +- .../modbus/serial/mb_slave/main/slave.c | 4 +- .../tcp/mb_tcp_master/main/CMakeLists.txt | 1 - .../tcp/mb_tcp_master/main/tcp_master.c | 22 +++--- .../tcp/mb_tcp_master/sdkconfig.defaults | 2 +- .../modbus/tcp/mb_tcp_slave/Makefile | 1 - .../tcp/mb_tcp_slave/main/CMakeLists.txt | 2 +- .../tcp/mb_tcp_slave/main/Kconfig.projbuild | 2 +- .../modbus/tcp/mb_tcp_slave/main/tcp_slave.c | 4 +- .../tcp/mb_tcp_slave/sdkconfig.defaults | 2 +- 68 files changed, 227 insertions(+), 247 deletions(-) diff --git a/components/freemodbus/common/esp_modbus_master.c b/components/freemodbus/common/esp_modbus_master.c index eee3608..2684d0e 100644 --- a/components/freemodbus/common/esp_modbus_master.c +++ b/components/freemodbus/common/esp_modbus_master.c @@ -18,7 +18,7 @@ #include "esp_modbus_master.h" // for public interface defines #include "esp_modbus_callbacks.h" // for callback functions -// This file implements public API for Modbus master controller. +// This file implements public API for Modbus master controller. // These functions are wrappers for interface functions of the controller static mb_master_interface_t* master_interface_ptr = NULL; @@ -40,8 +40,8 @@ esp_err_t mbc_master_destroy(void) ESP_ERR_INVALID_STATE, "Master interface is not correctly initialized."); error = master_interface_ptr->destroy(); - MB_MASTER_CHECK((error == ESP_OK), - error, + MB_MASTER_CHECK((error == ESP_OK), + error, "Master destroy failure, error=(0x%x).", error); return error; @@ -57,8 +57,8 @@ esp_err_t mbc_master_get_cid_info(uint16_t cid, const mb_parameter_descriptor_t* ESP_ERR_INVALID_STATE, "Master interface is not correctly initialized."); error = master_interface_ptr->get_cid_info(cid, param_info); - MB_MASTER_CHECK((error == ESP_OK), - error, + MB_MASTER_CHECK((error == ESP_OK), + error, "Master get cid info failure, error=(0x%x).", error); return error; @@ -77,7 +77,7 @@ esp_err_t mbc_master_get_parameter(uint16_t cid, char* name, uint8_t* value, uin ESP_ERR_INVALID_STATE, "Master interface is not correctly initialized."); error = master_interface_ptr->get_parameter(cid, name, value, type); - MB_MASTER_CHECK((error == ESP_OK), + MB_MASTER_CHECK((error == ESP_OK), error, "Master get parameter failure, error=(0x%x) (%s).", error, esp_err_to_name(error)); @@ -97,7 +97,7 @@ esp_err_t mbc_master_send_request(mb_param_request_t* request, void* data_ptr) ESP_ERR_INVALID_STATE, "Master interface is not correctly initialized."); error = master_interface_ptr->send_request(request, data_ptr); - MB_MASTER_CHECK((error == ESP_OK), + MB_MASTER_CHECK((error == ESP_OK), error, "Master send request failure error=(0x%x) (%s).", error, esp_err_to_name(error)); @@ -118,7 +118,7 @@ esp_err_t mbc_master_set_descriptor(const mb_parameter_descriptor_t* descriptor, ESP_ERR_INVALID_STATE, "Master interface is not correctly initialized."); error = master_interface_ptr->set_descriptor(descriptor, num_elements); - MB_MASTER_CHECK((error == ESP_OK), + MB_MASTER_CHECK((error == ESP_OK), error, "Master set descriptor failure, error=(0x%x) (%s).", error, esp_err_to_name(error)); @@ -138,7 +138,7 @@ esp_err_t mbc_master_set_parameter(uint16_t cid, char* name, uint8_t* value, uin ESP_ERR_INVALID_STATE, "Master interface is not correctly initialized."); error = master_interface_ptr->set_parameter(cid, name, value, type); - MB_MASTER_CHECK((error == ESP_OK), + MB_MASTER_CHECK((error == ESP_OK), error, "Master set parameter failure, error=(0x%x) (%s).", error, esp_err_to_name(error)); @@ -158,7 +158,7 @@ esp_err_t mbc_master_setup(void* comm_info) ESP_ERR_INVALID_STATE, "Master interface is not correctly initialized."); error = master_interface_ptr->setup(comm_info); - MB_MASTER_CHECK((error == ESP_OK), + MB_MASTER_CHECK((error == ESP_OK), error, "Master setup failure, error=(0x%x) (%s).", error, esp_err_to_name(error)); @@ -178,7 +178,7 @@ esp_err_t mbc_master_start(void) ESP_ERR_INVALID_STATE, "Master interface is not correctly initialized."); error = master_interface_ptr->start(); - MB_MASTER_CHECK((error == ESP_OK), + MB_MASTER_CHECK((error == ESP_OK), error, "Master start failure, error=(0x%x) (%s).", error, esp_err_to_name(error)); diff --git a/components/freemodbus/common/esp_modbus_slave.c b/components/freemodbus/common/esp_modbus_slave.c index 57a54ef..85a869e 100644 --- a/components/freemodbus/common/esp_modbus_slave.c +++ b/components/freemodbus/common/esp_modbus_slave.c @@ -56,13 +56,13 @@ esp_err_t mbc_slave_destroy(void) ESP_ERR_INVALID_STATE, "Slave interface is not correctly initialized."); // Check if interface has been initialized - MB_SLAVE_CHECK((slave_interface_ptr->destroy != NULL), + MB_SLAVE_CHECK((slave_interface_ptr->destroy != NULL), ESP_ERR_INVALID_STATE, "Slave interface is not correctly initialized."); // Call the slave port destroy function error = slave_interface_ptr->destroy(); - MB_SLAVE_CHECK((error == ESP_OK), - ESP_ERR_INVALID_STATE, + MB_SLAVE_CHECK((error == ESP_OK), + ESP_ERR_INVALID_STATE, "Slave destroy failure error=(0x%x).", error); return error; @@ -77,12 +77,12 @@ esp_err_t mbc_slave_setup(void* comm_info) MB_SLAVE_CHECK((slave_interface_ptr != NULL), ESP_ERR_INVALID_STATE, "Slave interface is not correctly initialized."); - MB_SLAVE_CHECK((slave_interface_ptr->setup != NULL), + MB_SLAVE_CHECK((slave_interface_ptr->setup != NULL), ESP_ERR_INVALID_STATE, "Slave interface is not correctly initialized."); error = slave_interface_ptr->setup(comm_info); - MB_SLAVE_CHECK((error == ESP_OK), - ESP_ERR_INVALID_STATE, + MB_SLAVE_CHECK((error == ESP_OK), + ESP_ERR_INVALID_STATE, "Slave setup failure error=(0x%x).", error); return error; @@ -97,7 +97,7 @@ esp_err_t mbc_slave_start(void) MB_SLAVE_CHECK((slave_interface_ptr != NULL), ESP_ERR_INVALID_STATE, "Slave interface is not correctly initialized."); - MB_SLAVE_CHECK((slave_interface_ptr->start != NULL), + MB_SLAVE_CHECK((slave_interface_ptr->start != NULL), ESP_ERR_INVALID_STATE, "Slave interface is not correctly initialized."); #ifdef CONFIG_FMB_CONTROLLER_SLAVE_ID_SUPPORT @@ -106,12 +106,12 @@ esp_err_t mbc_slave_start(void) MB_SLAVE_CHECK((status == MB_ENOERR), ESP_ERR_INVALID_STATE, "mb stack set slave ID failure."); #endif error = slave_interface_ptr->start(); - MB_SLAVE_CHECK((error == ESP_OK), - ESP_ERR_INVALID_STATE, + MB_SLAVE_CHECK((error == ESP_OK), + ESP_ERR_INVALID_STATE, "Slave start failure error=(0x%x).", error); return error; -} +} /** * Blocking function to get event on parameter group change for application task @@ -121,7 +121,7 @@ mb_event_group_t mbc_slave_check_event(mb_event_group_t group) MB_SLAVE_CHECK((slave_interface_ptr != NULL), MB_EVENT_NO_EVENTS, "Slave interface is not correctly initialized."); - MB_SLAVE_CHECK((slave_interface_ptr->check_event != NULL), + MB_SLAVE_CHECK((slave_interface_ptr->check_event != NULL), MB_EVENT_NO_EVENTS, "Slave interface is not correctly initialized."); mb_event_group_t event = slave_interface_ptr->check_event(group); @@ -137,12 +137,12 @@ esp_err_t mbc_slave_get_param_info(mb_param_info_t* reg_info, uint32_t timeout) MB_SLAVE_CHECK((slave_interface_ptr != NULL), ESP_ERR_INVALID_STATE, "Slave interface is not correctly initialized."); - MB_SLAVE_CHECK((slave_interface_ptr->get_param_info != NULL), + MB_SLAVE_CHECK((slave_interface_ptr->get_param_info != NULL), ESP_ERR_INVALID_STATE, "Slave interface is not correctly initialized."); error = slave_interface_ptr->get_param_info(reg_info, timeout); - MB_SLAVE_CHECK((error == ESP_OK), - ESP_ERR_INVALID_STATE, + MB_SLAVE_CHECK((error == ESP_OK), + ESP_ERR_INVALID_STATE, "Slave get parameter info failure error=(0x%x).", error); return error; @@ -157,12 +157,12 @@ esp_err_t mbc_slave_set_descriptor(mb_register_area_descriptor_t descr_data) MB_SLAVE_CHECK((slave_interface_ptr != NULL), ESP_ERR_INVALID_STATE, "Slave interface is not correctly initialized."); - MB_SLAVE_CHECK((slave_interface_ptr->set_descriptor != NULL), + MB_SLAVE_CHECK((slave_interface_ptr->set_descriptor != NULL), ESP_ERR_INVALID_STATE, "Slave interface is not correctly initialized."); error = slave_interface_ptr->set_descriptor(descr_data); - MB_SLAVE_CHECK((error == ESP_OK), - ESP_ERR_INVALID_STATE, + MB_SLAVE_CHECK((error == ESP_OK), + ESP_ERR_INVALID_STATE, "Slave set descriptor failure error=(0x%x).", (uint16_t)error); return error; @@ -178,11 +178,11 @@ eMBErrorCode eMBRegDiscreteCB(UCHAR * pucRegBuffer, USHORT usAddress, MB_SLAVE_CHECK((slave_interface_ptr != NULL), ESP_ERR_INVALID_STATE, "Slave interface is not correctly initialized."); - MB_SLAVE_CHECK((slave_interface_ptr->slave_reg_cb_discrete != NULL), + MB_SLAVE_CHECK((slave_interface_ptr->slave_reg_cb_discrete != NULL), error, "Slave interface is not correctly initialized."); error = slave_interface_ptr->slave_reg_cb_discrete(pucRegBuffer, usAddress, usNDiscrete); - + return error; } @@ -193,7 +193,7 @@ eMBErrorCode eMBRegCoilsCB(UCHAR* pucRegBuffer, USHORT usAddress, MB_SLAVE_CHECK((slave_interface_ptr != NULL), ESP_ERR_INVALID_STATE, "Slave interface is not correctly initialized."); - MB_SLAVE_CHECK((slave_interface_ptr->slave_reg_cb_coils != NULL), + MB_SLAVE_CHECK((slave_interface_ptr->slave_reg_cb_coils != NULL), ESP_ERR_INVALID_STATE, "Slave interface is not correctly initialized."); error = slave_interface_ptr->slave_reg_cb_coils(pucRegBuffer, usAddress, @@ -208,7 +208,7 @@ eMBErrorCode eMBRegHoldingCB(UCHAR * pucRegBuffer, USHORT usAddress, MB_SLAVE_CHECK((slave_interface_ptr != NULL), ESP_ERR_INVALID_STATE, "Slave interface is not correctly initialized."); - MB_SLAVE_CHECK((slave_interface_ptr->slave_reg_cb_holding != NULL), + MB_SLAVE_CHECK((slave_interface_ptr->slave_reg_cb_holding != NULL), ESP_ERR_INVALID_STATE, "Slave interface is not correctly initialized."); error = slave_interface_ptr->slave_reg_cb_holding(pucRegBuffer, usAddress, @@ -223,7 +223,7 @@ eMBErrorCode eMBRegInputCB(UCHAR * pucRegBuffer, USHORT usAddress, MB_SLAVE_CHECK((slave_interface_ptr != NULL), ESP_ERR_INVALID_STATE, "Slave interface is not correctly initialized."); - MB_SLAVE_CHECK((slave_interface_ptr->slave_reg_cb_input != NULL), + MB_SLAVE_CHECK((slave_interface_ptr->slave_reg_cb_input != NULL), ESP_ERR_INVALID_STATE, "Slave interface is not correctly initialized."); error = slave_interface_ptr->slave_reg_cb_input(pucRegBuffer, usAddress, usNRegs); diff --git a/components/freemodbus/common/esp_modbus_slave_serial.c b/components/freemodbus/common/esp_modbus_slave_serial.c index 662b03e..89b75f4 100644 --- a/components/freemodbus/common/esp_modbus_slave_serial.c +++ b/components/freemodbus/common/esp_modbus_slave_serial.c @@ -41,4 +41,3 @@ esp_err_t mbc_slave_init(mb_port_type_t port_type, void** handler) } return error; } - diff --git a/components/freemodbus/common/include/esp_modbus_common.h b/components/freemodbus/common/include/esp_modbus_common.h index a603364..aa53e85 100644 --- a/components/freemodbus/common/include/esp_modbus_common.h +++ b/components/freemodbus/common/include/esp_modbus_common.h @@ -153,4 +153,3 @@ typedef esp_err_t (*iface_start)(void); /*!< Interface method start */ #endif #endif // _MB_IFACE_COMMON_H - diff --git a/components/freemodbus/component.mk b/components/freemodbus/component.mk index e19a242..c90a5dc 100644 --- a/components/freemodbus/component.mk +++ b/components/freemodbus/component.mk @@ -1,6 +1,6 @@ COMPONENT_ADD_INCLUDEDIRS := common/include -COMPONENT_PRIV_INCLUDEDIRS := common port modbus modbus/ascii modbus/functions -COMPONENT_PRIV_INCLUDEDIRS += modbus/rtu modbus/tcp modbus/include +COMPONENT_PRIV_INCLUDEDIRS := common port modbus modbus/ascii modbus/functions +COMPONENT_PRIV_INCLUDEDIRS += modbus/rtu modbus/tcp modbus/include COMPONENT_PRIV_INCLUDEDIRS += serial_slave/port serial_slave/modbus_controller COMPONENT_PRIV_INCLUDEDIRS += serial_master/port serial_master/modbus_controller COMPONENT_PRIV_INCLUDEDIRS += tcp_slave/port tcp_slave/modbus_controller diff --git a/components/freemodbus/modbus/ascii/mbascii.c b/components/freemodbus/modbus/ascii/mbascii.c index bbe1994..132711e 100644 --- a/components/freemodbus/modbus/ascii/mbascii.c +++ b/components/freemodbus/modbus/ascii/mbascii.c @@ -1,4 +1,4 @@ -/* +/* * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. * Copyright (c) 2006 Christian Walter * All rights reserved. @@ -101,7 +101,7 @@ eMBASCIIInit( UCHAR ucSlaveAddress, UCHAR ucPort, ULONG ulBaudRate, eMBParity eP { eMBErrorCode eStatus = MB_ENOERR; ( void )ucSlaveAddress; - + ENTER_CRITICAL_SECTION( ); ucMBLFCharacter = MB_ASCII_DEFAULT_LF; @@ -393,7 +393,7 @@ xMBASCIITransmitFSM( void ) return xNeedPoll; } -BOOL MB_PORT_ISR_ATTR +BOOL MB_PORT_ISR_ATTR xMBASCIITimerT1SExpired( void ) { switch ( eRcvState ) diff --git a/components/freemodbus/modbus/ascii/mbascii.h b/components/freemodbus/modbus/ascii/mbascii.h index 535701b..93cc688 100644 --- a/components/freemodbus/modbus/ascii/mbascii.h +++ b/components/freemodbus/modbus/ascii/mbascii.h @@ -1,4 +1,4 @@ -/* +/* * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. * Copyright (c) 2006 Christian Walter * All rights reserved. diff --git a/components/freemodbus/modbus/ascii/mbascii_m.c b/components/freemodbus/modbus/ascii/mbascii_m.c index b6327c2..94c0421 100644 --- a/components/freemodbus/modbus/ascii/mbascii_m.c +++ b/components/freemodbus/modbus/ascii/mbascii_m.c @@ -1,4 +1,4 @@ -/* +/* * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. * Copyright (c) 2006 Christian Walter * All rights reserved. @@ -108,7 +108,7 @@ eMBErrorCode eMBMasterASCIIInit( UCHAR ucPort, ULONG ulBaudRate, eMBParity eParity ) { eMBErrorCode eStatus = MB_ENOERR; - + ENTER_CRITICAL_SECTION( ); ucMBLFCharacter = MB_ASCII_DEFAULT_LF; @@ -237,14 +237,14 @@ xMBMasterASCIIReceiveFSM( void ) case STATE_M_RX_INIT: vMBMasterPortTimersT35Enable( ); break; - + /* In the error state we wait until all characters in the * damaged frame are transmitted. */ case STATE_M_RX_ERROR: vMBMasterPortTimersRespondTimeoutEnable( ); break; - + /* In the idle state we wait for a new character. If a character * is received the t1.5 and t3.5 timers are started and the * receiver is in the state STATE_RX_RECEIVE and disable early @@ -254,7 +254,7 @@ xMBMasterASCIIReceiveFSM( void ) /* Waiting for the start of frame character during respond timeout */ vMBMasterPortTimersRespondTimeoutEnable( ); if( ucByte == ':' ) - { + { /* Reset the input buffers to store the frame in receive state. */ usMasterRcvBufferPos = 0; eBytePos = BYTE_HIGH_NIBBLE; @@ -358,19 +358,19 @@ xMBMasterASCIITransmitFSM( void ) BOOL xFrameIsBroadcast = FALSE; assert( eRcvState == STATE_M_RX_IDLE ); - + switch ( eSndState ) { /* We should not get a transmitter event if the transmitter is in * idle state. */ case STATE_M_TX_XFWR: - break; - + break; + /* We should not get a transmitter event if the transmitter is in * idle state. */ case STATE_M_TX_IDLE: break; - + /* Start of transmission. The start of a frame is defined by sending * the character ':'. */ case STATE_M_TX_START: @@ -446,22 +446,22 @@ BOOL xMBMasterASCIITimerT1SExpired( void ) { BOOL xNeedPoll = FALSE; - + switch ( eRcvState ) { /* Timer t35 expired. Startup phase is finished. */ case STATE_M_RX_INIT: xNeedPoll = xMBMasterPortEventPost(EV_MASTER_READY); ESP_EARLY_LOGI("xMBMasterASCIITimerT1SExpired", "RX_INIT_EXPIRED"); - break; - + break; + /* Start of message is not received during respond timeout. * Process error. */ case STATE_M_RX_IDLE: eRcvState = STATE_M_RX_ERROR; break; - - /* A recieve timeout expired and no any new character received. + + /* A recieve timeout expired and no any new character received. * Wait for respond time and go to error state to inform listener about error */ case STATE_M_RX_RCV: eRcvState = STATE_M_RX_ERROR; @@ -472,7 +472,7 @@ xMBMasterASCIITimerT1SExpired( void ) vMBMasterSetErrorType(EV_ERROR_RECEIVE_DATA); xNeedPoll = xMBMasterPortEventPost( EV_MASTER_ERROR_PROCESS ); break; - + /* If we have a timeout we go back to the idle state and wait for * the next frame. */ @@ -485,7 +485,7 @@ xMBMasterASCIITimerT1SExpired( void ) break; } eRcvState = STATE_M_RX_IDLE; - + switch (eSndState) { /* A frame was send finish and convert delay or respond timeout expired. @@ -497,11 +497,11 @@ xMBMasterASCIITimerT1SExpired( void ) xNeedPoll = xMBMasterPortEventPost(EV_MASTER_ERROR_PROCESS); } break; - + /* Function called in an illegal state. */ - default: + default: assert( ( eSndState == STATE_M_TX_START ) || ( eSndState == STATE_M_TX_IDLE ) - || ( eSndState == STATE_M_TX_DATA ) || ( eSndState == STATE_M_TX_END ) + || ( eSndState == STATE_M_TX_DATA ) || ( eSndState == STATE_M_TX_END ) || ( eSndState == STATE_M_TX_NOTIFY ) ); break; } @@ -512,9 +512,9 @@ xMBMasterASCIITimerT1SExpired( void ) if (xMBMasterGetCurTimerMode() == MB_TMODE_CONVERT_DELAY) { xNeedPoll = xMBMasterPortEventPost( EV_MASTER_EXECUTE ); } - + vMBMasterPortTimersDisable( ); - + /* no context switch required. */ return xNeedPoll; } diff --git a/components/freemodbus/modbus/functions/mbfunccoils.c b/components/freemodbus/modbus/functions/mbfunccoils.c index 458ff5c..40ca1c1 100644 --- a/components/freemodbus/modbus/functions/mbfunccoils.c +++ b/components/freemodbus/modbus/functions/mbfunccoils.c @@ -1,4 +1,4 @@ -/* +/* * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. * Copyright (c) 2006 Christian Walter * All rights reserved. @@ -87,7 +87,7 @@ eMBFuncReadCoils( UCHAR * pucFrame, USHORT * usLen ) usCoilCount |= ( USHORT )( pucFrame[MB_PDU_FUNC_READ_COILCNT_OFF + 1] ); /* Check if the number of registers to read is valid. If not - * return Modbus illegal data value exception. + * return Modbus illegal data value exception. */ if( ( usCoilCount >= 1 ) && ( usCoilCount < MB_PDU_FUNC_READ_COILCNT_MAX ) ) @@ -125,7 +125,7 @@ eMBFuncReadCoils( UCHAR * pucFrame, USHORT * usLen ) else { /* The response contains the function code, the starting address - * and the quantity of registers. We reuse the old values in the + * and the quantity of registers. We reuse the old values in the * buffer because they are still valid. */ *usLen += ucNBytes;; } @@ -247,7 +247,7 @@ eMBFuncWriteMultipleCoils( UCHAR * pucFrame, USHORT * usLen ) else { /* The response contains the function code, the starting address - * and the quantity of registers. We reuse the old values in the + * and the quantity of registers. We reuse the old values in the * buffer because they are still valid. */ *usLen = MB_PDU_FUNC_WRITE_MUL_BYTECNT_OFF; } diff --git a/components/freemodbus/modbus/functions/mbfunccoils_m.c b/components/freemodbus/modbus/functions/mbfunccoils_m.c index 036808c..931f536 100644 --- a/components/freemodbus/modbus/functions/mbfunccoils_m.c +++ b/components/freemodbus/modbus/functions/mbfunccoils_m.c @@ -1,4 +1,4 @@ -/* +/* * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. * Copyright (C) 2013 Armink * All rights reserved. @@ -148,7 +148,7 @@ eMBMasterFuncReadCoils( UCHAR * pucFrame, USHORT * usLen ) } /* Check if the number of registers to read is valid. If not - * return Modbus illegal data value exception. + * return Modbus illegal data value exception. */ if( ( usCoilCount >= 1 ) && ( ucByteCount == pucFrame[MB_PDU_FUNC_READ_COILCNT_OFF] ) ) diff --git a/components/freemodbus/modbus/functions/mbfuncdiag.c b/components/freemodbus/modbus/functions/mbfuncdiag.c index d75ffc0..8f7b967 100644 --- a/components/freemodbus/modbus/functions/mbfuncdiag.c +++ b/components/freemodbus/modbus/functions/mbfuncdiag.c @@ -1,4 +1,4 @@ -/* +/* * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. * Copyright (c) 2006 Christian Walter * All rights reserved. diff --git a/components/freemodbus/modbus/functions/mbfuncdisc.c b/components/freemodbus/modbus/functions/mbfuncdisc.c index 87667ac..79ff68f 100644 --- a/components/freemodbus/modbus/functions/mbfuncdisc.c +++ b/components/freemodbus/modbus/functions/mbfuncdisc.c @@ -65,7 +65,7 @@ eMBFuncReadDiscreteInputs( UCHAR * pucFrame, USHORT * usLen ) usDiscreteCnt |= ( USHORT )( pucFrame[MB_PDU_FUNC_READ_DISCCNT_OFF + 1] ); /* Check if the number of registers to read is valid. If not - * return Modbus illegal data value exception. + * return Modbus illegal data value exception. */ if( ( usDiscreteCnt >= 1 ) && ( usDiscreteCnt < MB_PDU_FUNC_READ_DISCCNT_MAX ) ) @@ -102,7 +102,7 @@ eMBFuncReadDiscreteInputs( UCHAR * pucFrame, USHORT * usLen ) else { /* The response contains the function code, the starting address - * and the quantity of registers. We reuse the old values in the + * and the quantity of registers. We reuse the old values in the * buffer because they are still valid. */ *usLen += ucNBytes;; } diff --git a/components/freemodbus/modbus/functions/mbfuncdisc_m.c b/components/freemodbus/modbus/functions/mbfuncdisc_m.c index 1a69647..21ce0cb 100644 --- a/components/freemodbus/modbus/functions/mbfuncdisc_m.c +++ b/components/freemodbus/modbus/functions/mbfuncdisc_m.c @@ -131,7 +131,7 @@ eMBMasterFuncReadDiscreteInputs( UCHAR * pucFrame, USHORT * usLen ) } /* Check if the number of registers to read is valid. If not - * return Modbus illegal data value exception. + * return Modbus illegal data value exception. */ if ((usDiscreteCnt >= 1) && ucNBytes == pucFrame[MB_PDU_FUNC_READ_DISCCNT_OFF]) { diff --git a/components/freemodbus/modbus/functions/mbfuncholding.c b/components/freemodbus/modbus/functions/mbfuncholding.c index 1a37866..e51b7de 100644 --- a/components/freemodbus/modbus/functions/mbfuncholding.c +++ b/components/freemodbus/modbus/functions/mbfuncholding.c @@ -1,4 +1,4 @@ -/* +/* * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. * Copyright (c) 2006 Christian Walter * All rights reserved. @@ -187,7 +187,7 @@ eMBFuncReadHoldingRegister( UCHAR * pucFrame, USHORT * usLen ) usRegCount = ( USHORT )( pucFrame[MB_PDU_FUNC_READ_REGCNT_OFF + 1] ); /* Check if the number of registers to read is valid. If not - * return Modbus illegal data value exception. + * return Modbus illegal data value exception. */ if( ( usRegCount >= 1 ) && ( usRegCount <= MB_PDU_FUNC_READ_REGCNT_MAX ) ) { diff --git a/components/freemodbus/modbus/functions/mbfuncholding_m.c b/components/freemodbus/modbus/functions/mbfuncholding_m.c index 9b4c077..9c3d699 100644 --- a/components/freemodbus/modbus/functions/mbfuncholding_m.c +++ b/components/freemodbus/modbus/functions/mbfuncholding_m.c @@ -1,4 +1,4 @@ -/* +/* * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. * Copyright (C) 2013 Armink * All rights reserved. @@ -452,4 +452,3 @@ eMBMasterFuncReadWriteMultipleHoldingRegister( UCHAR * pucFrame, USHORT * usLen #endif #endif // #if MB_MASTER_RTU_ENABLED || MB_MASTER_ASCII_ENABLED || MB_MASTER_TCP_ENABLED - diff --git a/components/freemodbus/modbus/functions/mbfuncinput.c b/components/freemodbus/modbus/functions/mbfuncinput.c index 97aeac4..b713d86 100644 --- a/components/freemodbus/modbus/functions/mbfuncinput.c +++ b/components/freemodbus/modbus/functions/mbfuncinput.c @@ -1,4 +1,4 @@ -/* +/* * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. * Copyright (c) 2006 Christian Walter * All rights reserved. @@ -77,7 +77,7 @@ eMBFuncReadInputRegister( UCHAR * pucFrame, USHORT * usLen ) usRegCount |= ( USHORT )( pucFrame[MB_PDU_FUNC_READ_REGCNT_OFF + 1] ); /* Check if the number of registers to read is valid. If not - * return Modbus illegal data value exception. + * return Modbus illegal data value exception. */ if( ( usRegCount >= 1 ) && ( usRegCount < MB_PDU_FUNC_READ_REGCNT_MAX ) ) diff --git a/components/freemodbus/modbus/functions/mbfuncinput_m.c b/components/freemodbus/modbus/functions/mbfuncinput_m.c index 3a68695..37135f7 100644 --- a/components/freemodbus/modbus/functions/mbfuncinput_m.c +++ b/components/freemodbus/modbus/functions/mbfuncinput_m.c @@ -1,4 +1,4 @@ -/* +/* * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. * Copyright (C) 2013 Armink * All rights reserved. diff --git a/components/freemodbus/modbus/functions/mbfuncother.c b/components/freemodbus/modbus/functions/mbfuncother.c index a488a5b..0c2323a 100644 --- a/components/freemodbus/modbus/functions/mbfuncother.c +++ b/components/freemodbus/modbus/functions/mbfuncother.c @@ -1,4 +1,4 @@ -/* +/* * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. * Copyright (c) 2006 Christian Walter * All rights reserved. diff --git a/components/freemodbus/modbus/functions/mbutils.c b/components/freemodbus/modbus/functions/mbutils.c index 6a72570..0f0928b 100644 --- a/components/freemodbus/modbus/functions/mbutils.c +++ b/components/freemodbus/modbus/functions/mbutils.c @@ -1,4 +1,4 @@ -/* +/* * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. * Copyright (c) 2006 Christian Walter * All rights reserved. diff --git a/components/freemodbus/modbus/include/mb.h b/components/freemodbus/modbus/include/mb.h index abfa92b..bd0f24a 100644 --- a/components/freemodbus/modbus/include/mb.h +++ b/components/freemodbus/modbus/include/mb.h @@ -1,4 +1,4 @@ -/* +/* * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. * Copyright (c) 2006 Christian Walter * All rights reserved. @@ -98,7 +98,7 @@ typedef enum * registers should be updated and reading means that the modbus protocol * stack needs to know the current register values. * - * \see eMBRegHoldingCB( ), eMBRegCoilsCB( ), eMBRegDiscreteCB( ) and + * \see eMBRegHoldingCB( ), eMBRegCoilsCB( ), eMBRegDiscreteCB( ) and * eMBRegInputCB( ). */ typedef enum @@ -142,7 +142,7 @@ typedef enum * * \return If no error occurs the function returns eMBErrorCode::MB_ENOERR. * The protocol is then in the disabled state and ready for activation - * by calling eMBEnable( ). Otherwise one of the following error codes + * by calling eMBEnable( ). Otherwise one of the following error codes * is returned: * - eMBErrorCode::MB_EINVAL If the slave address was not valid. Valid * slave addresses are in the range 1 - 247. @@ -171,10 +171,10 @@ eMBErrorCode eMBTCPInit( USHORT usTCPPort ); * \brief Release resources used by the protocol stack. * * This function disables the Modbus protocol stack and release all - * hardware resources. It must only be called when the protocol stack - * is disabled. + * hardware resources. It must only be called when the protocol stack + * is disabled. * - * \note Note all ports implement this function. A port which wants to + * \note Note all ports implement this function. A port which wants to * get an callback must define the macro MB_PORT_HAS_CLOSE to 1. * * \return If the resources where released it return eMBErrorCode::MB_ENOERR. @@ -189,8 +189,8 @@ eMBErrorCode eMBClose( void ); * This function enables processing of Modbus frames. Enabling the protocol * stack is only possible if it is in the disabled state. * - * \return If the protocol stack is now in the state enabled it returns - * eMBErrorCode::MB_ENOERR. If it was not in the disabled state it + * \return If the protocol stack is now in the state enabled it returns + * eMBErrorCode::MB_ENOERR. If it was not in the disabled state it * return eMBErrorCode::MB_EILLSTATE. */ eMBErrorCode eMBEnable( void ); @@ -200,7 +200,7 @@ eMBErrorCode eMBEnable( void ); * * This function disables processing of Modbus frames. * - * \return If the protocol stack has been disabled it returns + * \return If the protocol stack has been disabled it returns * eMBErrorCode::MB_ENOERR. If it was not in the enabled state it returns * eMBErrorCode::MB_EILLSTATE. */ @@ -212,10 +212,10 @@ eMBErrorCode eMBDisable( void ); * This function must be called periodically. The timer interval required * is given by the application dependent Modbus slave timeout. Internally the * function calls xMBPortEventGet() and waits for an event from the receiver or - * transmitter state machines. + * transmitter state machines. * * \return If the protocol stack is not in the enabled state the function - * returns eMBErrorCode::MB_EILLSTATE. Otherwise it returns + * returns eMBErrorCode::MB_EILLSTATE. Otherwise it returns * eMBErrorCode::MB_ENOERR. */ eMBErrorCode eMBPoll( void ); @@ -249,7 +249,7 @@ eMBErrorCode eMBSetSlaveID( UCHAR ucSlaveID, BOOL xIsRunning, * The callback handler supplied is responsible for interpreting the Modbus PDU and * the creation of an appropriate response. In case of an error it should return * one of the possible Modbus exceptions which results in a Modbus exception frame - * sent by the protocol stack. + * sent by the protocol stack. * * \param ucFunctionCode The Modbus function code for which this handler should * be registers. Valid function codes are in the range 1 to 127. @@ -262,7 +262,7 @@ eMBErrorCode eMBSetSlaveID( UCHAR ucSlaveID, BOOL xIsRunning, * case the values in mbconfig.h should be adjusted. If the argument was not * valid it returns eMBErrorCode::MB_EINVAL. */ -eMBErrorCode eMBRegisterCB( UCHAR ucFunctionCode, +eMBErrorCode eMBRegisterCB( UCHAR ucFunctionCode, pxMBFunctionHandler pxHandler ); /* ----------------------- Callback -----------------------------------------*/ @@ -300,7 +300,7 @@ eMBErrorCode eMBRegisterCB( UCHAR ucFunctionCode, * - eMBErrorCode::MB_ENOERR If no error occurred. In this case a normal * Modbus response is sent. * - eMBErrorCode::MB_ENOREG If the application can not supply values - * for registers within this range. In this case a + * for registers within this range. In this case a * ILLEGAL DATA ADDRESS exception frame is sent as a response. * - eMBErrorCode::MB_ETIMEDOUT If the requested register block is * currently not available and the application dependent response @@ -324,18 +324,18 @@ eMBErrorCode eMBRegInputCB( UCHAR * pucRegBuffer, USHORT usAddress, * this buffer. * \param usAddress The starting address of the register. * \param usNRegs Number of registers to read or write. - * \param eMode If eMBRegisterMode::MB_REG_WRITE the application register + * \param eMode If eMBRegisterMode::MB_REG_WRITE the application register * values should be updated from the values in the buffer. For example - * this would be the case when the Modbus master has issued an + * this would be the case when the Modbus master has issued an * WRITE SINGLE REGISTER command. - * If the value eMBRegisterMode::MB_REG_READ the application should copy + * If the value eMBRegisterMode::MB_REG_READ the application should copy * the current values into the buffer \c pucRegBuffer. * * \return The function must return one of the following error codes: * - eMBErrorCode::MB_ENOERR If no error occurred. In this case a normal * Modbus response is sent. * - eMBErrorCode::MB_ENOREG If the application can not supply values - * for registers within this range. In this case a + * for registers within this range. In this case a * ILLEGAL DATA ADDRESS exception frame is sent as a response. * - eMBErrorCode::MB_ETIMEDOUT If the requested register block is * currently not available and the application dependent response @@ -370,7 +370,7 @@ eMBErrorCode eMBRegHoldingCB( UCHAR * pucRegBuffer, USHORT usAddress, * - eMBErrorCode::MB_ENOERR If no error occurred. In this case a normal * Modbus response is sent. * - eMBErrorCode::MB_ENOREG If the application does not map an coils - * within the requested address range. In this case a + * within the requested address range. In this case a * ILLEGAL DATA ADDRESS is sent as a response. * - eMBErrorCode::MB_ETIMEDOUT If the requested register block is * currently not available and the application dependent response @@ -399,7 +399,7 @@ eMBErrorCode eMBRegCoilsCB( UCHAR * pucRegBuffer, USHORT usAddress, * - eMBErrorCode::MB_ENOERR If no error occurred. In this case a normal * Modbus response is sent. * - eMBErrorCode::MB_ENOREG If no such discrete inputs exists. - * In this case a ILLEGAL DATA ADDRESS exception frame is sent + * In this case a ILLEGAL DATA ADDRESS exception frame is sent * as a response. * - eMBErrorCode::MB_ETIMEDOUT If the requested register block is * currently not available and the application dependent response diff --git a/components/freemodbus/modbus/include/mb_m.h b/components/freemodbus/modbus/include/mb_m.h index f17867e..cb088e9 100644 --- a/components/freemodbus/modbus/include/mb_m.h +++ b/components/freemodbus/modbus/include/mb_m.h @@ -1,4 +1,4 @@ -/* +/* * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. * Copyright (C) 2013 Armink * All rights reserved. @@ -143,10 +143,10 @@ eMBErrorCode eMBMasterTCPInit( USHORT usTCPPort ); * \brief Release resources used by the protocol stack. * * This function disables the Modbus Master protocol stack and release all - * hardware resources. It must only be called when the protocol stack - * is disabled. + * hardware resources. It must only be called when the protocol stack + * is disabled. * - * \note Note all ports implement this function. A port which wants to + * \note Note all ports implement this function. A port which wants to * get an callback must define the macro MB_PORT_HAS_CLOSE to 1. * * \return If the resources where released it return eMBErrorCode::MB_ENOERR. @@ -161,8 +161,8 @@ eMBErrorCode eMBMasterClose( void ); * This function enables processing of Modbus Master frames. Enabling the protocol * stack is only possible if it is in the disabled state. * - * \return If the protocol stack is now in the state enabled it returns - * eMBErrorCode::MB_ENOERR. If it was not in the disabled state it + * \return If the protocol stack is now in the state enabled it returns + * eMBErrorCode::MB_ENOERR. If it was not in the disabled state it * return eMBErrorCode::MB_EILLSTATE. */ eMBErrorCode eMBMasterEnable( void ); @@ -172,7 +172,7 @@ eMBErrorCode eMBMasterEnable( void ); * * This function disables processing of Modbus frames. * - * \return If the protocol stack has been disabled it returns + * \return If the protocol stack has been disabled it returns * eMBErrorCode::MB_ENOERR. If it was not in the enabled state it returns * eMBErrorCode::MB_EILLSTATE. */ @@ -184,10 +184,10 @@ eMBErrorCode eMBMasterDisable( void ); * This function must be called periodically. The timer interval required * is given by the application dependent Modbus slave timeout. Internally the * function calls xMBMasterPortEventGet() and waits for an event from the receiver or - * transmitter state machines. + * transmitter state machines. * * \return If the protocol stack is not in the enabled state the function - * returns eMBErrorCode::MB_EILLSTATE. Otherwise it returns + * returns eMBErrorCode::MB_EILLSTATE. Otherwise it returns * eMBErrorCode::MB_ENOERR. */ eMBErrorCode eMBMasterPoll( void ); diff --git a/components/freemodbus/modbus/include/mbconfig.h b/components/freemodbus/modbus/include/mbconfig.h index f32be6c..b784bf8 100644 --- a/components/freemodbus/modbus/include/mbconfig.h +++ b/components/freemodbus/modbus/include/mbconfig.h @@ -1,4 +1,4 @@ -/* +/* * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. * Copyright (c) 2006 Christian Walter * All rights reserved. @@ -90,7 +90,7 @@ PR_BEGIN_EXTERN_C * MB_ASCII_TIMEOUT_WAIT_BEFORE_SEND_MS to allow for a delay before * the serial transmitter is enabled. This is required because some * targets are so fast that there is no time between receiving and - * transmitting the frame. If the master is to slow with enabling its + * transmitting the frame. If the master is to slow with enabling its * receiver then he will not receive the response correctly. */ #ifndef MB_ASCII_TIMEOUT_WAIT_BEFORE_SEND_MS diff --git a/components/freemodbus/modbus/include/mbframe.h b/components/freemodbus/modbus/include/mbframe.h index 9dbfc39..5b7d6d7 100644 --- a/components/freemodbus/modbus/include/mbframe.h +++ b/components/freemodbus/modbus/include/mbframe.h @@ -1,4 +1,4 @@ -/* +/* * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. * Copyright (c) 2006 Christian Walter * All rights reserved. diff --git a/components/freemodbus/modbus/include/mbfunc.h b/components/freemodbus/modbus/include/mbfunc.h index aea14f7..48d7b39 100644 --- a/components/freemodbus/modbus/include/mbfunc.h +++ b/components/freemodbus/modbus/include/mbfunc.h @@ -1,4 +1,4 @@ -/* +/* * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. * Copyright (c) 2006 Christian Walter * All rights reserved. diff --git a/components/freemodbus/modbus/include/mbport.h b/components/freemodbus/modbus/include/mbport.h index 8dfe8b7..a73b949 100644 --- a/components/freemodbus/modbus/include/mbport.h +++ b/components/freemodbus/modbus/include/mbport.h @@ -1,4 +1,4 @@ -/* +/* * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. * Copyright (c) 2006 Christian Walter * All rights reserved. diff --git a/components/freemodbus/modbus/include/mbproto.h b/components/freemodbus/modbus/include/mbproto.h index f84cb3e..3c76517 100644 --- a/components/freemodbus/modbus/include/mbproto.h +++ b/components/freemodbus/modbus/include/mbproto.h @@ -1,4 +1,4 @@ -/* +/* * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. * Copyright (c) 2006 Christian Walter * All rights reserved. diff --git a/components/freemodbus/modbus/include/mbutils.h b/components/freemodbus/modbus/include/mbutils.h index 6149575..1d96ddc 100644 --- a/components/freemodbus/modbus/include/mbutils.h +++ b/components/freemodbus/modbus/include/mbutils.h @@ -1,4 +1,4 @@ -/* +/* * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. * Copyright (c) 2006 Christian Walter * All rights reserved. diff --git a/components/freemodbus/modbus/mb.c b/components/freemodbus/modbus/mb.c index 90fef65..be00e55 100644 --- a/components/freemodbus/modbus/mb.c +++ b/components/freemodbus/modbus/mb.c @@ -1,4 +1,4 @@ -/* +/* * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. * Copyright (c) 2006 Christian Walter * All rights reserved. @@ -407,11 +407,11 @@ eMBPoll( void ) if( ( eMBCurrentMode == MB_ASCII ) && MB_ASCII_TIMEOUT_WAIT_BEFORE_SEND_MS ) { vMBPortTimersDelay( MB_ASCII_TIMEOUT_WAIT_BEFORE_SEND_MS ); - } + } eStatus = peMBFrameSendCur( ucMBAddress, ucMBFrame, usLength ); } break; - + case EV_FRAME_TRANSMIT: ESP_LOGD(MB_PORT_TAG, "%s:EV_FRAME_TRANSMIT", __func__); break; diff --git a/components/freemodbus/modbus/mb_m.c b/components/freemodbus/modbus/mb_m.c index 38a031c..8cc4dba 100644 --- a/components/freemodbus/modbus/mb_m.c +++ b/components/freemodbus/modbus/mb_m.c @@ -1,4 +1,4 @@ -/* +/* * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. * Copyright (C) 2013 Armink * All rights reserved. @@ -348,7 +348,7 @@ eMBMasterPoll( void ) eStatus = peMBMasterFrameReceiveCur( &ucRcvAddress, &ucMBFrame, &usLength); // Check if the frame is for us. If not ,send an error process event. - if ( ( eStatus == MB_ENOERR ) && ( ( ucRcvAddress == ucMBMasterGetDestAddress() ) + if ( ( eStatus == MB_ENOERR ) && ( ( ucRcvAddress == ucMBMasterGetDestAddress() ) || ( ucRcvAddress == MB_TCP_PSEUDO_ADDRESS ) ) ) { ( void ) xMBMasterPortEventPost( EV_MASTER_EXECUTE ); diff --git a/components/freemodbus/modbus/rtu/mbcrc.c b/components/freemodbus/modbus/rtu/mbcrc.c index 1cd0a6e..bb89676 100644 --- a/components/freemodbus/modbus/rtu/mbcrc.c +++ b/components/freemodbus/modbus/rtu/mbcrc.c @@ -1,4 +1,4 @@ -/* +/* * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. * Copyright (c) 2006 Christian Walter * All rights reserved. @@ -46,12 +46,12 @@ static const UCHAR aucCRCHi[] = { 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, - 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, + 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, - 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, + 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, - 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, + 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, 0x01, 0xC0, 0x80, 0x41, 0x00, 0xC1, 0x81, 0x40, 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x41, @@ -67,12 +67,12 @@ static const UCHAR aucCRCLo[] = { 0x14, 0xD4, 0xD5, 0x15, 0xD7, 0x17, 0x16, 0xD6, 0xD2, 0x12, 0x13, 0xD3, 0x11, 0xD1, 0xD0, 0x10, 0xF0, 0x30, 0x31, 0xF1, 0x33, 0xF3, 0xF2, 0x32, 0x36, 0xF6, 0xF7, 0x37, 0xF5, 0x35, 0x34, 0xF4, 0x3C, 0xFC, 0xFD, 0x3D, - 0xFF, 0x3F, 0x3E, 0xFE, 0xFA, 0x3A, 0x3B, 0xFB, 0x39, 0xF9, 0xF8, 0x38, + 0xFF, 0x3F, 0x3E, 0xFE, 0xFA, 0x3A, 0x3B, 0xFB, 0x39, 0xF9, 0xF8, 0x38, 0x28, 0xE8, 0xE9, 0x29, 0xEB, 0x2B, 0x2A, 0xEA, 0xEE, 0x2E, 0x2F, 0xEF, 0x2D, 0xED, 0xEC, 0x2C, 0xE4, 0x24, 0x25, 0xE5, 0x27, 0xE7, 0xE6, 0x26, 0x22, 0xE2, 0xE3, 0x23, 0xE1, 0x21, 0x20, 0xE0, 0xA0, 0x60, 0x61, 0xA1, 0x63, 0xA3, 0xA2, 0x62, 0x66, 0xA6, 0xA7, 0x67, 0xA5, 0x65, 0x64, 0xA4, - 0x6C, 0xAC, 0xAD, 0x6D, 0xAF, 0x6F, 0x6E, 0xAE, 0xAA, 0x6A, 0x6B, 0xAB, + 0x6C, 0xAC, 0xAD, 0x6D, 0xAF, 0x6F, 0x6E, 0xAE, 0xAA, 0x6A, 0x6B, 0xAB, 0x69, 0xA9, 0xA8, 0x68, 0x78, 0xB8, 0xB9, 0x79, 0xBB, 0x7B, 0x7A, 0xBA, 0xBE, 0x7E, 0x7F, 0xBF, 0x7D, 0xBD, 0xBC, 0x7C, 0xB4, 0x74, 0x75, 0xB5, 0x77, 0xB7, 0xB6, 0x76, 0x72, 0xB2, 0xB3, 0x73, 0xB1, 0x71, 0x70, 0xB0, diff --git a/components/freemodbus/modbus/rtu/mbcrc.h b/components/freemodbus/modbus/rtu/mbcrc.h index db22776..5ed3f22 100644 --- a/components/freemodbus/modbus/rtu/mbcrc.h +++ b/components/freemodbus/modbus/rtu/mbcrc.h @@ -1,4 +1,4 @@ -/* +/* * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. * Copyright (c) 2006 Christian Walter * All rights reserved. diff --git a/components/freemodbus/modbus/rtu/mbrtu.c b/components/freemodbus/modbus/rtu/mbrtu.c index 066fea3..c4d77f6 100644 --- a/components/freemodbus/modbus/rtu/mbrtu.c +++ b/components/freemodbus/modbus/rtu/mbrtu.c @@ -1,4 +1,4 @@ -/* +/* * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. * Copyright (c) 2006 Christian Walter * All rights reserved. diff --git a/components/freemodbus/modbus/rtu/mbrtu.h b/components/freemodbus/modbus/rtu/mbrtu.h index 4adf99f..676f67d 100644 --- a/components/freemodbus/modbus/rtu/mbrtu.h +++ b/components/freemodbus/modbus/rtu/mbrtu.h @@ -1,4 +1,4 @@ -/* +/* * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. * Copyright (c) 2006 Christian Walter * All rights reserved. diff --git a/components/freemodbus/modbus/rtu/mbrtu_m.c b/components/freemodbus/modbus/rtu/mbrtu_m.c index 19be4b8..ce22c8e 100644 --- a/components/freemodbus/modbus/rtu/mbrtu_m.c +++ b/components/freemodbus/modbus/rtu/mbrtu_m.c @@ -1,4 +1,4 @@ -/* +/* * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. * Copyright (c) 2013 China Beijing Armink * All rights reserved. @@ -355,7 +355,7 @@ xMBMasterRTUTimerExpired(void) case STATE_M_RX_INIT: xNeedPoll = xMBMasterPortEventPost(EV_MASTER_READY); break; - + /* A frame was received and t35 expired. Notify the listener that * a new frame was received. */ case STATE_M_RX_RCV: @@ -404,5 +404,3 @@ xMBMasterRTUTimerExpired(void) #endif - - diff --git a/components/freemodbus/modbus/tcp/mbtcp.c b/components/freemodbus/modbus/tcp/mbtcp.c index 58542d8..2527752 100644 --- a/components/freemodbus/modbus/tcp/mbtcp.c +++ b/components/freemodbus/modbus/tcp/mbtcp.c @@ -1,4 +1,4 @@ -/* +/* * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. * Copyright (c) 2006 Christian Walter * All rights reserved. @@ -54,10 +54,10 @@ * +-----------+---------------+------------------------------------------+ * | TID | PID | Length | UID |Code | Data | * +-----------+---------------+------------------------------------------+ - * | | | | | - * (2) (3) (4) (5) (6) + * | | | | | + * (2) (3) (4) (5) (6) * - * (2) ... MB_TCP_TID = 0 (Transaction Identifier - 2 Byte) + * (2) ... MB_TCP_TID = 0 (Transaction Identifier - 2 Byte) * (3) ... MB_TCP_PID = 2 (Protocol Identifier - 2 Byte) * (4) ... MB_TCP_LEN = 4 (Number of bytes - 2 Byte) * (5) ... MB_TCP_UID = 6 (Unit Identifier - 1 Byte) @@ -135,9 +135,9 @@ eMBTCPSend( UCHAR _unused, const UCHAR * pucFrame, USHORT usLength ) USHORT usTCPLength = usLength + MB_TCP_FUNC; /* The MBAP header is already initialized because the caller calls this - * function with the buffer returned by the previous call. Therefore we - * only have to update the length in the header. Note that the length - * header includes the size of the Modbus PDU and the UID Byte. Therefore + * function with the buffer returned by the previous call. Therefore we + * only have to update the length in the header. Note that the length + * header includes the size of the Modbus PDU and the UID Byte. Therefore * the length is usLength plus one. */ pucMBTCPFrame[MB_TCP_LEN] = ( usLength + 1 ) >> 8U; diff --git a/components/freemodbus/modbus/tcp/mbtcp.h b/components/freemodbus/modbus/tcp/mbtcp.h index 6e55718..89e970a 100644 --- a/components/freemodbus/modbus/tcp/mbtcp.h +++ b/components/freemodbus/modbus/tcp/mbtcp.h @@ -1,4 +1,4 @@ -/* +/* * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. * Copyright (c) 2006 Christian Walter * All rights reserved. diff --git a/components/freemodbus/modbus/tcp/mbtcp_m.c b/components/freemodbus/modbus/tcp/mbtcp_m.c index 419710d..18359d6 100644 --- a/components/freemodbus/modbus/tcp/mbtcp_m.c +++ b/components/freemodbus/modbus/tcp/mbtcp_m.c @@ -1,4 +1,4 @@ -/* +/* * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. * Copyright (c) 2006 Christian Walter * All rights reserved. @@ -54,10 +54,10 @@ * +-----------+---------------+------------------------------------------+ * | TID | PID | Length | UID |Code | Data | * +-----------+---------------+------------------------------------------+ - * | | | | | - * (2) (3) (4) (5) (6) + * | | | | | + * (2) (3) (4) (5) (6) * - * (2) ... MB_TCP_TID = 0 (Transaction Identifier - 2 Byte) + * (2) ... MB_TCP_TID = 0 (Transaction Identifier - 2 Byte) * (3) ... MB_TCP_PID = 2 (Protocol Identifier - 2 Byte) * (4) ... MB_TCP_LEN = 4 (Number of bytes - 2 Byte) * (5) ... MB_TCP_UID = 6 (Unit Identifier - 1 Byte) @@ -135,9 +135,9 @@ eMBMasterTCPSend( UCHAR _unused, const UCHAR * pucFrame, USHORT usLength ) USHORT usTCPLength = usLength + MB_TCP_FUNC; /* The MBAP header is already initialized because the caller calls this - * function with the buffer returned by the previous call. Therefore we - * only have to update the length in the header. Note that the length - * header includes the size of the Modbus PDU and the UID Byte. Therefore + * function with the buffer returned by the previous call. Therefore we + * only have to update the length in the header. Note that the length + * header includes the size of the Modbus PDU and the UID Byte. Therefore * the length is usLength plus one. */ pucMBTCPFrame[MB_TCP_LEN] = ( usLength + 1 ) >> 8U; diff --git a/components/freemodbus/modbus/tcp/mbtcp_m.h b/components/freemodbus/modbus/tcp/mbtcp_m.h index 3445ca9..34aaa02 100644 --- a/components/freemodbus/modbus/tcp/mbtcp_m.h +++ b/components/freemodbus/modbus/tcp/mbtcp_m.h @@ -1,4 +1,4 @@ -/* +/* * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. * Copyright (c) 2006 Christian Walter * All rights reserved. diff --git a/components/freemodbus/port/portevent.c b/components/freemodbus/port/portevent.c index 42dde24..20e2bce 100644 --- a/components/freemodbus/port/portevent.c +++ b/components/freemodbus/port/portevent.c @@ -27,7 +27,7 @@ * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * IF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. @@ -87,7 +87,7 @@ xMBPortEventPost( eMBEventType eEvent ) { BaseType_t xStatus, xHigherPriorityTaskWoken = pdFALSE; assert(xQueueHdl != NULL); - + if( (BOOL)xPortInIsrContext() == TRUE ) { xStatus = xQueueSendFromISR(xQueueHdl, (const void*)&eEvent, &xHigherPriorityTaskWoken); @@ -129,4 +129,3 @@ xMBPortEventGetHandle(void) } return NULL; } - diff --git a/components/freemodbus/port/portevent_m.c b/components/freemodbus/port/portevent_m.c index 81c3c3b..21975bc 100644 --- a/components/freemodbus/port/portevent_m.c +++ b/components/freemodbus/port/portevent_m.c @@ -204,7 +204,7 @@ void vMBMasterRunResRelease( void ) * @param ucPDULength PDU buffer length * */ -void vMBMasterErrorCBRespondTimeout(UCHAR ucDestAddress, const UCHAR* pucPDUData, USHORT ucPDULength) +void vMBMasterErrorCBRespondTimeout(UCHAR ucDestAddress, const UCHAR* pucPDUData, USHORT ucPDULength) { BOOL ret = xMBMasterPortEventPost(EV_MASTER_ERROR_RESPOND_TIMEOUT); MB_PORT_CHECK((ret == TRUE), ; , "%s: Post event 'EV_MASTER_ERROR_RESPOND_TIMEOUT' failed!", __func__); @@ -219,7 +219,7 @@ void vMBMasterErrorCBRespondTimeout(UCHAR ucDestAddress, const UCHAR* pucPDUData * @param pucPDUData PDU buffer data * @param ucPDULength PDU buffer length */ -void vMBMasterErrorCBReceiveData(UCHAR ucDestAddress, const UCHAR* pucPDUData, USHORT ucPDULength) +void vMBMasterErrorCBReceiveData(UCHAR ucDestAddress, const UCHAR* pucPDUData, USHORT ucPDULength) { BOOL ret = xMBMasterPortEventPost(EV_MASTER_ERROR_RECEIVE_DATA); MB_PORT_CHECK((ret == TRUE), ; , "%s: Post event 'EV_MASTER_ERROR_RECEIVE_DATA' failed!", __func__); @@ -237,7 +237,7 @@ void vMBMasterErrorCBReceiveData(UCHAR ucDestAddress, const UCHAR* pucPDUData, U * @param ucPDULength PDU buffer length * */ -void vMBMasterErrorCBExecuteFunction(UCHAR ucDestAddress, const UCHAR* pucPDUData, USHORT ucPDULength) +void vMBMasterErrorCBExecuteFunction(UCHAR ucDestAddress, const UCHAR* pucPDUData, USHORT ucPDULength) { BOOL ret = xMBMasterPortEventPost(EV_MASTER_ERROR_EXECUTE_FUNCTION); MB_PORT_CHECK((ret == TRUE), ; , "%s: Post event 'EV_MASTER_ERROR_EXECUTE_FUNCTION' failed!", __func__); diff --git a/components/freemodbus/port/portother.c b/components/freemodbus/port/portother.c index 43b6e96..0ff251c 100644 --- a/components/freemodbus/port/portother.c +++ b/components/freemodbus/port/portother.c @@ -16,7 +16,7 @@ * FreeModbus Libary: ESP32 Demo Application * Copyright (C) 2010 Christian Walter * - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -27,7 +27,7 @@ * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * IF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. diff --git a/components/freemodbus/port/portother_m.c b/components/freemodbus/port/portother_m.c index 15b727a..bdc471c 100644 --- a/components/freemodbus/port/portother_m.c +++ b/components/freemodbus/port/portother_m.c @@ -68,4 +68,3 @@ vMBMasterPortClose( void ) vMBMasterPortTimerClose( ); vMBMasterPortEventClose( ); } - diff --git a/components/freemodbus/port/portserial.c b/components/freemodbus/port/portserial.c index 10fc1b5..1d2c6bf 100644 --- a/components/freemodbus/port/portserial.c +++ b/components/freemodbus/port/portserial.c @@ -48,7 +48,7 @@ #include "driver/gpio.h" #include "esp_log.h" // for esp_log #include "esp_err.h" // for ESP_ERROR_CHECK macro - + /* ----------------------- Modbus includes ----------------------------------*/ #include "mb.h" #include "mbport.h" @@ -283,4 +283,3 @@ BOOL xMBPortSerialGetByte(CHAR* pucByte) USHORT usLength = uart_read_bytes(ucUartNumber, (uint8_t*)pucByte, 1, MB_SERIAL_RX_TOUT_TICKS); return (usLength == 1); } - diff --git a/components/freemodbus/serial_master/modbus_controller/mbc_serial_master.c b/components/freemodbus/serial_master/modbus_controller/mbc_serial_master.c index 93ac313..5f65c52 100644 --- a/components/freemodbus/serial_master/modbus_controller/mbc_serial_master.c +++ b/components/freemodbus/serial_master/modbus_controller/mbc_serial_master.c @@ -146,9 +146,9 @@ static esp_err_t mbc_serial_master_destroy(void) // Set Modbus parameter description table static esp_err_t mbc_serial_master_set_descriptor(const mb_parameter_descriptor_t* descriptor, const uint16_t num_elements) { - MB_MASTER_CHECK((descriptor != NULL), + MB_MASTER_CHECK((descriptor != NULL), ESP_ERR_INVALID_ARG, "mb incorrect descriptor."); - MB_MASTER_CHECK((num_elements >= 1), + MB_MASTER_CHECK((num_elements >= 1), ESP_ERR_INVALID_ARG, "mb table size is incorrect."); mb_master_options_t* mbm_opts = &mbm_interface_ptr->opts; const mb_parameter_descriptor_t *reg_ptr = descriptor; @@ -156,11 +156,11 @@ static esp_err_t mbc_serial_master_set_descriptor(const mb_parameter_descriptor_ for (uint16_t counter = 0; counter < (num_elements); counter++, reg_ptr++) { // Below is the code to check consistency of the table format and required fields. - MB_MASTER_CHECK((reg_ptr->cid == counter), + MB_MASTER_CHECK((reg_ptr->cid == counter), ESP_ERR_INVALID_ARG, "mb descriptor cid field is incorrect."); - MB_MASTER_CHECK((reg_ptr->param_key != NULL), + MB_MASTER_CHECK((reg_ptr->param_key != NULL), ESP_ERR_INVALID_ARG, "mb descriptor param key is incorrect."); - MB_MASTER_CHECK((reg_ptr->mb_size > 0), + MB_MASTER_CHECK((reg_ptr->mb_size > 0), ESP_ERR_INVALID_ARG, "mb descriptor param size is incorrect."); } mbm_opts->mbm_param_descriptor_table = descriptor; @@ -175,9 +175,9 @@ static esp_err_t mbc_serial_master_send_request(mb_param_request_t* request, voi ESP_ERR_INVALID_STATE, "Master interface uninitialized."); mb_master_options_t* mbm_opts = &mbm_interface_ptr->opts; - MB_MASTER_CHECK((request != NULL), + MB_MASTER_CHECK((request != NULL), ESP_ERR_INVALID_ARG, "mb request structure."); - MB_MASTER_CHECK((data_ptr != NULL), + MB_MASTER_CHECK((data_ptr != NULL), ESP_ERR_INVALID_ARG, "mb incorrect data pointer."); eMBMasterReqErrCode mb_error = MB_MRE_NO_REG; @@ -283,17 +283,17 @@ static esp_err_t mbc_serial_master_get_cid_info(uint16_t cid, const mb_parameter "Master interface uninitialized."); mb_master_options_t* mbm_opts = &mbm_interface_ptr->opts; - MB_MASTER_CHECK((param_buffer != NULL), + MB_MASTER_CHECK((param_buffer != NULL), ESP_ERR_INVALID_ARG, "mb incorrect data buffer pointer."); - MB_MASTER_CHECK((mbm_opts->mbm_param_descriptor_table != NULL), + MB_MASTER_CHECK((mbm_opts->mbm_param_descriptor_table != NULL), ESP_ERR_INVALID_ARG, "mb incorrect descriptor table or not set."); - MB_MASTER_CHECK((cid < mbm_opts->mbm_param_descriptor_size), + MB_MASTER_CHECK((cid < mbm_opts->mbm_param_descriptor_size), ESP_ERR_NOT_FOUND, "mb incorrect cid of characteristic."); // It is assumed that characteristics cid increased in the table const mb_parameter_descriptor_t* reg_info = &mbm_opts->mbm_param_descriptor_table[cid]; - MB_MASTER_CHECK((reg_info->param_key != NULL), + MB_MASTER_CHECK((reg_info->param_key != NULL), ESP_ERR_INVALID_ARG, "mb incorrect characteristic key."); *param_buffer = reg_info; return ESP_OK; @@ -306,37 +306,37 @@ static uint8_t mbc_serial_master_get_command(mb_param_type_t param_type, mb_para switch(param_type) { // case MB_PARAM_HOLDING: - command = (mode == MB_PARAM_WRITE) ? - MB_FUNC_WRITE_MULTIPLE_REGISTERS : + command = (mode == MB_PARAM_WRITE) ? + MB_FUNC_WRITE_MULTIPLE_REGISTERS : MB_FUNC_READ_HOLDING_REGISTER; break; case MB_PARAM_INPUT: command = MB_FUNC_READ_INPUT_REGISTER; break; case MB_PARAM_COIL: - command = (mode == MB_PARAM_WRITE) ? - MB_FUNC_WRITE_MULTIPLE_COILS : + command = (mode == MB_PARAM_WRITE) ? + MB_FUNC_WRITE_MULTIPLE_COILS : MB_FUNC_READ_COILS; break; case MB_PARAM_DISCRETE: if (mode != MB_PARAM_WRITE) { command = MB_FUNC_READ_DISCRETE_INPUTS; } else { - ESP_LOGE(MB_MASTER_TAG, "%s: Incorrect mode (%u)", + ESP_LOGE(MB_MASTER_TAG, "%s: Incorrect mode (%u)", __FUNCTION__, (uint8_t)mode); } break; default: - ESP_LOGE(MB_MASTER_TAG, "%s: Incorrect param type (%u)", + ESP_LOGE(MB_MASTER_TAG, "%s: Incorrect param type (%u)", __FUNCTION__, param_type); break; } return command; } -// Helper to search parameter by name in the parameter description table +// Helper to search parameter by name in the parameter description table // and fills Modbus request fields accordingly -static esp_err_t mbc_serial_master_set_request(char* name, mb_param_mode_t mode, +static esp_err_t mbc_serial_master_set_request(char* name, mb_param_mode_t mode, mb_param_request_t* request, mb_parameter_descriptor_t* reg_data) { @@ -345,11 +345,11 @@ static esp_err_t mbc_serial_master_set_request(char* name, mb_param_mode_t mode, "Master interface uninitialized."); mb_master_options_t* mbm_opts = &mbm_interface_ptr->opts; esp_err_t error = ESP_ERR_NOT_FOUND; - MB_MASTER_CHECK((name != NULL), + MB_MASTER_CHECK((name != NULL), ESP_ERR_INVALID_ARG, "mb incorrect parameter name."); - MB_MASTER_CHECK((request != NULL), + MB_MASTER_CHECK((request != NULL), ESP_ERR_INVALID_ARG, "mb incorrect request parameter."); - MB_MASTER_CHECK((mode <= MB_PARAM_WRITE), + MB_MASTER_CHECK((mode <= MB_PARAM_WRITE), ESP_ERR_INVALID_ARG, "mb incorrect mode."); MB_MASTER_ASSERT(mbm_opts->mbm_param_descriptor_table != NULL); const mb_parameter_descriptor_t* reg_ptr = mbm_opts->mbm_param_descriptor_table; @@ -369,8 +369,8 @@ static esp_err_t mbc_serial_master_set_request(char* name, mb_param_mode_t mode, request->reg_start = reg_ptr->mb_reg_start; request->reg_size = reg_ptr->mb_size; request->command = mbc_serial_master_get_command(reg_ptr->mb_param_type, mode); - MB_MASTER_CHECK((request->command > 0), - ESP_ERR_INVALID_ARG, + MB_MASTER_CHECK((request->command > 0), + ESP_ERR_INVALID_ARG, "mb incorrect command or parameter type."); if (reg_data != NULL) { *reg_data = *reg_ptr; // Set the cid registered parameter data @@ -383,12 +383,12 @@ static esp_err_t mbc_serial_master_set_request(char* name, mb_param_mode_t mode, } // Get parameter data for corresponding characteristic -static esp_err_t mbc_serial_master_get_parameter(uint16_t cid, char* name, +static esp_err_t mbc_serial_master_get_parameter(uint16_t cid, char* name, uint8_t* value_ptr, uint8_t *type) { - MB_MASTER_CHECK((name != NULL), + MB_MASTER_CHECK((name != NULL), ESP_ERR_INVALID_ARG, "mb incorrect descriptor."); - MB_MASTER_CHECK((type != NULL), + MB_MASTER_CHECK((type != NULL), ESP_ERR_INVALID_ARG, "type pointer is incorrect."); esp_err_t error = ESP_ERR_INVALID_RESPONSE; mb_param_request_t request ; @@ -415,14 +415,14 @@ static esp_err_t mbc_serial_master_get_parameter(uint16_t cid, char* name, } // Set parameter value for characteristic selected by name and cid -static esp_err_t mbc_serial_master_set_parameter(uint16_t cid, char* name, +static esp_err_t mbc_serial_master_set_parameter(uint16_t cid, char* name, uint8_t* value_ptr, uint8_t *type) { - MB_MASTER_CHECK((name != NULL), + MB_MASTER_CHECK((name != NULL), ESP_ERR_INVALID_ARG, "mb incorrect descriptor."); MB_MASTER_CHECK((value_ptr != NULL), ESP_ERR_INVALID_ARG, "value pointer is incorrect."); - MB_MASTER_CHECK((type != NULL), + MB_MASTER_CHECK((type != NULL), ESP_ERR_INVALID_ARG, "type pointer is incorrect."); esp_err_t error = ESP_ERR_INVALID_RESPONSE; mb_param_request_t request ; @@ -471,7 +471,7 @@ eMBErrorCode eMBRegInputCBSerialMaster(UCHAR * pucRegBuffer, USHORT usAddress, "Master stack processing error."); mb_master_options_t* mbm_opts = &mbm_interface_ptr->opts; // Number of input registers to be transferred - USHORT usRegInputNregs = (USHORT)mbm_opts->mbm_reg_buffer_size; + USHORT usRegInputNregs = (USHORT)mbm_opts->mbm_reg_buffer_size; UCHAR* pucInputBuffer = (UCHAR*)mbm_opts->mbm_reg_buffer_ptr; // Get instance address USHORT usRegs = usNRegs; eMBErrorCode eStatus = MB_ENOERR; @@ -555,7 +555,7 @@ eMBErrorCode eMBRegCoilsCBSerialMaster(UCHAR* pucRegBuffer, USHORT usAddress, { MB_MASTER_CHECK((mbm_interface_ptr != NULL), MB_EILLSTATE, "Master interface uninitialized."); - MB_MASTER_CHECK((pucRegBuffer != NULL), + MB_MASTER_CHECK((pucRegBuffer != NULL), MB_EINVAL, "Master stack processing error."); mb_master_options_t* mbm_opts = &mbm_interface_ptr->opts; USHORT usRegCoilNregs = (USHORT)mbm_opts->mbm_reg_buffer_size; @@ -608,7 +608,7 @@ eMBErrorCode eMBRegDiscreteCBSerialMaster(UCHAR * pucRegBuffer, USHORT usAddress { MB_MASTER_CHECK((mbm_interface_ptr != NULL), MB_EILLSTATE, "Master interface uninitialized."); - MB_MASTER_CHECK((pucRegBuffer != NULL), + MB_MASTER_CHECK((pucRegBuffer != NULL), MB_EINVAL, "Master stack processing error."); mb_master_options_t* mbm_opts = &mbm_interface_ptr->opts; USHORT usRegDiscreteNregs = (USHORT)mbm_opts->mbm_reg_buffer_size; @@ -666,7 +666,7 @@ esp_err_t mbc_serial_master_create(void** handler) BaseType_t status = 0; // Parameter change notification queue mbm_opts->mbm_event_group = xEventGroupCreate(); - MB_MASTER_CHECK((mbm_opts->mbm_event_group != NULL), + MB_MASTER_CHECK((mbm_opts->mbm_event_group != NULL), ESP_ERR_NO_MEM, "mb event group error."); // Create modbus controller task status = xTaskCreate((void*)&modbus_master_task, diff --git a/components/freemodbus/serial_master/modbus_controller/mbc_serial_master.h b/components/freemodbus/serial_master/modbus_controller/mbc_serial_master.h index ab9f46a..5ed72c9 100644 --- a/components/freemodbus/serial_master/modbus_controller/mbc_serial_master.h +++ b/components/freemodbus/serial_master/modbus_controller/mbc_serial_master.h @@ -35,4 +35,3 @@ esp_err_t mbc_serial_master_create(void** handler); #endif // _MODBUS_SERIAL_CONTROLLER_MASTER - diff --git a/components/freemodbus/serial_slave/modbus_controller/mbc_serial_slave.c b/components/freemodbus/serial_slave/modbus_controller/mbc_serial_slave.c index 9221279..eae69e2 100644 --- a/components/freemodbus/serial_slave/modbus_controller/mbc_serial_slave.c +++ b/components/freemodbus/serial_slave/modbus_controller/mbc_serial_slave.c @@ -33,7 +33,7 @@ static mb_slave_interface_t* mbs_interface_ptr = NULL; // Modbus task function static void modbus_slave_task(void *pvParameters) { - // Modbus interface must be initialized before start + // Modbus interface must be initialized before start MB_SLAVE_ASSERT(mbs_interface_ptr != NULL); mb_slave_options_t* mbs_opts = &mbs_interface_ptr->opts; @@ -250,9 +250,9 @@ static esp_err_t mbc_serial_slave_get_param_info(mb_param_info_t* reg_info, uint eMBErrorCode eMBRegInputCBSerialSlave(UCHAR * pucRegBuffer, USHORT usAddress, USHORT usNRegs) { - MB_SLAVE_CHECK((mbs_interface_ptr != NULL), + MB_SLAVE_CHECK((mbs_interface_ptr != NULL), MB_EILLSTATE, "Slave stack uninitialized."); - MB_SLAVE_CHECK((pucRegBuffer != NULL), + MB_SLAVE_CHECK((pucRegBuffer != NULL), MB_EINVAL, "Slave stack call failed."); mb_slave_options_t* mbs_opts = &mbs_interface_ptr->opts; USHORT usRegInputNregs = (USHORT)(mbs_opts->mbs_area_descriptors[MB_PARAM_INPUT].size >> 1); // Number of input registers @@ -292,9 +292,9 @@ eMBErrorCode eMBRegInputCBSerialSlave(UCHAR * pucRegBuffer, USHORT usAddress, eMBErrorCode eMBRegHoldingCBSerialSlave(UCHAR * pucRegBuffer, USHORT usAddress, USHORT usNRegs, eMBRegisterMode eMode) { - MB_SLAVE_CHECK((mbs_interface_ptr != NULL), + MB_SLAVE_CHECK((mbs_interface_ptr != NULL), MB_EILLSTATE, "Slave stack uninitialized."); - MB_SLAVE_CHECK((pucRegBuffer != NULL), + MB_SLAVE_CHECK((pucRegBuffer != NULL), MB_EINVAL, "Slave stack call failed."); mb_slave_options_t* mbs_opts = &mbs_interface_ptr->opts; USHORT usRegHoldingNregs = (USHORT)(mbs_opts->mbs_area_descriptors[MB_PARAM_HOLDING].size >> 1); @@ -350,9 +350,9 @@ eMBErrorCode eMBRegHoldingCBSerialSlave(UCHAR * pucRegBuffer, USHORT usAddress, eMBErrorCode eMBRegCoilsCBSerialSlave(UCHAR* pucRegBuffer, USHORT usAddress, USHORT usNCoils, eMBRegisterMode eMode) { - MB_SLAVE_CHECK((mbs_interface_ptr != NULL), + MB_SLAVE_CHECK((mbs_interface_ptr != NULL), MB_EILLSTATE, "Slave stack uninitialized."); - MB_SLAVE_CHECK((pucRegBuffer != NULL), + MB_SLAVE_CHECK((pucRegBuffer != NULL), MB_EINVAL, "Slave stack call failed."); mb_slave_options_t* mbs_opts = &mbs_interface_ptr->opts; USHORT usRegCoilNregs = (USHORT)(mbs_opts->mbs_area_descriptors[MB_PARAM_COIL].size >> 1); // number of registers in storage area @@ -407,9 +407,9 @@ eMBErrorCode eMBRegCoilsCBSerialSlave(UCHAR* pucRegBuffer, USHORT usAddress, eMBErrorCode eMBRegDiscreteCBSerialSlave(UCHAR* pucRegBuffer, USHORT usAddress, USHORT usNDiscrete) { - MB_SLAVE_CHECK((mbs_interface_ptr != NULL), + MB_SLAVE_CHECK((mbs_interface_ptr != NULL), MB_EILLSTATE, "Slave stack uninitialized."); - MB_SLAVE_CHECK((pucRegBuffer != NULL), + MB_SLAVE_CHECK((pucRegBuffer != NULL), MB_EINVAL, "Slave stack call failed."); mb_slave_options_t* mbs_opts = &mbs_interface_ptr->opts; USHORT usRegDiscreteNregs = (USHORT)(mbs_opts->mbs_area_descriptors[MB_PARAM_DISCRETE].size >> 1); // number of registers in storage area @@ -518,4 +518,3 @@ esp_err_t mbc_serial_slave_create(void** handler) return ESP_OK; } - diff --git a/components/freemodbus/serial_slave/modbus_controller/mbc_serial_slave.h b/components/freemodbus/serial_slave/modbus_controller/mbc_serial_slave.h index 85558e9..e8c5c3d 100644 --- a/components/freemodbus/serial_slave/modbus_controller/mbc_serial_slave.h +++ b/components/freemodbus/serial_slave/modbus_controller/mbc_serial_slave.h @@ -37,4 +37,3 @@ esp_err_t mbc_serial_slave_create(void** handler); #endif // _MODBUS_SERIAL_CONTROLLER_SLAVE - diff --git a/components/freemodbus/tcp_master/modbus_controller/mbc_tcp_master.c b/components/freemodbus/tcp_master/modbus_controller/mbc_tcp_master.c index 5b5bb32..158aa7a 100644 --- a/components/freemodbus/tcp_master/modbus_controller/mbc_tcp_master.c +++ b/components/freemodbus/tcp_master/modbus_controller/mbc_tcp_master.c @@ -161,7 +161,7 @@ static esp_err_t mbc_tcp_master_set_descriptor(const mb_parameter_descriptor_t* MB_MASTER_CHECK((num_elements >= 1), ESP_ERR_INVALID_ARG, "mb table size is incorrect."); mb_master_options_t* mbm_opts = &mbm_interface_ptr->opts; MB_MASTER_CHECK((mbm_opts != NULL), ESP_ERR_INVALID_ARG, "mb options."); - + const char** comm_ip_table = (const char**)mbm_opts->mbm_comm.ip_addr; MB_MASTER_CHECK((comm_ip_table != NULL), ESP_ERR_INVALID_ARG, "mb ip table address is incorrect."); diff --git a/components/freemodbus/tcp_master/modbus_controller/mbc_tcp_master.h b/components/freemodbus/tcp_master/modbus_controller/mbc_tcp_master.h index 612f8a1..9593f77 100644 --- a/components/freemodbus/tcp_master/modbus_controller/mbc_tcp_master.h +++ b/components/freemodbus/tcp_master/modbus_controller/mbc_tcp_master.h @@ -40,4 +40,3 @@ esp_err_t mbc_tcp_master_create(void** handler); #endif // _MODBUS_TCP_CONTROLLER_SLAVE - diff --git a/components/freemodbus/tcp_slave/modbus_controller/mbc_tcp_slave.h b/components/freemodbus/tcp_slave/modbus_controller/mbc_tcp_slave.h index efa9194..0987610 100644 --- a/components/freemodbus/tcp_slave/modbus_controller/mbc_tcp_slave.h +++ b/components/freemodbus/tcp_slave/modbus_controller/mbc_tcp_slave.h @@ -38,4 +38,3 @@ esp_err_t mbc_tcp_slave_create(void** handler); #endif // _MODBUS_TCP_CONTROLLER_SLAVE - diff --git a/components/freemodbus/tcp_slave/port/port_tcp_slave.c b/components/freemodbus/tcp_slave/port/port_tcp_slave.c index 5a9d254..67f04c2 100644 --- a/components/freemodbus/tcp_slave/port/port_tcp_slave.c +++ b/components/freemodbus/tcp_slave/port/port_tcp_slave.c @@ -706,4 +706,3 @@ xMBTCPPortSendResponse( UCHAR * pucMBTCPFrame, USHORT usTCPLength ) } return bFrameSent; } - diff --git a/examples/protocols/modbus/mb_example_common/CMakeLists.txt b/examples/protocols/modbus/mb_example_common/CMakeLists.txt index 5dceb36..9b12675 100644 --- a/examples/protocols/modbus/mb_example_common/CMakeLists.txt +++ b/examples/protocols/modbus/mb_example_common/CMakeLists.txt @@ -3,4 +3,4 @@ cmake_minimum_required(VERSION 3.5) idf_component_register(SRCS "modbus_params.c" INCLUDE_DIRS "include" - PRIV_REQUIRES freemodbus) \ No newline at end of file + PRIV_REQUIRES freemodbus) diff --git a/examples/protocols/modbus/mb_example_common/component.mk b/examples/protocols/modbus/mb_example_common/component.mk index 9b8ec90..f0dc18c 100644 --- a/examples/protocols/modbus/mb_example_common/component.mk +++ b/examples/protocols/modbus/mb_example_common/component.mk @@ -2,4 +2,4 @@ # Component Makefile # COMPONENT_ADD_INCLUDEDIRS := include -COMPONENT_SRCDIRS := . \ No newline at end of file +COMPONENT_SRCDIRS := . diff --git a/examples/protocols/modbus/mb_example_common/modbus_params.c b/examples/protocols/modbus/mb_example_common/modbus_params.c index 5a0bcad..ab31ba4 100644 --- a/examples/protocols/modbus/mb_example_common/modbus_params.c +++ b/examples/protocols/modbus/mb_example_common/modbus_params.c @@ -14,4 +14,3 @@ input_reg_params_t input_reg_params = { 0 }; coil_reg_params_t coil_reg_params = { 0 }; discrete_reg_params_t discrete_reg_params = { 0 }; - diff --git a/examples/protocols/modbus/serial/mb_master/Makefile b/examples/protocols/modbus/serial/mb_master/Makefile index 8119959..458a97b 100644 --- a/examples/protocols/modbus/serial/mb_master/Makefile +++ b/examples/protocols/modbus/serial/mb_master/Makefile @@ -8,4 +8,3 @@ PROJECT_NAME := modbus_master EXTRA_COMPONENT_DIRS := $(IDF_PATH)/examples/protocols/modbus/mb_example_common include $(IDF_PATH)/make/project.mk - diff --git a/examples/protocols/modbus/serial/mb_master/main/CMakeLists.txt b/examples/protocols/modbus/serial/mb_master/main/CMakeLists.txt index 9a6cf30..f9ab7f6 100644 --- a/examples/protocols/modbus/serial/mb_master/main/CMakeLists.txt +++ b/examples/protocols/modbus/serial/mb_master/main/CMakeLists.txt @@ -2,4 +2,3 @@ set(PROJECT_NAME "modbus_master") idf_component_register(SRCS "master.c" INCLUDE_DIRS ".") - diff --git a/examples/protocols/modbus/serial/mb_master/main/master.c b/examples/protocols/modbus/serial/mb_master/main/master.c index 227785d..6b71a57 100644 --- a/examples/protocols/modbus/serial/mb_master/main/master.c +++ b/examples/protocols/modbus/serial/mb_master/main/master.c @@ -148,12 +148,12 @@ static void master_operation_func(void *arg) float value = 0; bool alarm_state = false; const mb_parameter_descriptor_t* param_descriptor = NULL; - + ESP_LOGI(MASTER_TAG, "Start modbus test..."); - + for(uint16_t retry = 0; retry <= MASTER_MAX_RETRY && (!alarm_state); retry++) { // Read all found characteristics from slave(s) - for (uint16_t cid = 0; (err != ESP_ERR_NOT_FOUND) && cid < MASTER_MAX_CIDS; cid++) + for (uint16_t cid = 0; (err != ESP_ERR_NOT_FOUND) && cid < MASTER_MAX_CIDS; cid++) { // Get data from parameters description table // and use this information to fill the characteristics description table @@ -244,10 +244,10 @@ static void master_operation_func(void *arg) vTaskDelay(POLL_TIMEOUT_TICS); // timeout between polls } } - vTaskDelay(UPDATE_CIDS_TIMEOUT_TICS); // + vTaskDelay(UPDATE_CIDS_TIMEOUT_TICS); // } - - if (alarm_state) { + + if (alarm_state) { ESP_LOGI(MASTER_TAG, "Alarm triggered by cid #%d.", param_descriptor->cid); } else { @@ -315,6 +315,6 @@ void app_main(void) // Initialization of device peripheral and objects ESP_ERROR_CHECK(master_init()); vTaskDelay(10); - + master_operation_func(NULL); } diff --git a/examples/protocols/modbus/serial/mb_slave/Makefile b/examples/protocols/modbus/serial/mb_slave/Makefile index b9df4ba..c3aa218 100644 --- a/examples/protocols/modbus/serial/mb_slave/Makefile +++ b/examples/protocols/modbus/serial/mb_slave/Makefile @@ -8,4 +8,3 @@ PROJECT_NAME := modbus_slave EXTRA_COMPONENT_DIRS := $(IDF_PATH)/examples/protocols/modbus/mb_example_common include $(IDF_PATH)/make/project.mk - diff --git a/examples/protocols/modbus/serial/mb_slave/main/CMakeLists.txt b/examples/protocols/modbus/serial/mb_slave/main/CMakeLists.txt index b4a0874..561fa6c 100644 --- a/examples/protocols/modbus/serial/mb_slave/main/CMakeLists.txt +++ b/examples/protocols/modbus/serial/mb_slave/main/CMakeLists.txt @@ -1,4 +1,4 @@ set(PROJECT_NAME "modbus_slave") idf_component_register(SRCS "slave.c" - INCLUDE_DIRS ".") \ No newline at end of file + INCLUDE_DIRS ".") diff --git a/examples/protocols/modbus/serial/mb_slave/main/slave.c b/examples/protocols/modbus/serial/mb_slave/main/slave.c index 70a23d3..9d8763a 100644 --- a/examples/protocols/modbus/serial/mb_slave/main/slave.c +++ b/examples/protocols/modbus/serial/mb_slave/main/slave.c @@ -128,7 +128,7 @@ void app_main(void) // Starts of modbus controller and stack ESP_ERROR_CHECK(mbc_slave_start()); - + // Set UART pin numbers ESP_ERROR_CHECK(uart_set_pin(MB_PORT_NUM, CONFIG_MB_UART_TXD, CONFIG_MB_UART_RXD, CONFIG_MB_UART_RTS, @@ -136,7 +136,7 @@ void app_main(void) // Set UART driver mode to Half Duplex ESP_ERROR_CHECK(uart_set_mode(MB_PORT_NUM, UART_MODE_RS485_HALF_DUPLEX)); - + ESP_LOGI(SLAVE_TAG, "Modbus slave stack initialized."); ESP_LOGI(SLAVE_TAG, "Start modbus test..."); diff --git a/examples/protocols/modbus/tcp/mb_tcp_master/main/CMakeLists.txt b/examples/protocols/modbus/tcp/mb_tcp_master/main/CMakeLists.txt index 6a75e2d..842f186 100644 --- a/examples/protocols/modbus/tcp/mb_tcp_master/main/CMakeLists.txt +++ b/examples/protocols/modbus/tcp/mb_tcp_master/main/CMakeLists.txt @@ -2,4 +2,3 @@ set(PROJECT_NAME "modbus_tcp_master") idf_component_register(SRCS "tcp_master.c" INCLUDE_DIRS ".") - diff --git a/examples/protocols/modbus/tcp/mb_tcp_master/main/tcp_master.c b/examples/protocols/modbus/tcp/mb_tcp_master/main/tcp_master.c index 5a9cb62..375cf9c 100644 --- a/examples/protocols/modbus/tcp/mb_tcp_master/main/tcp_master.c +++ b/examples/protocols/modbus/tcp/mb_tcp_master/main/tcp_master.c @@ -77,7 +77,7 @@ #define MB_MDNS_INSTANCE(pref) pref"mb_master_tcp" -// Enumeration of modbus device addresses accessed by master device +// Enumeration of modbus device addresses accessed by master device // Each address in the table is a index of TCP slave ip address in mb_communication_info_t::tcp_ip_addr table enum { MB_DEVICE_ADDR1 = 1, // Slave address 1 @@ -432,12 +432,12 @@ static void master_operation_func(void *arg) float value = 0; bool alarm_state = false; const mb_parameter_descriptor_t* param_descriptor = NULL; - + ESP_LOGI(MASTER_TAG, "Start modbus test..."); - + for(uint16_t retry = 0; retry <= MASTER_MAX_RETRY && (!alarm_state); retry++) { // Read all found characteristics from slave(s) - for (uint16_t cid = 0; (err != ESP_ERR_NOT_FOUND) && cid < MASTER_MAX_CIDS; cid++) + for (uint16_t cid = 0; (err != ESP_ERR_NOT_FOUND) && cid < MASTER_MAX_CIDS; cid++) { // Get data from parameters description table // and use this information to fill the characteristics description table @@ -447,7 +447,7 @@ static void master_operation_func(void *arg) void* temp_data_ptr = master_get_param_data(param_descriptor); assert(temp_data_ptr); uint8_t type = 0; - err = mbc_master_get_parameter(cid, (char*)param_descriptor->param_key, + err = mbc_master_get_parameter(cid, (char*)param_descriptor->param_key, (uint8_t*)&value, &type); if (err == ESP_OK) { *(float*)temp_data_ptr = value; @@ -455,9 +455,9 @@ static void master_operation_func(void *arg) (param_descriptor->mb_param_type == MB_PARAM_INPUT)) { ESP_LOGI(MASTER_TAG, "Characteristic #%d %s (%s) value = %f (0x%x) read successful.", param_descriptor->cid, - (char*)param_descriptor->param_key, + (char*)param_descriptor->param_key, (char*)param_descriptor->param_units, - value, + value, *(uint32_t*)temp_data_ptr); if (((value > param_descriptor->param_opts.max) || (value < param_descriptor->param_opts.min))) { @@ -469,7 +469,7 @@ static void master_operation_func(void *arg) const char* rw_str = (state & param_descriptor->param_opts.opt1) ? "ON" : "OFF"; ESP_LOGI(MASTER_TAG, "Characteristic #%d %s (%s) value = %s (0x%x) read successful.", param_descriptor->cid, - (char*)param_descriptor->param_key, + (char*)param_descriptor->param_key, (char*)param_descriptor->param_units, (const char*)rw_str, *(uint16_t*)temp_data_ptr); @@ -490,8 +490,8 @@ static void master_operation_func(void *arg) } vTaskDelay(UPDATE_CIDS_TIMEOUT_TICS); } - - if (alarm_state) { + + if (alarm_state) { ESP_LOGI(MASTER_TAG, "Alarm triggered by cid #%d.", param_descriptor->cid); } else { @@ -591,7 +591,7 @@ void app_main(void) // Initialization of device peripheral and objects ESP_ERROR_CHECK(master_init()); vTaskDelay(10); - + master_operation_func(NULL); #if CONFIG_MB_MDNS_IP_RESOLVER master_destroy_slave_list(slave_ip_address_table); diff --git a/examples/protocols/modbus/tcp/mb_tcp_master/sdkconfig.defaults b/examples/protocols/modbus/tcp/mb_tcp_master/sdkconfig.defaults index baccdaf..36ecd58 100644 --- a/examples/protocols/modbus/tcp/mb_tcp_master/sdkconfig.defaults +++ b/examples/protocols/modbus/tcp/mb_tcp_master/sdkconfig.defaults @@ -16,4 +16,4 @@ CONFIG_FMB_TIMER_INDEX=0 CONFIG_FMB_TIMER_ISR_IN_IRAM=y CONFIG_MB_MDNS_IP_RESOLVER=n CONFIG_MB_SLAVE_IP_FROM_STDIN=y -CONFIG_EXAMPLE_CONNECT_IPV6=n \ No newline at end of file +CONFIG_EXAMPLE_CONNECT_IPV6=n diff --git a/examples/protocols/modbus/tcp/mb_tcp_slave/Makefile b/examples/protocols/modbus/tcp/mb_tcp_slave/Makefile index e93a985..892d758 100644 --- a/examples/protocols/modbus/tcp/mb_tcp_slave/Makefile +++ b/examples/protocols/modbus/tcp/mb_tcp_slave/Makefile @@ -8,4 +8,3 @@ EXTRA_COMPONENT_DIRS := $(IDF_PATH)/examples/protocols/modbus/mb_example_common EXTRA_COMPONENT_DIRS += $(IDF_PATH)/examples/common_components/protocol_examples_common include $(IDF_PATH)/make/project.mk - diff --git a/examples/protocols/modbus/tcp/mb_tcp_slave/main/CMakeLists.txt b/examples/protocols/modbus/tcp/mb_tcp_slave/main/CMakeLists.txt index 33dbfa3..588a20f 100644 --- a/examples/protocols/modbus/tcp/mb_tcp_slave/main/CMakeLists.txt +++ b/examples/protocols/modbus/tcp/mb_tcp_slave/main/CMakeLists.txt @@ -1,4 +1,4 @@ set(PROJECT_NAME "modbus_tcp_slave") idf_component_register(SRCS "tcp_slave.c" - INCLUDE_DIRS ".") \ No newline at end of file + INCLUDE_DIRS ".") diff --git a/examples/protocols/modbus/tcp/mb_tcp_slave/main/Kconfig.projbuild b/examples/protocols/modbus/tcp/mb_tcp_slave/main/Kconfig.projbuild index 1c6d766..45c10bb 100644 --- a/examples/protocols/modbus/tcp/mb_tcp_slave/main/Kconfig.projbuild +++ b/examples/protocols/modbus/tcp/mb_tcp_slave/main/Kconfig.projbuild @@ -15,4 +15,4 @@ menu "Modbus Example Configuration" This option allows to use mDNS service to resolve IP addresses of the Modbus slaves. If the option is disabled the ip addresses of slaves are defined in static table. -endmenu \ No newline at end of file +endmenu diff --git a/examples/protocols/modbus/tcp/mb_tcp_slave/main/tcp_slave.c b/examples/protocols/modbus/tcp/mb_tcp_slave/main/tcp_slave.c index a74b0c2..b1c1085 100644 --- a/examples/protocols/modbus/tcp/mb_tcp_slave/main/tcp_slave.c +++ b/examples/protocols/modbus/tcp/mb_tcp_slave/main/tcp_slave.c @@ -168,10 +168,10 @@ void app_main(void) void* mbc_slave_handler = NULL; ESP_ERROR_CHECK(mbc_slave_init_tcp(&mbc_slave_handler)); // Initialization of Modbus controller - + mb_param_info_t reg_info; // keeps the Modbus registers access information mb_register_area_descriptor_t reg_area; // Modbus register area descriptor structure - + mb_communication_info_t comm_info = { 0 }; comm_info.ip_port = MB_TCP_PORT_NUMBER; #if !CONFIG_EXAMPLE_CONNECT_IPV6 diff --git a/examples/protocols/modbus/tcp/mb_tcp_slave/sdkconfig.defaults b/examples/protocols/modbus/tcp/mb_tcp_slave/sdkconfig.defaults index 578350f..6184c9f 100644 --- a/examples/protocols/modbus/tcp/mb_tcp_slave/sdkconfig.defaults +++ b/examples/protocols/modbus/tcp/mb_tcp_slave/sdkconfig.defaults @@ -18,4 +18,4 @@ CONFIG_MB_MDNS_IP_RESOLVER=n CONFIG_MB_SLAVE_IP_FROM_STDIN=y CONFIG_MB_SLAVE_ADDR=1 CONFIG_LOG_DEFAULT_LEVEL_DEBUG=y -CONFIG_EXAMPLE_CONNECT_IPV6=n \ No newline at end of file +CONFIG_EXAMPLE_CONNECT_IPV6=n