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