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@66fb5a29bb
This commit is contained in:
Angus Gratton
2020-11-10 18:40:01 +11:00
committed by aleks
parent fb445432c4
commit e0102243f5
68 changed files with 227 additions and 247 deletions

View File

@@ -18,7 +18,7 @@
#include "esp_modbus_master.h" // for public interface defines #include "esp_modbus_master.h" // for public interface defines
#include "esp_modbus_callbacks.h" // for callback functions #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 // These functions are wrappers for interface functions of the controller
static mb_master_interface_t* master_interface_ptr = NULL; static mb_master_interface_t* master_interface_ptr = NULL;
@@ -40,8 +40,8 @@ esp_err_t mbc_master_destroy(void)
ESP_ERR_INVALID_STATE, ESP_ERR_INVALID_STATE,
"Master interface is not correctly initialized."); "Master interface is not correctly initialized.");
error = master_interface_ptr->destroy(); error = master_interface_ptr->destroy();
MB_MASTER_CHECK((error == ESP_OK), MB_MASTER_CHECK((error == ESP_OK),
error, error,
"Master destroy failure, error=(0x%x).", "Master destroy failure, error=(0x%x).",
error); error);
return 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, ESP_ERR_INVALID_STATE,
"Master interface is not correctly initialized."); "Master interface is not correctly initialized.");
error = master_interface_ptr->get_cid_info(cid, param_info); error = master_interface_ptr->get_cid_info(cid, param_info);
MB_MASTER_CHECK((error == ESP_OK), MB_MASTER_CHECK((error == ESP_OK),
error, error,
"Master get cid info failure, error=(0x%x).", "Master get cid info failure, error=(0x%x).",
error); error);
return 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, ESP_ERR_INVALID_STATE,
"Master interface is not correctly initialized."); "Master interface is not correctly initialized.");
error = master_interface_ptr->get_parameter(cid, name, value, type); error = master_interface_ptr->get_parameter(cid, name, value, type);
MB_MASTER_CHECK((error == ESP_OK), MB_MASTER_CHECK((error == ESP_OK),
error, error,
"Master get parameter failure, error=(0x%x) (%s).", "Master get parameter failure, error=(0x%x) (%s).",
error, esp_err_to_name(error)); 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, ESP_ERR_INVALID_STATE,
"Master interface is not correctly initialized."); "Master interface is not correctly initialized.");
error = master_interface_ptr->send_request(request, data_ptr); error = master_interface_ptr->send_request(request, data_ptr);
MB_MASTER_CHECK((error == ESP_OK), MB_MASTER_CHECK((error == ESP_OK),
error, error,
"Master send request failure error=(0x%x) (%s).", "Master send request failure error=(0x%x) (%s).",
error, esp_err_to_name(error)); 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, ESP_ERR_INVALID_STATE,
"Master interface is not correctly initialized."); "Master interface is not correctly initialized.");
error = master_interface_ptr->set_descriptor(descriptor, num_elements); error = master_interface_ptr->set_descriptor(descriptor, num_elements);
MB_MASTER_CHECK((error == ESP_OK), MB_MASTER_CHECK((error == ESP_OK),
error, error,
"Master set descriptor failure, error=(0x%x) (%s).", "Master set descriptor failure, error=(0x%x) (%s).",
error, esp_err_to_name(error)); 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, ESP_ERR_INVALID_STATE,
"Master interface is not correctly initialized."); "Master interface is not correctly initialized.");
error = master_interface_ptr->set_parameter(cid, name, value, type); error = master_interface_ptr->set_parameter(cid, name, value, type);
MB_MASTER_CHECK((error == ESP_OK), MB_MASTER_CHECK((error == ESP_OK),
error, error,
"Master set parameter failure, error=(0x%x) (%s).", "Master set parameter failure, error=(0x%x) (%s).",
error, esp_err_to_name(error)); error, esp_err_to_name(error));
@@ -158,7 +158,7 @@ esp_err_t mbc_master_setup(void* comm_info)
ESP_ERR_INVALID_STATE, ESP_ERR_INVALID_STATE,
"Master interface is not correctly initialized."); "Master interface is not correctly initialized.");
error = master_interface_ptr->setup(comm_info); error = master_interface_ptr->setup(comm_info);
MB_MASTER_CHECK((error == ESP_OK), MB_MASTER_CHECK((error == ESP_OK),
error, error,
"Master setup failure, error=(0x%x) (%s).", "Master setup failure, error=(0x%x) (%s).",
error, esp_err_to_name(error)); error, esp_err_to_name(error));
@@ -178,7 +178,7 @@ esp_err_t mbc_master_start(void)
ESP_ERR_INVALID_STATE, ESP_ERR_INVALID_STATE,
"Master interface is not correctly initialized."); "Master interface is not correctly initialized.");
error = master_interface_ptr->start(); error = master_interface_ptr->start();
MB_MASTER_CHECK((error == ESP_OK), MB_MASTER_CHECK((error == ESP_OK),
error, error,
"Master start failure, error=(0x%x) (%s).", "Master start failure, error=(0x%x) (%s).",
error, esp_err_to_name(error)); error, esp_err_to_name(error));

View File

@@ -56,13 +56,13 @@ esp_err_t mbc_slave_destroy(void)
ESP_ERR_INVALID_STATE, ESP_ERR_INVALID_STATE,
"Slave interface is not correctly initialized."); "Slave interface is not correctly initialized.");
// Check if interface has been 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, ESP_ERR_INVALID_STATE,
"Slave interface is not correctly initialized."); "Slave interface is not correctly initialized.");
// Call the slave port destroy function // Call the slave port destroy function
error = slave_interface_ptr->destroy(); error = slave_interface_ptr->destroy();
MB_SLAVE_CHECK((error == ESP_OK), MB_SLAVE_CHECK((error == ESP_OK),
ESP_ERR_INVALID_STATE, ESP_ERR_INVALID_STATE,
"Slave destroy failure error=(0x%x).", "Slave destroy failure error=(0x%x).",
error); error);
return error; return error;
@@ -77,12 +77,12 @@ esp_err_t mbc_slave_setup(void* comm_info)
MB_SLAVE_CHECK((slave_interface_ptr != NULL), MB_SLAVE_CHECK((slave_interface_ptr != NULL),
ESP_ERR_INVALID_STATE, ESP_ERR_INVALID_STATE,
"Slave interface is not correctly initialized."); "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, ESP_ERR_INVALID_STATE,
"Slave interface is not correctly initialized."); "Slave interface is not correctly initialized.");
error = slave_interface_ptr->setup(comm_info); error = slave_interface_ptr->setup(comm_info);
MB_SLAVE_CHECK((error == ESP_OK), MB_SLAVE_CHECK((error == ESP_OK),
ESP_ERR_INVALID_STATE, ESP_ERR_INVALID_STATE,
"Slave setup failure error=(0x%x).", "Slave setup failure error=(0x%x).",
error); error);
return error; return error;
@@ -97,7 +97,7 @@ esp_err_t mbc_slave_start(void)
MB_SLAVE_CHECK((slave_interface_ptr != NULL), MB_SLAVE_CHECK((slave_interface_ptr != NULL),
ESP_ERR_INVALID_STATE, ESP_ERR_INVALID_STATE,
"Slave interface is not correctly initialized."); "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, ESP_ERR_INVALID_STATE,
"Slave interface is not correctly initialized."); "Slave interface is not correctly initialized.");
#ifdef CONFIG_FMB_CONTROLLER_SLAVE_ID_SUPPORT #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."); MB_SLAVE_CHECK((status == MB_ENOERR), ESP_ERR_INVALID_STATE, "mb stack set slave ID failure.");
#endif #endif
error = slave_interface_ptr->start(); error = slave_interface_ptr->start();
MB_SLAVE_CHECK((error == ESP_OK), MB_SLAVE_CHECK((error == ESP_OK),
ESP_ERR_INVALID_STATE, ESP_ERR_INVALID_STATE,
"Slave start failure error=(0x%x).", "Slave start failure error=(0x%x).",
error); error);
return error; return error;
} }
/** /**
* Blocking function to get event on parameter group change for application task * 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_SLAVE_CHECK((slave_interface_ptr != NULL),
MB_EVENT_NO_EVENTS, MB_EVENT_NO_EVENTS,
"Slave interface is not correctly initialized."); "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, MB_EVENT_NO_EVENTS,
"Slave interface is not correctly initialized."); "Slave interface is not correctly initialized.");
mb_event_group_t event = slave_interface_ptr->check_event(group); 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), MB_SLAVE_CHECK((slave_interface_ptr != NULL),
ESP_ERR_INVALID_STATE, ESP_ERR_INVALID_STATE,
"Slave interface is not correctly initialized."); "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, ESP_ERR_INVALID_STATE,
"Slave interface is not correctly initialized."); "Slave interface is not correctly initialized.");
error = slave_interface_ptr->get_param_info(reg_info, timeout); error = slave_interface_ptr->get_param_info(reg_info, timeout);
MB_SLAVE_CHECK((error == ESP_OK), MB_SLAVE_CHECK((error == ESP_OK),
ESP_ERR_INVALID_STATE, ESP_ERR_INVALID_STATE,
"Slave get parameter info failure error=(0x%x).", "Slave get parameter info failure error=(0x%x).",
error); error);
return 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), MB_SLAVE_CHECK((slave_interface_ptr != NULL),
ESP_ERR_INVALID_STATE, ESP_ERR_INVALID_STATE,
"Slave interface is not correctly initialized."); "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, ESP_ERR_INVALID_STATE,
"Slave interface is not correctly initialized."); "Slave interface is not correctly initialized.");
error = slave_interface_ptr->set_descriptor(descr_data); error = slave_interface_ptr->set_descriptor(descr_data);
MB_SLAVE_CHECK((error == ESP_OK), MB_SLAVE_CHECK((error == ESP_OK),
ESP_ERR_INVALID_STATE, ESP_ERR_INVALID_STATE,
"Slave set descriptor failure error=(0x%x).", "Slave set descriptor failure error=(0x%x).",
(uint16_t)error); (uint16_t)error);
return error; return error;
@@ -178,11 +178,11 @@ eMBErrorCode eMBRegDiscreteCB(UCHAR * pucRegBuffer, USHORT usAddress,
MB_SLAVE_CHECK((slave_interface_ptr != NULL), MB_SLAVE_CHECK((slave_interface_ptr != NULL),
ESP_ERR_INVALID_STATE, ESP_ERR_INVALID_STATE,
"Slave interface is not correctly initialized."); "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, error,
"Slave interface is not correctly initialized."); "Slave interface is not correctly initialized.");
error = slave_interface_ptr->slave_reg_cb_discrete(pucRegBuffer, usAddress, usNDiscrete); error = slave_interface_ptr->slave_reg_cb_discrete(pucRegBuffer, usAddress, usNDiscrete);
return error; return error;
} }
@@ -193,7 +193,7 @@ eMBErrorCode eMBRegCoilsCB(UCHAR* pucRegBuffer, USHORT usAddress,
MB_SLAVE_CHECK((slave_interface_ptr != NULL), MB_SLAVE_CHECK((slave_interface_ptr != NULL),
ESP_ERR_INVALID_STATE, ESP_ERR_INVALID_STATE,
"Slave interface is not correctly initialized."); "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, ESP_ERR_INVALID_STATE,
"Slave interface is not correctly initialized."); "Slave interface is not correctly initialized.");
error = slave_interface_ptr->slave_reg_cb_coils(pucRegBuffer, usAddress, 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), MB_SLAVE_CHECK((slave_interface_ptr != NULL),
ESP_ERR_INVALID_STATE, ESP_ERR_INVALID_STATE,
"Slave interface is not correctly initialized."); "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, ESP_ERR_INVALID_STATE,
"Slave interface is not correctly initialized."); "Slave interface is not correctly initialized.");
error = slave_interface_ptr->slave_reg_cb_holding(pucRegBuffer, usAddress, 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), MB_SLAVE_CHECK((slave_interface_ptr != NULL),
ESP_ERR_INVALID_STATE, ESP_ERR_INVALID_STATE,
"Slave interface is not correctly initialized."); "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, ESP_ERR_INVALID_STATE,
"Slave interface is not correctly initialized."); "Slave interface is not correctly initialized.");
error = slave_interface_ptr->slave_reg_cb_input(pucRegBuffer, usAddress, usNRegs); error = slave_interface_ptr->slave_reg_cb_input(pucRegBuffer, usAddress, usNRegs);

View File

@@ -41,4 +41,3 @@ esp_err_t mbc_slave_init(mb_port_type_t port_type, void** handler)
} }
return error; return error;
} }

View File

@@ -153,4 +153,3 @@ typedef esp_err_t (*iface_start)(void); /*!< Interface method start */
#endif #endif
#endif // _MB_IFACE_COMMON_H #endif // _MB_IFACE_COMMON_H

