mirror of
https://github.com/espressif/esp-modbus.git
synced 2025-09-25 14:10:56 +02:00
modify example
This commit is contained in:
@@ -20,7 +20,7 @@
|
||||
#define MASTER_MAX_CIDS num_device_parameters
|
||||
|
||||
// Number of reading of parameters from slave
|
||||
#define MASTER_MAX_RETRY (10)
|
||||
#define MASTER_MAX_RETRY (1000)
|
||||
|
||||
// Timeout to update cid over Modbus
|
||||
#define UPDATE_CIDS_TIMEOUT_MS (500)
|
||||
@@ -149,10 +149,10 @@ const mb_parameter_descriptor_t device_parameters[] = {
|
||||
OPTS( 0xAA, 0x15, 0 ), PAR_PERMS_READ_WRITE_TRIGGER },
|
||||
{ CID_RELAY_P2, STR("RelayP2"), STR("on/off"), MB_DEVICE_ADDR1, MB_PARAM_COIL, 10, 6,
|
||||
COIL_OFFSET(coils_port1), PARAM_TYPE_U8, 1,
|
||||
OPTS( 0x55, 0x2A, 0 ), PAR_PERMS_READ_WRITE_TRIGGER },
|
||||
OPTS( 0x55, 0x2A, 0xAA ), PAR_PERMS_READ_WRITE_TRIGGER },
|
||||
{ CID_DISCR_P1, STR("DiscreteInpP1"), STR("on/off"), MB_DEVICE_ADDR1, MB_PARAM_DISCRETE, 2, 7,
|
||||
DISCR_OFFSET(discrete_input_port1), PARAM_TYPE_U8, 1,
|
||||
OPTS( 0xAA, 0x15, 0 ), PAR_PERMS_READ_WRITE_TRIGGER },
|
||||
OPTS( 0xAA, 0x15, 0x55 ), PAR_PERMS_READ_WRITE_TRIGGER },
|
||||
#if CONFIG_FMB_EXT_TYPE_SUPPORT
|
||||
{ CID_HOLD_U8_A, STR("U8_A"), STR("__"), MB_DEVICE_ADDR1, MB_PARAM_HOLDING,
|
||||
TEST_HOLD_REG_START(holding_u8_a), TEST_HOLD_REG_SIZE(holding_u8_a),
|
||||
@@ -445,7 +445,7 @@ static void master_operation_func(void *arg)
|
||||
float value = *(float *)temp_data_ptr;
|
||||
if (((value > param_descriptor->param_opts.max) ||
|
||||
(value < param_descriptor->param_opts.min))) {
|
||||
alarm_state = true;
|
||||
//alarm_state = true;
|
||||
break;
|
||||
}
|
||||
} else if ((cid >= CID_RELAY_P1) && (cid <= CID_DISCR_P1)) {
|
||||
@@ -466,11 +466,11 @@ static void master_operation_func(void *arg)
|
||||
(char *)param_descriptor->param_units,
|
||||
(const char *)rw_str,
|
||||
*(uint8_t *)temp_data_ptr);
|
||||
alarm_state = true;
|
||||
//alarm_state = true;
|
||||
break;
|
||||
}
|
||||
if (state & param_descriptor->param_opts.opt1) {
|
||||
alarm_state = true;
|
||||
//alarm_state = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -567,11 +567,24 @@ static esp_err_t master_init(void)
|
||||
return err;
|
||||
}
|
||||
|
||||
#include "esp_heap_trace.h"
|
||||
|
||||
#define NUM_RECORDS 100
|
||||
static heap_trace_record_t trace_record[NUM_RECORDS];
|
||||
|
||||
void app_main(void)
|
||||
{
|
||||
// Initialization of device peripheral and objects
|
||||
ESP_ERROR_CHECK(master_init());
|
||||
vTaskDelay(10);
|
||||
|
||||
ESP_ERROR_CHECK( heap_trace_init_standalone(trace_record, NUM_RECORDS) );
|
||||
|
||||
ESP_ERROR_CHECK( heap_trace_start(HEAP_TRACE_LEAKS) );
|
||||
|
||||
master_operation_func(NULL);
|
||||
|
||||
ESP_ERROR_CHECK( heap_trace_stop() );
|
||||
heap_trace_dump();
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user