View File

@@ -1,6 +1,6 @@
COMPONENT_ADD_INCLUDEDIRS := common/include COMPONENT_ADD_INCLUDEDIRS := common/include
COMPONENT_PRIV_INCLUDEDIRS := common port modbus modbus/ascii modbus/functions COMPONENT_PRIV_INCLUDEDIRS := common port modbus modbus/ascii modbus/functions
COMPONENT_PRIV_INCLUDEDIRS += modbus/rtu modbus/tcp modbus/include COMPONENT_PRIV_INCLUDEDIRS += modbus/rtu modbus/tcp modbus/include
COMPONENT_PRIV_INCLUDEDIRS += serial_slave/port serial_slave/modbus_controller COMPONENT_PRIV_INCLUDEDIRS += serial_slave/port serial_slave/modbus_controller
COMPONENT_PRIV_INCLUDEDIRS += serial_master/port serial_master/modbus_controller COMPONENT_PRIV_INCLUDEDIRS += serial_master/port serial_master/modbus_controller
COMPONENT_PRIV_INCLUDEDIRS += tcp_slave/port tcp_slave/modbus_controller COMPONENT_PRIV_INCLUDEDIRS += tcp_slave/port tcp_slave/modbus_controller

View File

@@ -1,4 +1,4 @@
/* /*
* FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU.
* Copyright (c) 2006 Christian Walter <wolti@sil.at> * Copyright (c) 2006 Christian Walter <wolti@sil.at>
* All rights reserved. * All rights reserved.
@@ -101,7 +101,7 @@ eMBASCIIInit( UCHAR ucSlaveAddress, UCHAR ucPort, ULONG ulBaudRate, eMBParity eP
{ {
eMBErrorCode eStatus = MB_ENOERR; eMBErrorCode eStatus = MB_ENOERR;
( void )ucSlaveAddress; ( void )ucSlaveAddress;
ENTER_CRITICAL_SECTION( ); ENTER_CRITICAL_SECTION( );
ucMBLFCharacter = MB_ASCII_DEFAULT_LF; ucMBLFCharacter = MB_ASCII_DEFAULT_LF;
@@ -393,7 +393,7 @@ xMBASCIITransmitFSM( void )
return xNeedPoll; return xNeedPoll;
} }
BOOL MB_PORT_ISR_ATTR BOOL MB_PORT_ISR_ATTR
xMBASCIITimerT1SExpired( void ) xMBASCIITimerT1SExpired( void )
{ {
switch ( eRcvState ) switch ( eRcvState )

View File

@@ -1,4 +1,4 @@
/* /*
* FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU.
* Copyright (c) 2006 Christian Walter <wolti@sil.at> * Copyright (c) 2006 Christian Walter <wolti@sil.at>
* All rights reserved. * All rights reserved.

View File

@@ -1,4 +1,4 @@
/* /*
* FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU.
* Copyright (c) 2006 Christian Walter <wolti@sil.at> * Copyright (c) 2006 Christian Walter <wolti@sil.at>
* All rights reserved. * All rights reserved.
@@ -108,7 +108,7 @@ eMBErrorCode
eMBMasterASCIIInit( UCHAR ucPort, ULONG ulBaudRate, eMBParity eParity ) eMBMasterASCIIInit( UCHAR ucPort, ULONG ulBaudRate, eMBParity eParity )
{ {
eMBErrorCode eStatus = MB_ENOERR; eMBErrorCode eStatus = MB_ENOERR;
ENTER_CRITICAL_SECTION( ); ENTER_CRITICAL_SECTION( );
ucMBLFCharacter = MB_ASCII_DEFAULT_LF; ucMBLFCharacter = MB_ASCII_DEFAULT_LF;
@@ -237,14 +237,14 @@ xMBMasterASCIIReceiveFSM( void )
case STATE_M_RX_INIT: case STATE_M_RX_INIT:
vMBMasterPortTimersT35Enable( ); vMBMasterPortTimersT35Enable( );
break; break;
/* In the error state we wait until all characters in the /* In the error state we wait until all characters in the
* damaged frame are transmitted. * damaged frame are transmitted.
*/ */
case STATE_M_RX_ERROR: case STATE_M_RX_ERROR:
vMBMasterPortTimersRespondTimeoutEnable( ); vMBMasterPortTimersRespondTimeoutEnable( );
break; break;
/* In the idle state we wait for a new character. If a character /* 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 * is received the t1.5 and t3.5 timers are started and the
* receiver is in the state STATE_RX_RECEIVE and disable early * 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 */ /* Waiting for the start of frame character during respond timeout */
vMBMasterPortTimersRespondTimeoutEnable( ); vMBMasterPortTimersRespondTimeoutEnable( );
if( ucByte == ':' ) if( ucByte == ':' )
{ {
/* Reset the input buffers to store the frame in receive state. */ /* Reset the input buffers to store the frame in receive state. */
usMasterRcvBufferPos = 0; usMasterRcvBufferPos = 0;
eBytePos = BYTE_HIGH_NIBBLE; eBytePos = BYTE_HIGH_NIBBLE;
@@ -358,19 +358,19 @@ xMBMasterASCIITransmitFSM( void )
BOOL xFrameIsBroadcast = FALSE; BOOL xFrameIsBroadcast = FALSE;
assert( eRcvState == STATE_M_RX_IDLE ); assert( eRcvState == STATE_M_RX_IDLE );
switch ( eSndState ) switch ( eSndState )
{ {
/* We should not get a transmitter event if the transmitter is in /* We should not get a transmitter event if the transmitter is in
* idle state. */ * idle state. */
case STATE_M_TX_XFWR: case STATE_M_TX_XFWR:
break; break;
/* We should not get a transmitter event if the transmitter is in /* We should not get a transmitter event if the transmitter is in
* idle state. */ * idle state. */
case STATE_M_TX_IDLE: case STATE_M_TX_IDLE:
break; break;
/* Start of transmission. The start of a frame is defined by sending /* Start of transmission. The start of a frame is defined by sending
* the character ':'. */ * the character ':'. */
case STATE_M_TX_START: case STATE_M_TX_START:
@@ -446,22 +446,22 @@ BOOL
xMBMasterASCIITimerT1SExpired( void ) xMBMasterASCIITimerT1SExpired( void )
{ {
BOOL xNeedPoll = FALSE; BOOL xNeedPoll = FALSE;
switch ( eRcvState ) switch ( eRcvState )
{ {
/* Timer t35 expired. Startup phase is finished. */ /* Timer t35 expired. Startup phase is finished. */
case STATE_M_RX_INIT: case STATE_M_RX_INIT:
xNeedPoll = xMBMasterPortEventPost(EV_MASTER_READY); xNeedPoll = xMBMasterPortEventPost(EV_MASTER_READY);
ESP_EARLY_LOGI("xMBMasterASCIITimerT1SExpired", "RX_INIT_EXPIRED"); ESP_EARLY_LOGI("xMBMasterASCIITimerT1SExpired", "RX_INIT_EXPIRED");
break; break;
/* Start of message is not received during respond timeout. /* Start of message is not received during respond timeout.
* Process error. */ * Process error. */
case STATE_M_RX_IDLE: case STATE_M_RX_IDLE:
eRcvState = STATE_M_RX_ERROR; eRcvState = STATE_M_RX_ERROR;
break; 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 */ * Wait for respond time and go to error state to inform listener about error */
case STATE_M_RX_RCV: case STATE_M_RX_RCV:
eRcvState = STATE_M_RX_ERROR; eRcvState = STATE_M_RX_ERROR;
@@ -472,7 +472,7 @@ xMBMasterASCIITimerT1SExpired( void )
vMBMasterSetErrorType(EV_ERROR_RECEIVE_DATA); vMBMasterSetErrorType(EV_ERROR_RECEIVE_DATA);
xNeedPoll = xMBMasterPortEventPost( EV_MASTER_ERROR_PROCESS ); xNeedPoll = xMBMasterPortEventPost( EV_MASTER_ERROR_PROCESS );
break; break;
/* If we have a timeout we go back to the idle state and wait for /* If we have a timeout we go back to the idle state and wait for
* the next frame. * the next frame.
*/ */
@@ -485,7 +485,7 @@ xMBMasterASCIITimerT1SExpired( void )
break; break;
} }
eRcvState = STATE_M_RX_IDLE; eRcvState = STATE_M_RX_IDLE;
switch (eSndState) switch (eSndState)
{ {
/* A frame was send finish and convert delay or respond timeout expired. /* A frame was send finish and convert delay or respond timeout expired.
@@ -497,11 +497,11 @@ xMBMasterASCIITimerT1SExpired( void )
xNeedPoll = xMBMasterPortEventPost(EV_MASTER_ERROR_PROCESS); xNeedPoll = xMBMasterPortEventPost(EV_MASTER_ERROR_PROCESS);
} }
break; break;
/* Function called in an illegal state. */ /* Function called in an illegal state. */
default: default:
assert( ( eSndState == STATE_M_TX_START ) || ( eSndState == STATE_M_TX_IDLE ) 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 ) ); || ( eSndState == STATE_M_TX_NOTIFY ) );
break; break;
} }
@@ -512,9 +512,9 @@ xMBMasterASCIITimerT1SExpired( void )
if (xMBMasterGetCurTimerMode() == MB_TMODE_CONVERT_DELAY) { if (xMBMasterGetCurTimerMode() == MB_TMODE_CONVERT_DELAY) {
xNeedPoll = xMBMasterPortEventPost( EV_MASTER_EXECUTE ); xNeedPoll = xMBMasterPortEventPost( EV_MASTER_EXECUTE );
} }
vMBMasterPortTimersDisable( ); vMBMasterPortTimersDisable( );
/* no context switch required. */ /* no context switch required. */
return xNeedPoll; return xNeedPoll;
} }

View File

@@ -1,4 +1,4 @@
/* /*
* FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU.
* Copyright (c) 2006 Christian Walter <wolti@sil.at> * Copyright (c) 2006 Christian Walter <wolti@sil.at>
* All rights reserved. * All rights reserved.
@@ -87,7 +87,7 @@ eMBFuncReadCoils( UCHAR * pucFrame, USHORT * usLen )
usCoilCount |= ( USHORT )( pucFrame[MB_PDU_FUNC_READ_COILCNT_OFF + 1] ); usCoilCount |= ( USHORT )( pucFrame[MB_PDU_FUNC_READ_COILCNT_OFF + 1] );
/* Check if the number of registers to read is valid. If not /* 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 ) && if( ( usCoilCount >= 1 ) &&
( usCoilCount < MB_PDU_FUNC_READ_COILCNT_MAX ) ) ( usCoilCount < MB_PDU_FUNC_READ_COILCNT_MAX ) )
@@ -125,7 +125,7 @@ eMBFuncReadCoils( UCHAR * pucFrame, USHORT * usLen )
else else
{ {
/* The response contains the function code, the starting address /* 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. */ * buffer because they are still valid. */
*usLen += ucNBytes;; *usLen += ucNBytes;;
} }
@@ -247,7 +247,7 @@ eMBFuncWriteMultipleCoils( UCHAR * pucFrame, USHORT * usLen )
else else
{ {
/* The response contains the function code, the starting address /* 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. */ * buffer because they are still valid. */
*usLen = MB_PDU_FUNC_WRITE_MUL_BYTECNT_OFF; *usLen = MB_PDU_FUNC_WRITE_MUL_BYTECNT_OFF;
} }

View File

@@ -1,4 +1,4 @@
/* /*
* FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU.
* Copyright (C) 2013 Armink <armink.ztl@gmail.com> * Copyright (C) 2013 Armink <armink.ztl@gmail.com>
* All rights reserved. * All rights reserved.
@@ -148,7 +148,7 @@ eMBMasterFuncReadCoils( UCHAR * pucFrame, USHORT * usLen )
} }
/* Check if the number of registers to read is valid. If not /* 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 ) && if( ( usCoilCount >= 1 ) &&
( ucByteCount == pucFrame[MB_PDU_FUNC_READ_COILCNT_OFF] ) ) ( ucByteCount == pucFrame[MB_PDU_FUNC_READ_COILCNT_OFF] ) )

View File

@@ -1,4 +1,4 @@
/* /*
* FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU.
* Copyright (c) 2006 Christian Walter <wolti@sil.at> * Copyright (c) 2006 Christian Walter <wolti@sil.at>
* All rights reserved. * All rights reserved.

View File

@@ -65,7 +65,7 @@ eMBFuncReadDiscreteInputs( UCHAR * pucFrame, USHORT * usLen )
usDiscreteCnt |= ( USHORT )( pucFrame[MB_PDU_FUNC_READ_DISCCNT_OFF + 1] ); usDiscreteCnt |= ( USHORT )( pucFrame[MB_PDU_FUNC_READ_DISCCNT_OFF + 1] );
/* Check if the number of registers to read is valid. If not /* 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 ) && if( ( usDiscreteCnt >= 1 ) &&
( usDiscreteCnt < MB_PDU_FUNC_READ_DISCCNT_MAX ) ) ( usDiscreteCnt < MB_PDU_FUNC_READ_DISCCNT_MAX ) )
@@ -102,7 +102,7 @@ eMBFuncReadDiscreteInputs( UCHAR * pucFrame, USHORT * usLen )
else else
{ {
/* The response contains the function code, the starting address /* 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. */ * buffer because they are still valid. */
*usLen += ucNBytes;; *usLen += ucNBytes;;
} }

View File

@@ -131,7 +131,7 @@ eMBMasterFuncReadDiscreteInputs( UCHAR * pucFrame, USHORT * usLen )
} }
/* Check if the number of registers to read is valid. If not /* 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]) if ((usDiscreteCnt >= 1) && ucNBytes == pucFrame[MB_PDU_FUNC_READ_DISCCNT_OFF])
{ {

View File

@@ -1,4 +1,4 @@
/* /*
* FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU.
* Copyright (c) 2006 Christian Walter <wolti@sil.at> * Copyright (c) 2006 Christian Walter <wolti@sil.at>
* All rights reserved. * All rights reserved.
@@ -187,7 +187,7 @@ eMBFuncReadHoldingRegister( UCHAR * pucFrame, USHORT * usLen )
usRegCount = ( USHORT )( pucFrame[MB_PDU_FUNC_READ_REGCNT_OFF + 1] ); usRegCount = ( USHORT )( pucFrame[MB_PDU_FUNC_READ_REGCNT_OFF + 1] );
/* Check if the number of registers to read is valid. If not /* 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 ) ) if( ( usRegCount >= 1 ) && ( usRegCount <= MB_PDU_FUNC_READ_REGCNT_MAX ) )
{ {

View File

@@ -1,4 +1,4 @@
/* /*
* FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU.
* Copyright (C) 2013 Armink <armink.ztl@gmail.com> * Copyright (C) 2013 Armink <armink.ztl@gmail.com>
* All rights reserved. * All rights reserved.
@@ -452,4 +452,3 @@ eMBMasterFuncReadWriteMultipleHoldingRegister( UCHAR * pucFrame, USHORT * usLen
#endif #endif
#endif // #if MB_MASTER_RTU_ENABLED || MB_MASTER_ASCII_ENABLED || MB_MASTER_TCP_ENABLED #endif // #if MB_MASTER_RTU_ENABLED || MB_MASTER_ASCII_ENABLED || MB_MASTER_TCP_ENABLED

View File

@@ -1,4 +1,4 @@
/* /*
* FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU.
* Copyright (c) 2006 Christian Walter <wolti@sil.at> * Copyright (c) 2006 Christian Walter <wolti@sil.at>
* All rights reserved. * All rights reserved.
@@ -77,7 +77,7 @@ eMBFuncReadInputRegister( UCHAR * pucFrame, USHORT * usLen )
usRegCount |= ( USHORT )( pucFrame[MB_PDU_FUNC_READ_REGCNT_OFF + 1] ); usRegCount |= ( USHORT )( pucFrame[MB_PDU_FUNC_READ_REGCNT_OFF + 1] );
/* Check if the number of registers to read is valid. If not /* 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 ) if( ( usRegCount >= 1 )
&& ( usRegCount < MB_PDU_FUNC_READ_REGCNT_MAX ) ) && ( usRegCount < MB_PDU_FUNC_READ_REGCNT_MAX ) )

View File

@@ -1,4 +1,4 @@
/* /*
* FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU.
* Copyright (C) 2013 Armink <armink.ztl@gmail.com> * Copyright (C) 2013 Armink <armink.ztl@gmail.com>
* All rights reserved. * All rights reserved.

View File

@@ -1,4 +1,4 @@
/* /*
* FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU.
* Copyright (c) 2006 Christian Walter <wolti@sil.at> * Copyright (c) 2006 Christian Walter <wolti@sil.at>
* All rights reserved. * All rights reserved.

View File

@@ -1,4 +1,4 @@
/* /*
* FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU.
* Copyright (c) 2006 Christian Walter <wolti@sil.at> * Copyright (c) 2006 Christian Walter <wolti@sil.at>
* All rights reserved. * All rights reserved.

View File

@@ -1,4 +1,4 @@
/* /*
* FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU.
* Copyright (c) 2006 Christian Walter <wolti@sil.at> * Copyright (c) 2006 Christian Walter <wolti@sil.at>
* All rights reserved. * All rights reserved.
@@ -98,7 +98,7 @@ typedef enum
* registers should be updated and reading means that the modbus protocol * registers should be updated and reading means that the modbus protocol
* stack needs to know the current register values. * stack needs to know the current register values.
* *
* \see eMBRegHoldingCB( ), eMBRegCoilsCB( ), eMBRegDiscreteCB( ) and * \see eMBRegHoldingCB( ), eMBRegCoilsCB( ), eMBRegDiscreteCB( ) and
* eMBRegInputCB( ). * eMBRegInputCB( ).
*/ */
typedef enum typedef enum
@@ -142,7 +142,7 @@ typedef enum
* *
* \return If no error occurs the function returns eMBErrorCode::MB_ENOERR. * \return If no error occurs the function returns eMBErrorCode::MB_ENOERR.
* The protocol is then in the disabled state and ready for activation * 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: * is returned:
* - eMBErrorCode::MB_EINVAL If the slave address was not valid. Valid * - eMBErrorCode::MB_EINVAL If the slave address was not valid. Valid
* slave addresses are in the range 1 - 247. * slave addresses are in the range 1 - 247.
@@ -171,10 +171,10 @@ eMBErrorCode eMBTCPInit( USHORT usTCPPort );
* \brief Release resources used by the protocol stack. * \brief Release resources used by the protocol stack.
* *
* This function disables the Modbus protocol stack and release all * This function disables the Modbus protocol stack and release all
* hardware resources. It must only be called when the protocol stack * hardware resources. It must only be called when the protocol stack
* is disabled. * 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. * get an callback must define the macro MB_PORT_HAS_CLOSE to 1.
* *
* \return If the resources where released it return eMBErrorCode::MB_ENOERR. * \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 * This function enables processing of Modbus frames. Enabling the protocol
* stack is only possible if it is in the disabled state. * stack is only possible if it is in the disabled state.
* *
* \return If the protocol stack is now in the state enabled it returns * \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 * eMBErrorCode::MB_ENOERR. If it was not in the disabled state it
* return eMBErrorCode::MB_EILLSTATE. * return eMBErrorCode::MB_EILLSTATE.
*/ */
eMBErrorCode eMBEnable( void ); eMBErrorCode eMBEnable( void );
@@ -200,7 +200,7 @@ eMBErrorCode eMBEnable( void );
* *
* This function disables processing of Modbus frames. * 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_ENOERR. If it was not in the enabled state it returns
* eMBErrorCode::MB_EILLSTATE. * eMBErrorCode::MB_EILLSTATE.
*/ */
@@ -212,10 +212,10 @@ eMBErrorCode eMBDisable( void );
* This function must be called periodically. The timer interval required * This function must be called periodically. The timer interval required
* is given by the application dependent Modbus slave timeout. Internally the * is given by the application dependent Modbus slave timeout. Internally the
* function calls xMBPortEventGet() and waits for an event from the receiver or * 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 * \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::MB_ENOERR.
*/ */
eMBErrorCode eMBPoll( void ); 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 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 * 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 * 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 * \param ucFunctionCode The Modbus function code for which this handler should
* be registers. Valid function codes are in the range 1 to 127. * 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 * case the values in mbconfig.h should be adjusted. If the argument was not
* valid it returns eMBErrorCode::MB_EINVAL. * valid it returns eMBErrorCode::MB_EINVAL.
*/ */
eMBErrorCode eMBRegisterCB( UCHAR ucFunctionCode, eMBErrorCode eMBRegisterCB( UCHAR ucFunctionCode,
pxMBFunctionHandler pxHandler ); pxMBFunctionHandler pxHandler );
/* ----------------------- Callback -----------------------------------------*/ /* ----------------------- Callback -----------------------------------------*/
@@ -300,7 +300,7 @@ eMBErrorCode eMBRegisterCB( UCHAR ucFunctionCode,
* - eMBErrorCode::MB_ENOERR If no error occurred. In this case a normal * - eMBErrorCode::MB_ENOERR If no error occurred. In this case a normal
* Modbus response is sent. * Modbus response is sent.
* - eMBErrorCode::MB_ENOREG If the application can not supply values * - 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
* <b>ILLEGAL DATA ADDRESS</b> exception frame is sent as a response. * <b>ILLEGAL DATA ADDRESS</b> exception frame is sent as a response.
* - eMBErrorCode::MB_ETIMEDOUT If the requested register block is * - eMBErrorCode::MB_ETIMEDOUT If the requested register block is
* currently not available and the application dependent response * currently not available and the application dependent response
@@ -324,18 +324,18 @@ eMBErrorCode eMBRegInputCB( UCHAR * pucRegBuffer, USHORT usAddress,
* this buffer. * this buffer.
* \param usAddress The starting address of the register. * \param usAddress The starting address of the register.
* \param usNRegs Number of registers to read or write. * \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 * 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
* <b>WRITE SINGLE REGISTER</b> command. * <b>WRITE SINGLE REGISTER</b> 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. * the current values into the buffer \c pucRegBuffer.
* *
* \return The function must return one of the following error codes: * \return The function must return one of the following error codes:
* - eMBErrorCode::MB_ENOERR If no error occurred. In this case a normal * - eMBErrorCode::MB_ENOERR If no error occurred. In this case a normal
* Modbus response is sent. * Modbus response is sent.
* - eMBErrorCode::MB_ENOREG If the application can not supply values * - 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
* <b>ILLEGAL DATA ADDRESS</b> exception frame is sent as a response. * <b>ILLEGAL DATA ADDRESS</b> exception frame is sent as a response.
* - eMBErrorCode::MB_ETIMEDOUT If the requested register block is * - eMBErrorCode::MB_ETIMEDOUT If the requested register block is
* currently not available and the application dependent response * 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 * - eMBErrorCode::MB_ENOERR If no error occurred. In this case a normal
* Modbus response is sent. * Modbus response is sent.
* - eMBErrorCode::MB_ENOREG If the application does not map an coils * - 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
* <b>ILLEGAL DATA ADDRESS</b> is sent as a response. * <b>ILLEGAL DATA ADDRESS</b> is sent as a response.
* - eMBErrorCode::MB_ETIMEDOUT If the requested register block is * - eMBErrorCode::MB_ETIMEDOUT If the requested register block is
* currently not available and the application dependent response * 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 * - eMBErrorCode::MB_ENOERR If no error occurred. In this case a normal
* Modbus response is sent. * Modbus response is sent.
* - eMBErrorCode::MB_ENOREG If no such discrete inputs exists. * - eMBErrorCode::MB_ENOREG If no such discrete inputs exists.
* In this case a <b>ILLEGAL DATA ADDRESS</b> exception frame is sent * In this case a <b>ILLEGAL DATA ADDRESS</b> exception frame is sent
* as a response. * as a response.
* - eMBErrorCode::MB_ETIMEDOUT If the requested register block is * - eMBErrorCode::MB_ETIMEDOUT If the requested register block is
* currently not available and the application dependent response * currently not available and the application dependent response

View File

@@ -1,4 +1,4 @@
/* /*
* FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU.
* Copyright (C) 2013 Armink <armink.ztl@gmail.com> * Copyright (C) 2013 Armink <armink.ztl@gmail.com>
* All rights reserved. * All rights reserved.
@@ -143,10 +143,10 @@ eMBErrorCode eMBMasterTCPInit( USHORT usTCPPort );
* \brief Release resources used by the protocol stack. * \brief Release resources used by the protocol stack.
* *
* This function disables the Modbus Master protocol stack and release all * This function disables the Modbus Master protocol stack and release all
* hardware resources. It must only be called when the protocol stack * hardware resources. It must only be called when the protocol stack
* is disabled. * 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. * get an callback must define the macro MB_PORT_HAS_CLOSE to 1.
* *
* \return If the resources where released it return eMBErrorCode::MB_ENOERR. * \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 * This function enables processing of Modbus Master frames. Enabling the protocol
* stack is only possible if it is in the disabled state. * stack is only possible if it is in the disabled state.
* *
* \return If the protocol stack is now in the state enabled it returns * \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 * eMBErrorCode::MB_ENOERR. If it was not in the disabled state it
* return eMBErrorCode::MB_EILLSTATE. * return eMBErrorCode::MB_EILLSTATE.
*/ */
eMBErrorCode eMBMasterEnable( void ); eMBErrorCode eMBMasterEnable( void );
@@ -172,7 +172,7 @@ eMBErrorCode eMBMasterEnable( void );
* *
* This function disables processing of Modbus frames. * 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_ENOERR. If it was not in the enabled state it returns
* eMBErrorCode::MB_EILLSTATE. * eMBErrorCode::MB_EILLSTATE.
*/ */
@@ -184,10 +184,10 @@ eMBErrorCode eMBMasterDisable( void );
* This function must be called periodically. The timer interval required * This function must be called periodically. The timer interval required
* is given by the application dependent Modbus slave timeout. Internally the * is given by the application dependent Modbus slave timeout. Internally the
* function calls xMBMasterPortEventGet() and waits for an event from the receiver or * 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 * \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::MB_ENOERR.
*/ */
eMBErrorCode eMBMasterPoll( void ); eMBErrorCode eMBMasterPoll( void );

View File

@@ -1,4 +1,4 @@
/* /*
* FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU.
* Copyright (c) 2006 Christian Walter <wolti@sil.at> * Copyright (c) 2006 Christian Walter <wolti@sil.at>
* All rights reserved. * All rights reserved.
@@ -90,7 +90,7 @@ PR_BEGIN_EXTERN_C
* MB_ASCII_TIMEOUT_WAIT_BEFORE_SEND_MS to allow for a delay before * MB_ASCII_TIMEOUT_WAIT_BEFORE_SEND_MS to allow for a delay before
* the serial transmitter is enabled. This is required because some * the serial transmitter is enabled. This is required because some
* targets are so fast that there is no time between receiving and * 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. * receiver then he will not receive the response correctly.
*/ */
#ifndef MB_ASCII_TIMEOUT_WAIT_BEFORE_SEND_MS #ifndef MB_ASCII_TIMEOUT_WAIT_BEFORE_SEND_MS

View File

@@ -1,4 +1,4 @@
/* /*
* FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU.
* Copyright (c) 2006 Christian Walter <wolti@sil.at> * Copyright (c) 2006 Christian Walter <wolti@sil.at>
* All rights reserved. * All rights reserved.

View File

@@ -1,4 +1,4 @@
/* /*
* FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU.
* Copyright (c) 2006 Christian Walter <wolti@sil.at> * Copyright (c) 2006 Christian Walter <wolti@sil.at>
* All rights reserved. * All rights reserved.

View File

@@ -1,4 +1,4 @@
/* /*
* FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU.
* Copyright (c) 2006 Christian Walter <wolti@sil.at> * Copyright (c) 2006 Christian Walter <wolti@sil.at>
* All rights reserved. * All rights reserved.

View File

@@ -1,4 +1,4 @@
/* /*
* FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU.
* Copyright (c) 2006 Christian Walter <wolti@sil.at> * Copyright (c) 2006 Christian Walter <wolti@sil.at>
* All rights reserved. * All rights reserved.

View File

@@ -1,4 +1,4 @@
/* /*
* FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU.
* Copyright (c) 2006 Christian Walter <wolti@sil.at> * Copyright (c) 2006 Christian Walter <wolti@sil.at>
* All rights reserved. * All rights reserved.

View File

@@ -1,4 +1,4 @@
/* /*
* FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU.
* Copyright (c) 2006 Christian Walter <wolti@sil.at> * Copyright (c) 2006 Christian Walter <wolti@sil.at>
* All rights reserved. * All rights reserved.
@@ -407,11 +407,11 @@ eMBPoll( void )
if( ( eMBCurrentMode == MB_ASCII ) && MB_ASCII_TIMEOUT_WAIT_BEFORE_SEND_MS ) if( ( eMBCurrentMode == MB_ASCII ) && MB_ASCII_TIMEOUT_WAIT_BEFORE_SEND_MS )
{ {
vMBPortTimersDelay( MB_ASCII_TIMEOUT_WAIT_BEFORE_SEND_MS ); vMBPortTimersDelay( MB_ASCII_TIMEOUT_WAIT_BEFORE_SEND_MS );
} }
eStatus = peMBFrameSendCur( ucMBAddress, ucMBFrame, usLength ); eStatus = peMBFrameSendCur( ucMBAddress, ucMBFrame, usLength );
} }
break; break;
case EV_FRAME_TRANSMIT: case EV_FRAME_TRANSMIT:
ESP_LOGD(MB_PORT_TAG, "%s:EV_FRAME_TRANSMIT", __func__); ESP_LOGD(MB_PORT_TAG, "%s:EV_FRAME_TRANSMIT", __func__);
break; break;

View File

@@ -1,4 +1,4 @@
/* /*
* FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU.
* Copyright (C) 2013 Armink <armink.ztl@gmail.com> * Copyright (C) 2013 Armink <armink.ztl@gmail.com>
* All rights reserved. * All rights reserved.
@@ -348,7 +348,7 @@ eMBMasterPoll( void )
eStatus = peMBMasterFrameReceiveCur( &ucRcvAddress, &ucMBFrame, &usLength); eStatus = peMBMasterFrameReceiveCur( &ucRcvAddress, &ucMBFrame, &usLength);
// Check if the frame is for us. If not ,send an error process event. // 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 ) ) ) || ( ucRcvAddress == MB_TCP_PSEUDO_ADDRESS ) ) )
{ {
( void ) xMBMasterPortEventPost( EV_MASTER_EXECUTE ); ( void ) xMBMasterPortEventPost( EV_MASTER_EXECUTE );

View File

@@ -1,4 +1,4 @@
/* /*
* FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU.
* Copyright (c) 2006 Christian Walter <wolti@sil.at> * Copyright (c) 2006 Christian Walter <wolti@sil.at>
* All rights reserved. * 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, 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,
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, 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, 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, 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, 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, 0x00, 0xC1, 0x81, 0x40,
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, 0x00, 0xC1, 0x81, 0x40, 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, 0x14, 0xD4, 0xD5, 0x15, 0xD7, 0x17, 0x16, 0xD6, 0xD2, 0x12, 0x13, 0xD3,
0x11, 0xD1, 0xD0, 0x10, 0xF0, 0x30, 0x31, 0xF1, 0x33, 0xF3, 0xF2, 0x32, 0x11, 0xD1, 0xD0, 0x10, 0xF0, 0x30, 0x31, 0xF1, 0x33, 0xF3, 0xF2, 0x32,
0x36, 0xF6, 0xF7, 0x37, 0xF5, 0x35, 0x34, 0xF4, 0x3C, 0xFC, 0xFD, 0x3D, 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, 0x28, 0xE8, 0xE9, 0x29, 0xEB, 0x2B, 0x2A, 0xEA, 0xEE, 0x2E, 0x2F, 0xEF,
0x2D, 0xED, 0xEC, 0x2C, 0xE4, 0x24, 0x25, 0xE5, 0x27, 0xE7, 0xE6, 0x26, 0x2D, 0xED, 0xEC, 0x2C, 0xE4, 0x24, 0x25, 0xE5, 0x27, 0xE7, 0xE6, 0x26,
0x22, 0xE2, 0xE3, 0x23, 0xE1, 0x21, 0x20, 0xE0, 0xA0, 0x60, 0x61, 0xA1, 0x22, 0xE2, 0xE3, 0x23, 0xE1, 0x21, 0x20, 0xE0, 0xA0, 0x60, 0x61, 0xA1,
0x63, 0xA3, 0xA2, 0x62, 0x66, 0xA6, 0xA7, 0x67, 0xA5, 0x65, 0x64, 0xA4, 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, 0x69, 0xA9, 0xA8, 0x68, 0x78, 0xB8, 0xB9, 0x79, 0xBB, 0x7B, 0x7A, 0xBA,
0xBE, 0x7E, 0x7F, 0xBF, 0x7D, 0xBD, 0xBC, 0x7C, 0xB4, 0x74, 0x75, 0xB5, 0xBE, 0x7E, 0x7F, 0xBF, 0x7D, 0xBD, 0xBC, 0x7C, 0xB4, 0x74, 0x75, 0xB5,
0x77, 0xB7, 0xB6, 0x76, 0x72, 0xB2, 0xB3, 0x73, 0xB1, 0x71, 0x70, 0xB0, 0x77, 0xB7, 0xB6, 0x76, 0x72, 0xB2, 0xB3, 0x73, 0xB1, 0x71, 0x70, 0xB0,

View File

@@ -1,4 +1,4 @@
/* /*
* FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU.
* Copyright (c) 2006 Christian Walter <wolti@sil.at> * Copyright (c) 2006 Christian Walter <wolti@sil.at>
* All rights reserved. * All rights reserved.

View File

@@ -1,4 +1,4 @@
/* /*
* FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU.
* Copyright (c) 2006 Christian Walter <wolti@sil.at> * Copyright (c) 2006 Christian Walter <wolti@sil.at>
* All rights reserved. * All rights reserved.

View File

@@ -1,4 +1,4 @@
/* /*
* FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU.
* Copyright (c) 2006 Christian Walter <wolti@sil.at> * Copyright (c) 2006 Christian Walter <wolti@sil.at>
* All rights reserved. * All rights reserved.

View File

@@ -1,4 +1,4 @@
/* /*
* FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU.
* Copyright (c) 2013 China Beijing Armink <armink.ztl@gmail.com> * Copyright (c) 2013 China Beijing Armink <armink.ztl@gmail.com>
* All rights reserved. * All rights reserved.
@@ -355,7 +355,7 @@ xMBMasterRTUTimerExpired(void)
case STATE_M_RX_INIT: case STATE_M_RX_INIT:
xNeedPoll = xMBMasterPortEventPost(EV_MASTER_READY); xNeedPoll = xMBMasterPortEventPost(EV_MASTER_READY);
break; break;
/* A frame was received and t35 expired. Notify the listener that /* A frame was received and t35 expired. Notify the listener that
* a new frame was received. */ * a new frame was received. */
case STATE_M_RX_RCV: case STATE_M_RX_RCV:
@@ -404,5 +404,3 @@ xMBMasterRTUTimerExpired(void)
#endif #endif

View File

@@ -1,4 +1,4 @@
/* /*
* FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU.
* Copyright (c) 2006 Christian Walter <wolti@sil.at> * Copyright (c) 2006 Christian Walter <wolti@sil.at>
* All rights reserved. * All rights reserved.
@@ -54,10 +54,10 @@
* +-----------+---------------+------------------------------------------+ * +-----------+---------------+------------------------------------------+
* | TID | PID | Length | UID |Code | Data | * | 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) * (3) ... MB_TCP_PID = 2 (Protocol Identifier - 2 Byte)
* (4) ... MB_TCP_LEN = 4 (Number of bytes - 2 Byte) * (4) ... MB_TCP_LEN = 4 (Number of bytes - 2 Byte)
* (5) ... MB_TCP_UID = 6 (Unit Identifier - 1 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; USHORT usTCPLength = usLength + MB_TCP_FUNC;
/* The MBAP header is already initialized because the caller calls this /* The MBAP header is already initialized because the caller calls this
* function with the buffer returned by the previous call. Therefore we * function with the buffer returned by the previous call. Therefore we
* only have to update the length in the header. Note that the length * 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 * header includes the size of the Modbus PDU and the UID Byte. Therefore
* the length is usLength plus one. * the length is usLength plus one.
*/ */
pucMBTCPFrame[MB_TCP_LEN] = ( usLength + 1 ) >> 8U; pucMBTCPFrame[MB_TCP_LEN] = ( usLength + 1 ) >> 8U;

View File

@@ -1,4 +1,4 @@
/* /*
* FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU.
* Copyright (c) 2006 Christian Walter <wolti@sil.at> * Copyright (c) 2006 Christian Walter <wolti@sil.at>
* All rights reserved. * All rights reserved.

View File

@@ -1,4 +1,4 @@
/* /*
* FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU.
* Copyright (c) 2006 Christian Walter <wolti@sil.at> * Copyright (c) 2006 Christian Walter <wolti@sil.at>
* All rights reserved. * All rights reserved.
@@ -54,10 +54,10 @@
* +-----------+---------------+------------------------------------------+ * +-----------+---------------+------------------------------------------+
* | TID | PID | Length | UID |Code | Data | * | 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) * (3) ... MB_TCP_PID = 2 (Protocol Identifier - 2 Byte)
* (4) ... MB_TCP_LEN = 4 (Number of bytes - 2 Byte) * (4) ... MB_TCP_LEN = 4 (Number of bytes - 2 Byte)
* (5) ... MB_TCP_UID = 6 (Unit Identifier - 1 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; USHORT usTCPLength = usLength + MB_TCP_FUNC;
/* The MBAP header is already initialized because the caller calls this /* The MBAP header is already initialized because the caller calls this
* function with the buffer returned by the previous call. Therefore we * function with the buffer returned by the previous call. Therefore we
* only have to update the length in the header. Note that the length * 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 * header includes the size of the Modbus PDU and the UID Byte. Therefore
* the length is usLength plus one. * the length is usLength plus one.
*/ */
pucMBTCPFrame[MB_TCP_LEN] = ( usLength + 1 ) >> 8U; pucMBTCPFrame[MB_TCP_LEN] = ( usLength + 1 ) >> 8U;

View File

@@ -1,4 +1,4 @@
/* /*
* FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU. * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU.
* Copyright (c) 2006 Christian Walter <wolti@sil.at> * Copyright (c) 2006 Christian Walter <wolti@sil.at>
* All rights reserved. * All rights reserved.

View File

@@ -27,7 +27,7 @@
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products * 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission. * derived from this software without specific prior written permission.
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* IF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
@@ -87,7 +87,7 @@ xMBPortEventPost( eMBEventType eEvent )
{ {
BaseType_t xStatus, xHigherPriorityTaskWoken = pdFALSE; BaseType_t xStatus, xHigherPriorityTaskWoken = pdFALSE;
assert(xQueueHdl != NULL); assert(xQueueHdl != NULL);
if( (BOOL)xPortInIsrContext() == TRUE ) if( (BOOL)xPortInIsrContext() == TRUE )
{ {
xStatus = xQueueSendFromISR(xQueueHdl, (const void*)&eEvent, &xHigherPriorityTaskWoken); xStatus = xQueueSendFromISR(xQueueHdl, (const void*)&eEvent, &xHigherPriorityTaskWoken);
@@ -129,4 +129,3 @@ xMBPortEventGetHandle(void)
} }
return NULL; return NULL;
} }

View File

@@ -204,7 +204,7 @@ void vMBMasterRunResRelease( void )
* @param ucPDULength PDU buffer length * @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); BOOL ret = xMBMasterPortEventPost(EV_MASTER_ERROR_RESPOND_TIMEOUT);
MB_PORT_CHECK((ret == TRUE), ; , "%s: Post event 'EV_MASTER_ERROR_RESPOND_TIMEOUT' failed!", __func__); 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 pucPDUData PDU buffer data
* @param ucPDULength PDU buffer length * @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); BOOL ret = xMBMasterPortEventPost(EV_MASTER_ERROR_RECEIVE_DATA);
MB_PORT_CHECK((ret == TRUE), ; , "%s: Post event 'EV_MASTER_ERROR_RECEIVE_DATA' failed!", __func__); 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 * @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); BOOL ret = xMBMasterPortEventPost(EV_MASTER_ERROR_EXECUTE_FUNCTION);
MB_PORT_CHECK((ret == TRUE), ; , "%s: Post event 'EV_MASTER_ERROR_EXECUTE_FUNCTION' failed!", __func__); MB_PORT_CHECK((ret == TRUE), ; , "%s: Post event 'EV_MASTER_ERROR_EXECUTE_FUNCTION' failed!", __func__);

View File

@@ -16,7 +16,7 @@
* FreeModbus Libary: ESP32 Demo Application * FreeModbus Libary: ESP32 Demo Application
* Copyright (C) 2010 Christian Walter <cwalter@embedded-solutions.at> * Copyright (C) 2010 Christian Walter <cwalter@embedded-solutions.at>
* *
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
* are met: * are met:
@@ -27,7 +27,7 @@
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products * 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission. * derived from this software without specific prior written permission.
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* IF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.

View File

@@ -68,4 +68,3 @@ vMBMasterPortClose( void )
vMBMasterPortTimerClose( ); vMBMasterPortTimerClose( );
vMBMasterPortEventClose( ); vMBMasterPortEventClose( );
} }

View File

@@ -48,7 +48,7 @@
#include "driver/gpio.h" #include "driver/gpio.h"
#include "esp_log.h" // for esp_log #include "esp_log.h" // for esp_log
#include "esp_err.h" // for ESP_ERROR_CHECK macro #include "esp_err.h" // for ESP_ERROR_CHECK macro
/* ----------------------- Modbus includes ----------------------------------*/ /* ----------------------- Modbus includes ----------------------------------*/
#include "mb.h" #include "mb.h"
#include "mbport.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); USHORT usLength = uart_read_bytes(ucUartNumber, (uint8_t*)pucByte, 1, MB_SERIAL_RX_TOUT_TICKS);
return (usLength == 1); return (usLength == 1);
} }

View File

@@ -146,9 +146,9 @@ static esp_err_t mbc_serial_master_destroy(void)
// Set Modbus parameter description table // 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) 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."); 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."); ESP_ERR_INVALID_ARG, "mb table size is incorrect.");
mb_master_options_t* mbm_opts = &mbm_interface_ptr->opts; mb_master_options_t* mbm_opts = &mbm_interface_ptr->opts;
const mb_parameter_descriptor_t *reg_ptr = descriptor; 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++) 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. // 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."); 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."); 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."); ESP_ERR_INVALID_ARG, "mb descriptor param size is incorrect.");
} }
mbm_opts->mbm_param_descriptor_table = descriptor; 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, ESP_ERR_INVALID_STATE,
"Master interface uninitialized."); "Master interface uninitialized.");
mb_master_options_t* mbm_opts = &mbm_interface_ptr->opts; 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."); 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."); ESP_ERR_INVALID_ARG, "mb incorrect data pointer.");
eMBMasterReqErrCode mb_error = MB_MRE_NO_REG; 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."); "Master interface uninitialized.");
mb_master_options_t* mbm_opts = &mbm_interface_ptr->opts; 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."); 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."); 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."); ESP_ERR_NOT_FOUND, "mb incorrect cid of characteristic.");
// It is assumed that characteristics cid increased in the table // It is assumed that characteristics cid increased in the table
const mb_parameter_descriptor_t* reg_info = &mbm_opts->mbm_param_descriptor_table[cid]; 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."); ESP_ERR_INVALID_ARG, "mb incorrect characteristic key.");
*param_buffer = reg_info; *param_buffer = reg_info;
return ESP_OK; 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) switch(param_type)
{ // { //
case MB_PARAM_HOLDING: case MB_PARAM_HOLDING:
command = (mode == MB_PARAM_WRITE) ? command = (mode == MB_PARAM_WRITE) ?
MB_FUNC_WRITE_MULTIPLE_REGISTERS : MB_FUNC_WRITE_MULTIPLE_REGISTERS :
MB_FUNC_READ_HOLDING_REGISTER; MB_FUNC_READ_HOLDING_REGISTER;
break; break;
case MB_PARAM_INPUT: case MB_PARAM_INPUT:
command = MB_FUNC_READ_INPUT_REGISTER; command = MB_FUNC_READ_INPUT_REGISTER;
break; break;
case MB_PARAM_COIL: case MB_PARAM_COIL:
command = (mode == MB_PARAM_WRITE) ? command = (mode == MB_PARAM_WRITE) ?
MB_FUNC_WRITE_MULTIPLE_COILS : MB_FUNC_WRITE_MULTIPLE_COILS :
MB_FUNC_READ_COILS; MB_FUNC_READ_COILS;
break; break;
case MB_PARAM_DISCRETE: case MB_PARAM_DISCRETE:
if (mode != MB_PARAM_WRITE) { if (mode != MB_PARAM_WRITE) {
command = MB_FUNC_READ_DISCRETE_INPUTS; command = MB_FUNC_READ_DISCRETE_INPUTS;
} else { } else {
ESP_LOGE(MB_MASTER_TAG, "%s: Incorrect mode (%u)", ESP_LOGE(MB_MASTER_TAG, "%s: Incorrect mode (%u)",
__FUNCTION__, (uint8_t)mode); __FUNCTION__, (uint8_t)mode);
} }
break; break;
default: default:
ESP_LOGE(MB_MASTER_TAG, "%s: Incorrect param type (%u)", ESP_LOGE(MB_MASTER_TAG, "%s: Incorrect param type (%u)",
__FUNCTION__, param_type); __FUNCTION__, param_type);
break; break;
} }
return command; 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 // 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_param_request_t* request,
mb_parameter_descriptor_t* reg_data) 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."); "Master interface uninitialized.");
mb_master_options_t* mbm_opts = &mbm_interface_ptr->opts; mb_master_options_t* mbm_opts = &mbm_interface_ptr->opts;
esp_err_t error = ESP_ERR_NOT_FOUND; 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."); 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."); 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."); ESP_ERR_INVALID_ARG, "mb incorrect mode.");
MB_MASTER_ASSERT(mbm_opts->mbm_param_descriptor_table != NULL); MB_MASTER_ASSERT(mbm_opts->mbm_param_descriptor_table != NULL);
const mb_parameter_descriptor_t* reg_ptr = mbm_opts->mbm_param_descriptor_table; 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_start = reg_ptr->mb_reg_start;
request->reg_size = reg_ptr->mb_size; request->reg_size = reg_ptr->mb_size;
request->command = mbc_serial_master_get_command(reg_ptr->mb_param_type, mode); request->command = mbc_serial_master_get_command(reg_ptr->mb_param_type, mode);
MB_MASTER_CHECK((request->command > 0), MB_MASTER_CHECK((request->command > 0),
ESP_ERR_INVALID_ARG, ESP_ERR_INVALID_ARG,
"mb incorrect command or parameter type."); "mb incorrect command or parameter type.");
if (reg_data != NULL) { if (reg_data != NULL) {
*reg_data = *reg_ptr; // Set the cid registered parameter data *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 // 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) uint8_t* value_ptr, uint8_t *type)
{ {
MB_MASTER_CHECK((name != NULL), MB_MASTER_CHECK((name != NULL),
ESP_ERR_INVALID_ARG, "mb incorrect descriptor."); 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_INVALID_ARG, "type pointer is incorrect.");
esp_err_t error = ESP_ERR_INVALID_RESPONSE; esp_err_t error = ESP_ERR_INVALID_RESPONSE;
mb_param_request_t request ; 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 // 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) uint8_t* value_ptr, uint8_t *type)
{ {
MB_MASTER_CHECK((name != NULL), MB_MASTER_CHECK((name != NULL),
ESP_ERR_INVALID_ARG, "mb incorrect descriptor."); ESP_ERR_INVALID_ARG, "mb incorrect descriptor.");
MB_MASTER_CHECK((value_ptr != NULL), MB_MASTER_CHECK((value_ptr != NULL),
ESP_ERR_INVALID_ARG, "value pointer is incorrect."); 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_INVALID_ARG, "type pointer is incorrect.");
esp_err_t error = ESP_ERR_INVALID_RESPONSE; esp_err_t error = ESP_ERR_INVALID_RESPONSE;
mb_param_request_t request ; mb_param_request_t request ;
@@ -471,7 +471,7 @@ eMBErrorCode eMBRegInputCBSerialMaster(UCHAR * pucRegBuffer, USHORT usAddress,
"Master stack processing error."); "Master stack processing error.");
mb_master_options_t* mbm_opts = &mbm_interface_ptr->opts; mb_master_options_t* mbm_opts = &mbm_interface_ptr->opts;
// Number of input registers to be transferred // 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 UCHAR* pucInputBuffer = (UCHAR*)mbm_opts->mbm_reg_buffer_ptr; // Get instance address
USHORT usRegs = usNRegs; USHORT usRegs = usNRegs;
eMBErrorCode eStatus = MB_ENOERR; eMBErrorCode eStatus = MB_ENOERR;
@@ -555,7 +555,7 @@ eMBErrorCode eMBRegCoilsCBSerialMaster(UCHAR* pucRegBuffer, USHORT usAddress,
{ {
MB_MASTER_CHECK((mbm_interface_ptr != NULL), MB_MASTER_CHECK((mbm_interface_ptr != NULL),
MB_EILLSTATE, "Master interface uninitialized."); MB_EILLSTATE, "Master interface uninitialized.");
MB_MASTER_CHECK((pucRegBuffer != NULL), MB_MASTER_CHECK((pucRegBuffer != NULL),
MB_EINVAL, "Master stack processing error."); MB_EINVAL, "Master stack processing error.");
mb_master_options_t* mbm_opts = &mbm_interface_ptr->opts; mb_master_options_t* mbm_opts = &mbm_interface_ptr->opts;
USHORT usRegCoilNregs = (USHORT)mbm_opts->mbm_reg_buffer_size; 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_MASTER_CHECK((mbm_interface_ptr != NULL),
MB_EILLSTATE, "Master interface uninitialized."); MB_EILLSTATE, "Master interface uninitialized.");
MB_MASTER_CHECK((pucRegBuffer != NULL), MB_MASTER_CHECK((pucRegBuffer != NULL),
MB_EINVAL, "Master stack processing error."); MB_EINVAL, "Master stack processing error.");
mb_master_options_t* mbm_opts = &mbm_interface_ptr->opts; mb_master_options_t* mbm_opts = &mbm_interface_ptr->opts;
USHORT usRegDiscreteNregs = (USHORT)mbm_opts->mbm_reg_buffer_size; 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; BaseType_t status = 0;
// Parameter change notification queue // Parameter change notification queue
mbm_opts->mbm_event_group = xEventGroupCreate(); 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."); ESP_ERR_NO_MEM, "mb event group error.");
// Create modbus controller task // Create modbus controller task
status = xTaskCreate((void*)&modbus_master_task, status = xTaskCreate((void*)&modbus_master_task,

View File

@@ -35,4 +35,3 @@
esp_err_t mbc_serial_master_create(void** handler); esp_err_t mbc_serial_master_create(void** handler);
#endif // _MODBUS_SERIAL_CONTROLLER_MASTER #endif // _MODBUS_SERIAL_CONTROLLER_MASTER

View File

@@ -33,7 +33,7 @@ static mb_slave_interface_t* mbs_interface_ptr = NULL;
// Modbus task function // Modbus task function
static void modbus_slave_task(void *pvParameters) 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_ASSERT(mbs_interface_ptr != NULL);
mb_slave_options_t* mbs_opts = &mbs_interface_ptr->opts; 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, eMBErrorCode eMBRegInputCBSerialSlave(UCHAR * pucRegBuffer, USHORT usAddress,
USHORT usNRegs) USHORT usNRegs)
{ {
MB_SLAVE_CHECK((mbs_interface_ptr != NULL), MB_SLAVE_CHECK((mbs_interface_ptr != NULL),
MB_EILLSTATE, "Slave stack uninitialized."); MB_EILLSTATE, "Slave stack uninitialized.");
MB_SLAVE_CHECK((pucRegBuffer != NULL), MB_SLAVE_CHECK((pucRegBuffer != NULL),
MB_EINVAL, "Slave stack call failed."); MB_EINVAL, "Slave stack call failed.");
mb_slave_options_t* mbs_opts = &mbs_interface_ptr->opts; 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 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, eMBErrorCode eMBRegHoldingCBSerialSlave(UCHAR * pucRegBuffer, USHORT usAddress,
USHORT usNRegs, eMBRegisterMode eMode) USHORT usNRegs, eMBRegisterMode eMode)
{ {
MB_SLAVE_CHECK((mbs_interface_ptr != NULL), MB_SLAVE_CHECK((mbs_interface_ptr != NULL),
MB_EILLSTATE, "Slave stack uninitialized."); MB_EILLSTATE, "Slave stack uninitialized.");
MB_SLAVE_CHECK((pucRegBuffer != NULL), MB_SLAVE_CHECK((pucRegBuffer != NULL),
MB_EINVAL, "Slave stack call failed."); MB_EINVAL, "Slave stack call failed.");
mb_slave_options_t* mbs_opts = &mbs_interface_ptr->opts; mb_slave_options_t* mbs_opts = &mbs_interface_ptr->opts;
USHORT usRegHoldingNregs = (USHORT)(mbs_opts->mbs_area_descriptors[MB_PARAM_HOLDING].size >> 1); 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, eMBErrorCode eMBRegCoilsCBSerialSlave(UCHAR* pucRegBuffer, USHORT usAddress,
USHORT usNCoils, eMBRegisterMode eMode) USHORT usNCoils, eMBRegisterMode eMode)
{ {
MB_SLAVE_CHECK((mbs_interface_ptr != NULL), MB_SLAVE_CHECK((mbs_interface_ptr != NULL),
MB_EILLSTATE, "Slave stack uninitialized."); MB_EILLSTATE, "Slave stack uninitialized.");
MB_SLAVE_CHECK((pucRegBuffer != NULL), MB_SLAVE_CHECK((pucRegBuffer != NULL),
MB_EINVAL, "Slave stack call failed."); MB_EINVAL, "Slave stack call failed.");
mb_slave_options_t* mbs_opts = &mbs_interface_ptr->opts; 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 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, eMBErrorCode eMBRegDiscreteCBSerialSlave(UCHAR* pucRegBuffer, USHORT usAddress,
USHORT usNDiscrete) USHORT usNDiscrete)
{ {
MB_SLAVE_CHECK((mbs_interface_ptr != NULL), MB_SLAVE_CHECK((mbs_interface_ptr != NULL),
MB_EILLSTATE, "Slave stack uninitialized."); MB_EILLSTATE, "Slave stack uninitialized.");
MB_SLAVE_CHECK((pucRegBuffer != NULL), MB_SLAVE_CHECK((pucRegBuffer != NULL),
MB_EINVAL, "Slave stack call failed."); MB_EINVAL, "Slave stack call failed.");
mb_slave_options_t* mbs_opts = &mbs_interface_ptr->opts; 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 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; return ESP_OK;
} }

View File

@@ -37,4 +37,3 @@
esp_err_t mbc_serial_slave_create(void** handler); esp_err_t mbc_serial_slave_create(void** handler);
#endif // _MODBUS_SERIAL_CONTROLLER_SLAVE #endif // _MODBUS_SERIAL_CONTROLLER_SLAVE

View File

@@ -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_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_options_t* mbm_opts = &mbm_interface_ptr->opts;
MB_MASTER_CHECK((mbm_opts != NULL), ESP_ERR_INVALID_ARG, "mb options."); 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; 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."); MB_MASTER_CHECK((comm_ip_table != NULL), ESP_ERR_INVALID_ARG, "mb ip table address is incorrect.");

View File

@@ -40,4 +40,3 @@
esp_err_t mbc_tcp_master_create(void** handler); esp_err_t mbc_tcp_master_create(void** handler);
#endif // _MODBUS_TCP_CONTROLLER_SLAVE #endif // _MODBUS_TCP_CONTROLLER_SLAVE

View File

@@ -38,4 +38,3 @@
esp_err_t mbc_tcp_slave_create(void** handler); esp_err_t mbc_tcp_slave_create(void** handler);
#endif // _MODBUS_TCP_CONTROLLER_SLAVE #endif // _MODBUS_TCP_CONTROLLER_SLAVE

View File

@@ -706,4 +706,3 @@ xMBTCPPortSendResponse( UCHAR * pucMBTCPFrame, USHORT usTCPLength )
} }
return bFrameSent; return bFrameSent;
} }

View File

@@ -3,4 +3,4 @@
cmake_minimum_required(VERSION 3.5) cmake_minimum_required(VERSION 3.5)
idf_component_register(SRCS "modbus_params.c" idf_component_register(SRCS "modbus_params.c"
INCLUDE_DIRS "include" INCLUDE_DIRS "include"
PRIV_REQUIRES freemodbus) PRIV_REQUIRES freemodbus)

View File

@@ -2,4 +2,4 @@
# Component Makefile # Component Makefile
# #
COMPONENT_ADD_INCLUDEDIRS := include COMPONENT_ADD_INCLUDEDIRS := include
COMPONENT_SRCDIRS := . COMPONENT_SRCDIRS := .

View File

@@ -14,4 +14,3 @@ input_reg_params_t input_reg_params = { 0 };
coil_reg_params_t coil_reg_params = { 0 }; coil_reg_params_t coil_reg_params = { 0 };
discrete_reg_params_t discrete_reg_params = { 0 }; discrete_reg_params_t discrete_reg_params = { 0 };

View File

@@ -8,4 +8,3 @@ PROJECT_NAME := modbus_master
EXTRA_COMPONENT_DIRS := $(IDF_PATH)/examples/protocols/modbus/mb_example_common EXTRA_COMPONENT_DIRS := $(IDF_PATH)/examples/protocols/modbus/mb_example_common
include $(IDF_PATH)/make/project.mk include $(IDF_PATH)/make/project.mk

View File

@@ -2,4 +2,3 @@ set(PROJECT_NAME "modbus_master")
idf_component_register(SRCS "master.c" idf_component_register(SRCS "master.c"
INCLUDE_DIRS ".") INCLUDE_DIRS ".")

View File

@@ -148,12 +148,12 @@ static void master_operation_func(void *arg)
float value = 0; float value = 0;
bool alarm_state = false; bool alarm_state = false;
const mb_parameter_descriptor_t* param_descriptor = NULL; const mb_parameter_descriptor_t* param_descriptor = NULL;
ESP_LOGI(MASTER_TAG, "Start modbus test..."); ESP_LOGI(MASTER_TAG, "Start modbus test...");
for(uint16_t retry = 0; retry <= MASTER_MAX_RETRY && (!alarm_state); retry++) { for(uint16_t retry = 0; retry <= MASTER_MAX_RETRY && (!alarm_state); retry++) {
// Read all found characteristics from slave(s) // 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 // Get data from parameters description table
// and use this information to fill the characteristics 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(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.", ESP_LOGI(MASTER_TAG, "Alarm triggered by cid #%d.",
param_descriptor->cid); param_descriptor->cid);
} else { } else {
@@ -315,6 +315,6 @@ void app_main(void)
// Initialization of device peripheral and objects // Initialization of device peripheral and objects
ESP_ERROR_CHECK(master_init()); ESP_ERROR_CHECK(master_init());
vTaskDelay(10); vTaskDelay(10);
master_operation_func(NULL); master_operation_func(NULL);
} }

View File

@@ -8,4 +8,3 @@ PROJECT_NAME := modbus_slave
EXTRA_COMPONENT_DIRS := $(IDF_PATH)/examples/protocols/modbus/mb_example_common EXTRA_COMPONENT_DIRS := $(IDF_PATH)/examples/protocols/modbus/mb_example_common
include $(IDF_PATH)/make/project.mk include $(IDF_PATH)/make/project.mk

View File

@@ -1,4 +1,4 @@
set(PROJECT_NAME "modbus_slave") set(PROJECT_NAME "modbus_slave")
idf_component_register(SRCS "slave.c" idf_component_register(SRCS "slave.c"
INCLUDE_DIRS ".") INCLUDE_DIRS ".")

View File

@@ -128,7 +128,7 @@ void app_main(void)
// Starts of modbus controller and stack // Starts of modbus controller and stack
ESP_ERROR_CHECK(mbc_slave_start()); ESP_ERROR_CHECK(mbc_slave_start());
// Set UART pin numbers // Set UART pin numbers
ESP_ERROR_CHECK(uart_set_pin(MB_PORT_NUM, CONFIG_MB_UART_TXD, ESP_ERROR_CHECK(uart_set_pin(MB_PORT_NUM, CONFIG_MB_UART_TXD,
CONFIG_MB_UART_RXD, CONFIG_MB_UART_RTS, CONFIG_MB_UART_RXD, CONFIG_MB_UART_RTS,
@@ -136,7 +136,7 @@ void app_main(void)
// Set UART driver mode to Half Duplex // Set UART driver mode to Half Duplex
ESP_ERROR_CHECK(uart_set_mode(MB_PORT_NUM, UART_MODE_RS485_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, "Modbus slave stack initialized.");
ESP_LOGI(SLAVE_TAG, "Start modbus test..."); ESP_LOGI(SLAVE_TAG, "Start modbus test...");

View File

@@ -2,4 +2,3 @@ set(PROJECT_NAME "modbus_tcp_master")
idf_component_register(SRCS "tcp_master.c" idf_component_register(SRCS "tcp_master.c"
INCLUDE_DIRS ".") INCLUDE_DIRS ".")

View File

@@ -77,7 +77,7 @@
#define MB_MDNS_INSTANCE(pref) pref"mb_master_tcp" #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 // Each address in the table is a index of TCP slave ip address in mb_communication_info_t::tcp_ip_addr table
enum { enum {
MB_DEVICE_ADDR1 = 1, // Slave address 1 MB_DEVICE_ADDR1 = 1, // Slave address 1
@@ -432,12 +432,12 @@ static void master_operation_func(void *arg)
float value = 0; float value = 0;
bool alarm_state = false; bool alarm_state = false;
const mb_parameter_descriptor_t* param_descriptor = NULL; const mb_parameter_descriptor_t* param_descriptor = NULL;
ESP_LOGI(MASTER_TAG, "Start modbus test..."); ESP_LOGI(MASTER_TAG, "Start modbus test...");
for(uint16_t retry = 0; retry <= MASTER_MAX_RETRY && (!alarm_state); retry++) { for(uint16_t retry = 0; retry <= MASTER_MAX_RETRY && (!alarm_state); retry++) {
// Read all found characteristics from slave(s) // 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 // Get data from parameters description table
// and use this information to fill the characteristics 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); void* temp_data_ptr = master_get_param_data(param_descriptor);
assert(temp_data_ptr); assert(temp_data_ptr);
uint8_t type = 0; 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); (uint8_t*)&value, &type);
if (err == ESP_OK) { if (err == ESP_OK) {
*(float*)temp_data_ptr = value; *(float*)temp_data_ptr = value;
@@ -455,9 +455,9 @@ static void master_operation_func(void *arg)
(param_descriptor->mb_param_type == MB_PARAM_INPUT)) { (param_descriptor->mb_param_type == MB_PARAM_INPUT)) {
ESP_LOGI(MASTER_TAG, "Characteristic #%d %s (%s) value = %f (0x%x) read successful.", ESP_LOGI(MASTER_TAG, "Characteristic #%d %s (%s) value = %f (0x%x) read successful.",
param_descriptor->cid, param_descriptor->cid,
(char*)param_descriptor->param_key, (char*)param_descriptor->param_key,
(char*)param_descriptor->param_units, (char*)param_descriptor->param_units,
value, value,
*(uint32_t*)temp_data_ptr); *(uint32_t*)temp_data_ptr);
if (((value > param_descriptor->param_opts.max) || if (((value > param_descriptor->param_opts.max) ||
(value < param_descriptor->param_opts.min))) { (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"; 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.", ESP_LOGI(MASTER_TAG, "Characteristic #%d %s (%s) value = %s (0x%x) read successful.",
param_descriptor->cid, param_descriptor->cid,
(char*)param_descriptor->param_key, (char*)param_descriptor->param_key,
(char*)param_descriptor->param_units, (char*)param_descriptor->param_units,
(const char*)rw_str, (const char*)rw_str,
*(uint16_t*)temp_data_ptr); *(uint16_t*)temp_data_ptr);
@@ -490,8 +490,8 @@ static void master_operation_func(void *arg)
} }
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.", ESP_LOGI(MASTER_TAG, "Alarm triggered by cid #%d.",
param_descriptor->cid); param_descriptor->cid);
} else { } else {
@@ -591,7 +591,7 @@ void app_main(void)
// Initialization of device peripheral and objects // Initialization of device peripheral and objects
ESP_ERROR_CHECK(master_init()); ESP_ERROR_CHECK(master_init());
vTaskDelay(10); vTaskDelay(10);
master_operation_func(NULL); master_operation_func(NULL);
#if CONFIG_MB_MDNS_IP_RESOLVER #if CONFIG_MB_MDNS_IP_RESOLVER
master_destroy_slave_list(slave_ip_address_table); master_destroy_slave_list(slave_ip_address_table);

View File

@@ -16,4 +16,4 @@ CONFIG_FMB_TIMER_INDEX=0
CONFIG_FMB_TIMER_ISR_IN_IRAM=y CONFIG_FMB_TIMER_ISR_IN_IRAM=y
CONFIG_MB_MDNS_IP_RESOLVER=n CONFIG_MB_MDNS_IP_RESOLVER=n
CONFIG_MB_SLAVE_IP_FROM_STDIN=y CONFIG_MB_SLAVE_IP_FROM_STDIN=y
CONFIG_EXAMPLE_CONNECT_IPV6=n CONFIG_EXAMPLE_CONNECT_IPV6=n

View File

@@ -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 EXTRA_COMPONENT_DIRS += $(IDF_PATH)/examples/common_components/protocol_examples_common
include $(IDF_PATH)/make/project.mk include $(IDF_PATH)/make/project.mk

View File

@@ -1,4 +1,4 @@
set(PROJECT_NAME "modbus_tcp_slave") set(PROJECT_NAME "modbus_tcp_slave")
idf_component_register(SRCS "tcp_slave.c" idf_component_register(SRCS "tcp_slave.c"
INCLUDE_DIRS ".") INCLUDE_DIRS ".")

View File

@@ -15,4 +15,4 @@ menu "Modbus Example Configuration"
This option allows to use mDNS service to resolve IP addresses of the Modbus slaves. 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. If the option is disabled the ip addresses of slaves are defined in static table.
endmenu endmenu

View File

@@ -168,10 +168,10 @@ void app_main(void)
void* mbc_slave_handler = NULL; void* mbc_slave_handler = NULL;
ESP_ERROR_CHECK(mbc_slave_init_tcp(&mbc_slave_handler)); // Initialization of Modbus controller 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_param_info_t reg_info; // keeps the Modbus registers access information
mb_register_area_descriptor_t reg_area; // Modbus register area descriptor structure mb_register_area_descriptor_t reg_area; // Modbus register area descriptor structure
mb_communication_info_t comm_info = { 0 }; mb_communication_info_t comm_info = { 0 };
comm_info.ip_port = MB_TCP_PORT_NUMBER; comm_info.ip_port = MB_TCP_PORT_NUMBER;
#if !CONFIG_EXAMPLE_CONNECT_IPV6 #if !CONFIG_EXAMPLE_CONNECT_IPV6

View File

@@ -18,4 +18,4 @@ CONFIG_MB_MDNS_IP_RESOLVER=n
CONFIG_MB_SLAVE_IP_FROM_STDIN=y CONFIG_MB_SLAVE_IP_FROM_STDIN=y
CONFIG_MB_SLAVE_ADDR=1 CONFIG_MB_SLAVE_ADDR=1
CONFIG_LOG_DEFAULT_LEVEL_DEBUG=y CONFIG_LOG_DEFAULT_LEVEL_DEBUG=y
CONFIG_EXAMPLE_CONNECT_IPV6=n CONFIG_EXAMPLE_CONNECT_IPV6=n