espressif / esp-idf

Espressif IoT Development Framework. Official development framework for Espressif SoCs.
Apache License 2.0
13.82k stars 7.32k forks source link

Modbus master failed to initialize after called esp_restart() or program dump. (IDFGH-4652) #6466

Closed NguyenMinhTri closed 2 years ago

NguyenMinhTri commented 3 years ago

Environment

Problem Description

Modbus master failed to initialize after called esp_restart() or program dump.

Steps to reproduce

  1. Power plug for ESP32-WROOM
  2. Modbus master is initialized.
  3. Modbus master is running successfully.
  4. Call esp_restart().
  5. Modbus master failed to initialize as below.

// If possible, attach a picture of your setup/wiring here.

Code to reproduce this issue

    esp_err_t err = mbc_master_init(MB_PORT_SERIAL_MASTER, &master_handler);
    MASTER_CHECK((master_handler != NULL), ESP_ERR_INVALID_STATE,
                 "mb controller initialization fail.");
    MASTER_CHECK((err == ESP_OK), ESP_ERR_INVALID_STATE,
                 "mb controller initialization fail, returns(0x%x).",
                 (uint32_t)err);
    err = mbc_master_setup((void *)&comm);
    MASTER_CHECK((err == ESP_OK), ESP_ERR_INVALID_STATE,
                 "mb controller setup fail, returns(0x%x).",
                 (uint32_t)err);

Debug Logs

D (11331) MB_PORT_COMMON: vMBPortSetMode: Port enter critical.
D (11331) MB_PORT_COMMON: vMBPortSetMode: Port exit critical
D (11331) MB_PORT_COMMON: eMBMasterRTUInit: Port enter critical.
I (11341) uart: queue free spaces: 20
D (11341) intr_alloc: Connected src 36 to int 3 (cpu 1)
D (11351) MB_PORT_COMMON: xMBMasterPortSerialInit Init serial.
/Users/nguy1nt5i/eiptrsa-ldc: Cmponcnts/fre 1tos/ int 4 (cpu .c:[31 (D (e1t61)upBePBiTs)- aON:reMfailed!R

abort() was called at PC 0x4008b77f on core 0
0x4008b77f: xEventGroupSetBits at /Users/nguyentri/esp/esp-idf/components/freertos/event_groups.c:531 (discriminator 1)

Backtrace:0x40088c17:0x3ffc7c60 0x40089421:0x3ffc7c80 0x400904e2:0x3ffc7ca0 0x4008b77f:0x3ffc7d10 0x4008b859:0x3ffc7d30 0x4008bb79:0x3ffc7d50 0x4008bc87:0x3ffc7d90 0x4008bd89:0x3ffc7dc0
0x40088c17: panic_abort at /Users/nguyentri/esp/esp-idf/components/esp_system/panic.c:356

0x40089421: esp_system_abort at /Users/nguyentri/esp/esp-idf/components/esp_system/system_api.c:108

0x400904e2: abort at /Users/nguyentri/esp/esp-idf/components/newlib/abort.c:46

0x4008b77f: xEventGroupSetBits at /Users/nguyentri/esp/esp-idf/components/freertos/event_groups.c:531 (discriminator 1)

0x4008b859: vEventGroupSetBitsCallback at /Users/nguyentri/esp/esp-idf/components/freertos/event_groups.c:661

0x4008bb79: prvProcessReceivedCommands at /Users/nguyentri/esp/esp-idf/components/freertos/timers.c:731 (discriminator 2)

0x4008bc87: prvTimerTask at /Users/nguyentri/esp/esp-idf/components/freertos/timers.c:558 (discriminator 1)

0x4008bd89: vPortTaskWrapper at /Users/nguyentri/esp/esp-idf/components/freertos/port/xtensa/port.c:168
alisitsyn commented 3 years ago

Hello @NguyenMinhTri,

Thanks for issue. I was trying to reproduce it on my system on your commit 2bfdd036b2dbd07004c8e4f2ffc87c728819b737. I used modified modbus serial master example to reproduce the issue:

void app_main(void)
{
    // Initialization of device peripheral and objects
    ESP_ERROR_CHECK(master_init());
    vTaskDelay(10);

    xTaskCreate(&master_operation_func, "modbus_task", 16384, NULL, 5, NULL);
    vTaskDelay(300);
    esp_restart();

    master_operation_func(NULL);
}

Am I reproduce your conditions correctly? As you can see in the log below the modbus initialized, started communication then esp_restart() called and restarts processor and it is able to start properly again and read and write parameters. esp_restart_after_normal_start_modbus.log

According to this I have some questions:

  1. Which modbus slave device you are using with your master application?
  2. Could you send me the example which can easily reproduce your issue?
  3. Could you describe more conditions that would help to reproduce and then fix the issue? Thanks. UPD: there is the issue related to esp_restart(), but the fix for this was merged: incorrect reset of UART1/2 tx/rx fifo.
NguyenMinhTri commented 3 years ago

Hi @alisitsyn, sorry for missing information. I have updated new code as below.

static esp_err_t wifi_event_handler(void *ctx, system_event_t *event)
{
    switch (event->event_id) {
    case SYSTEM_EVENT_STA_START:
        esp_wifi_connect();
        break;
    case SYSTEM_EVENT_STA_GOT_IP:
        xEventGroupSetBits(wifi_event_group, CONNECTED_BIT);
        // Initialization of device peripheral and objects
        ESP_ERROR_CHECK(master_init());
        xTaskCreate(&master_operation_func, "modbus_task", 16384, NULL, 5, NULL);
        vTaskDelay(300);
        esp_restart();
        vTaskDelay(10);
        break;
    case SYSTEM_EVENT_STA_DISCONNECTED:
        esp_wifi_connect();
        xEventGroupClearBits(wifi_event_group, CONNECTED_BIT);
        break;
    default:
        break;
    }
    return ESP_OK;
}

static void wifi_init(void)
{
    tcpip_adapter_init();
    wifi_event_group = xEventGroupCreate();
    ESP_ERROR_CHECK(esp_event_loop_init(wifi_event_handler, NULL));
    wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
    ESP_ERROR_CHECK(esp_wifi_init(&cfg));
    ESP_ERROR_CHECK(esp_wifi_set_storage(WIFI_STORAGE_RAM));
    wifi_config_t wifi_config = {
        .sta = {
            .ssid = CONFIG_ESP_WIFI_SSID,
            .password = CONFIG_ESP_WIFI_PASSWORD,
        },
    };
    ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA));
    ESP_ERROR_CHECK(esp_wifi_set_config(ESP_IF_WIFI_STA, &wifi_config));
    ESP_LOGI(TAG, "start the WIFI SSID:[%s]", CONFIG_ESP_WIFI_SSID);
    ESP_ERROR_CHECK(esp_wifi_start());
    ESP_LOGI(TAG, "Waiting for wifi");
    xEventGroupWaitBits(wifi_event_group, CONNECTED_BIT, false, true, portMAX_DELAY);
}

void app_main(void)
{
        //Initialize NVS
    esp_err_t ret = nvs_flash_init();
    if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) {
        ESP_ERROR_CHECK(nvs_flash_erase());
        ret = nvs_flash_init();
    }
    ESP_ERROR_CHECK(ret);
    ESP_LOGI(TAG, "ESP_WIFI_MODE_STA");
    wifi_init();

}
alisitsyn commented 3 years ago

Hi @NguyenMinhTri,

I have updated the example you provided to use netif instead of tcpip_adapter which is deprecated. The example works just fine on your commit. The log and updated source are attached.

I am trying to get the reason for issue but it could be somewhere else in your code. Could you start my example to make it reproducible?

Thanks. init_wifi_modbus_on_connect_restart_app.zip

NguyenMinhTri commented 3 years ago

Hi @alisitsyn, I have tried with your code. Sometime, this issue is found as below. Please check debug log.

Environment

Problem Description

Modbus master failed to initialize after called esp_restart() or program dump.

Code to reproduce this issue

sdkconfig.h

/*
 * Automatically generated file. DO NOT EDIT.
 * Espressif IoT Development Framework (ESP-IDF) Configuration Header
 */
#pragma once
#define CONFIG_IDF_CMAKE 1
#define CONFIG_IDF_TARGET_ARCH_XTENSA 1
#define CONFIG_IDF_TARGET "esp32"
#define CONFIG_IDF_TARGET_ESP32 1
#define CONFIG_IDF_FIRMWARE_CHIP_ID 0x0000
#define CONFIG_SDK_TOOLPREFIX "xtensa-esp32-elf-"
#define CONFIG_APP_BUILD_TYPE_APP_2NDBOOT 1
#define CONFIG_APP_BUILD_GENERATE_BINARIES 1
#define CONFIG_APP_BUILD_BOOTLOADER 1
#define CONFIG_APP_BUILD_USE_FLASH_SECTIONS 1
#define CONFIG_APP_COMPILE_TIME_DATE 1
#define CONFIG_APP_RETRIEVE_LEN_ELF_SHA 16
#define CONFIG_BOOTLOADER_OFFSET_IN_FLASH 0x1000
#define CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE 1
#define CONFIG_BOOTLOADER_LOG_LEVEL_INFO 1
#define CONFIG_BOOTLOADER_LOG_LEVEL 3
#define CONFIG_BOOTLOADER_VDDSDIO_BOOST_1_9V 1
#define CONFIG_BOOTLOADER_WDT_ENABLE 1
#define CONFIG_BOOTLOADER_WDT_TIME_MS 9000
#define CONFIG_BOOTLOADER_RESERVE_RTC_SIZE 0x0
#define CONFIG_ESPTOOLPY_BAUD_OTHER_VAL 115200
#define CONFIG_ESPTOOLPY_FLASHMODE_DIO 1
#define CONFIG_ESPTOOLPY_FLASHMODE "dio"
#define CONFIG_ESPTOOLPY_FLASHFREQ_40M 1
#define CONFIG_ESPTOOLPY_FLASHFREQ "40m"
#define CONFIG_ESPTOOLPY_FLASHSIZE_4MB 1
#define CONFIG_ESPTOOLPY_FLASHSIZE "4MB"
#define CONFIG_ESPTOOLPY_FLASHSIZE_DETECT 1
#define CONFIG_ESPTOOLPY_BEFORE_RESET 1
#define CONFIG_ESPTOOLPY_BEFORE "default_reset"
#define CONFIG_ESPTOOLPY_AFTER_RESET 1
#define CONFIG_ESPTOOLPY_AFTER "hard_reset"
#define CONFIG_ESPTOOLPY_MONITOR_BAUD_115200B 1
#define CONFIG_ESPTOOLPY_MONITOR_BAUD_OTHER_VAL 115200
#define CONFIG_ESPTOOLPY_MONITOR_BAUD 115200
#define CONFIG_PARTITION_TABLE_TWO_OTA 1
#define CONFIG_PARTITION_TABLE_CUSTOM_FILENAME "partitions.csv"
#define CONFIG_PARTITION_TABLE_FILENAME "partitions_two_ota.csv"
#define CONFIG_PARTITION_TABLE_OFFSET 0x8000
#define CONFIG_PARTITION_TABLE_MD5 1
#define CONFIG_ESP_WIFI_SSID "myssid"
#define CONFIG_ESP_WIFI_PASSWORD "mypassword"
#define CONFIG_OUTPUT_GPIO 27
#define CONFIG_MB_UART_PORT_NUM 2
#define CONFIG_MB_UART_BAUD_RATE 9600
#define CONFIG_MB_UART_RXD 5
#define CONFIG_MB_UART_TXD 4
#define CONFIG_MB_UART_RTS 16
#define CONFIG_MB_COMM_MODE_RTU 1
#define CONFIG_COMPILER_OPTIMIZATION_DEFAULT 1
#define CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_ENABLE 1
#define CONFIG_COMPILER_STACK_CHECK_MODE_NONE 1
#define CONFIG_APPTRACE_DEST_NONE 1
#define CONFIG_APPTRACE_LOCK_ENABLE 1
#define CONFIG_BTDM_CTRL_BR_EDR_SCO_DATA_PATH_EFF 0
#define CONFIG_BTDM_CTRL_PCM_ROLE_EFF 0
#define CONFIG_BTDM_CTRL_PCM_POLAR_EFF 0
#define CONFIG_BTDM_CTRL_BLE_MAX_CONN_EFF 0
#define CONFIG_BTDM_CTRL_BR_EDR_MAX_ACL_CONN_EFF 0
#define CONFIG_BTDM_CTRL_BR_EDR_MAX_SYNC_CONN_EFF 0
#define CONFIG_BTDM_CTRL_PINNED_TO_CORE 0
#define CONFIG_BTDM_BLE_SLEEP_CLOCK_ACCURACY_INDEX_EFF 1
#define CONFIG_BT_RESERVE_DRAM 0x0
#define CONFIG_COAP_MBEDTLS_PSK 1
#define CONFIG_COAP_LOG_DEFAULT_LEVEL 0
#define CONFIG_ADC_DISABLE_DAC 1
#define CONFIG_SPI_MASTER_ISR_IN_IRAM 1
#define CONFIG_SPI_SLAVE_ISR_IN_IRAM 1
#define CONFIG_EFUSE_CODE_SCHEME_COMPAT_3_4 1
#define CONFIG_EFUSE_MAX_BLK_LEN 192
#define CONFIG_ESP_TLS_USING_MBEDTLS 1
#define CONFIG_ESP32_REV_MIN_0 1
#define CONFIG_ESP32_REV_MIN 0
#define CONFIG_ESP32_DPORT_WORKAROUND 1
#define CONFIG_ESP32_DEFAULT_CPU_FREQ_160 1
#define CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ 160
#define CONFIG_ESP32_TRACEMEM_RESERVE_DRAM 0x0
#define CONFIG_ESP32_UNIVERSAL_MAC_ADDRESSES_FOUR 1
#define CONFIG_ESP32_UNIVERSAL_MAC_ADDRESSES 4
#define CONFIG_ESP32_ULP_COPROC_RESERVE_MEM 0
#define CONFIG_ESP32_DEBUG_OCDAWARE 1
#define CONFIG_ESP32_BROWNOUT_DET 1
#define CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_0 1
#define CONFIG_ESP32_BROWNOUT_DET_LVL 0
#define CONFIG_ESP32_REDUCE_PHY_TX_POWER 1
#define CONFIG_ESP32_TIME_SYSCALL_USE_RTC_FRC1 1
#define CONFIG_ESP32_RTC_CLK_SRC_INT_RC 1
#define CONFIG_ESP32_RTC_CLK_CAL_CYCLES 1024
#define CONFIG_ESP32_DEEP_SLEEP_WAKEUP_DELAY 2000
#define CONFIG_ESP32_XTAL_FREQ_40 1
#define CONFIG_ESP32_XTAL_FREQ 40
#define CONFIG_ESP32_DPORT_DIS_INTERRUPT_LVL 5
#define CONFIG_ADC_CAL_EFUSE_TP_ENABLE 1
#define CONFIG_ADC_CAL_EFUSE_VREF_ENABLE 1
#define CONFIG_ADC_CAL_LUT_ENABLE 1
#define CONFIG_ESP_ERR_TO_NAME_LOOKUP 1
#define CONFIG_ESP_SYSTEM_EVENT_QUEUE_SIZE 32
#define CONFIG_ESP_SYSTEM_EVENT_TASK_STACK_SIZE 2304
#define CONFIG_ESP_MAIN_TASK_STACK_SIZE 3584
#define CONFIG_ESP_IPC_TASK_STACK_SIZE 1024
#define CONFIG_ESP_IPC_USES_CALLERS_PRIORITY 1
#define CONFIG_ESP_MINIMAL_SHARED_STACK_SIZE 2048
#define CONFIG_ESP_CONSOLE_UART_DEFAULT 1
#define CONFIG_ESP_CONSOLE_UART 1
#define CONFIG_ESP_CONSOLE_MULTIPLE_UART 1
#define CONFIG_ESP_CONSOLE_UART_NUM 0
#define CONFIG_ESP_CONSOLE_UART_BAUDRATE 115200
#define CONFIG_ESP_INT_WDT 1
#define CONFIG_ESP_INT_WDT_TIMEOUT_MS 300
#define CONFIG_ESP_INT_WDT_CHECK_CPU1 1
#define CONFIG_ESP_TASK_WDT 1
#define CONFIG_ESP_TASK_WDT_TIMEOUT_S 5
#define CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU0 1
#define CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU1 1
#define CONFIG_ESP_MAC_ADDR_UNIVERSE_WIFI_STA 1
#define CONFIG_ESP_MAC_ADDR_UNIVERSE_WIFI_AP 1
#define CONFIG_ESP_MAC_ADDR_UNIVERSE_BT 1
#define CONFIG_ESP_MAC_ADDR_UNIVERSE_BT_OFFSET 2
#define CONFIG_ESP_MAC_ADDR_UNIVERSE_ETH 1
#define CONFIG_ETH_ENABLED 1
#define CONFIG_ETH_USE_ESP32_EMAC 1
#define CONFIG_ETH_PHY_INTERFACE_RMII 1
#define CONFIG_ETH_RMII_CLK_INPUT 1
#define CONFIG_ETH_RMII_CLK_IN_GPIO 0
#define CONFIG_ETH_DMA_BUFFER_SIZE 512
#define CONFIG_ETH_DMA_RX_BUFFER_NUM 10
#define CONFIG_ETH_DMA_TX_BUFFER_NUM 10
#define CONFIG_ETH_USE_SPI_ETHERNET 1
#define CONFIG_ESP_EVENT_POST_FROM_ISR 1
#define CONFIG_ESP_EVENT_POST_FROM_IRAM_ISR 1
#define CONFIG_ESP_HTTP_CLIENT_ENABLE_HTTPS 1
#define CONFIG_HTTPD_MAX_REQ_HDR_LEN 1024
#define CONFIG_HTTPD_MAX_URI_LEN 512
#define CONFIG_HTTPD_ERR_RESP_NO_DELAY 1
#define CONFIG_HTTPD_PURGE_BUF_LEN 32
#define CONFIG_ESP_NETIF_IP_LOST_TIMER_INTERVAL 120
#define CONFIG_ESP_NETIF_TCPIP_LWIP 1
#define CONFIG_ESP_NETIF_TCPIP_ADAPTER_COMPATIBLE_LAYER 1
#define CONFIG_ESP_SYSTEM_PANIC_PRINT_REBOOT 1
#define CONFIG_ESP_TIME_FUNCS_USE_RTC_TIMER 1
#define CONFIG_ESP_TIME_FUNCS_USE_ESP_TIMER 1
#define CONFIG_ESP_TIMER_TASK_STACK_SIZE 3584
#define CONFIG_ESP_TIMER_IMPL_TG0_LAC 1
#define CONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM 10
#define CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM 32
#define CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER 1
#define CONFIG_ESP32_WIFI_TX_BUFFER_TYPE 1
#define CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER_NUM 32
#define CONFIG_ESP32_WIFI_AMPDU_TX_ENABLED 1
#define CONFIG_ESP32_WIFI_TX_BA_WIN 6
#define CONFIG_ESP32_WIFI_AMPDU_RX_ENABLED 1
#define CONFIG_ESP32_WIFI_RX_BA_WIN 6
#define CONFIG_ESP32_WIFI_NVS_ENABLED 1
#define CONFIG_ESP32_WIFI_TASK_PINNED_TO_CORE_0 1
#define CONFIG_ESP32_WIFI_SOFTAP_BEACON_MAX_LEN 752
#define CONFIG_ESP32_WIFI_MGMT_SBUF_NUM 32
#define CONFIG_ESP32_WIFI_IRAM_OPT 1
#define CONFIG_ESP32_WIFI_RX_IRAM_OPT 1
#define CONFIG_ESP32_WIFI_ENABLE_WPA3_SAE 1
#define CONFIG_ESP32_PHY_CALIBRATION_AND_DATA_STORAGE 1
#define CONFIG_ESP32_PHY_MAX_WIFI_TX_POWER 20
#define CONFIG_ESP32_PHY_MAX_TX_POWER 20
#define CONFIG_ESP_COREDUMP_ENABLE_TO_NONE 1
#define CONFIG_FATFS_CODEPAGE_437 1
#define CONFIG_FATFS_CODEPAGE 437
#define CONFIG_FATFS_LFN_NONE 1
#define CONFIG_FATFS_FS_LOCK 0
#define CONFIG_FATFS_TIMEOUT_MS 10000
#define CONFIG_FATFS_PER_FILE_CACHE 1
#define CONFIG_FMB_COMM_MODE_TCP_EN 1
#define CONFIG_FMB_TCP_PORT_DEFAULT 502
#define CONFIG_FMB_TCP_PORT_MAX_CONN 5
#define CONFIG_FMB_TCP_CONNECTION_TOUT_SEC 20
#define CONFIG_FMB_COMM_MODE_RTU_EN 1
#define CONFIG_FMB_COMM_MODE_ASCII_EN 1
#define CONFIG_FMB_MASTER_TIMEOUT_MS_RESPOND 2000
#define CONFIG_FMB_MASTER_DELAY_MS_CONVERT 200
#define CONFIG_FMB_QUEUE_LENGTH 20
#define CONFIG_FMB_PORT_TASK_STACK_SIZE 4096
#define CONFIG_FMB_SERIAL_BUF_SIZE 256
#define CONFIG_FMB_SERIAL_ASCII_BITS_PER_SYMB 8
#define CONFIG_FMB_SERIAL_ASCII_TIMEOUT_RESPOND_MS 1000
#define CONFIG_FMB_PORT_TASK_PRIO 5
#define CONFIG_FMB_CONTROLLER_NOTIFY_TIMEOUT 20
#define CONFIG_FMB_CONTROLLER_NOTIFY_QUEUE_SIZE 20
#define CONFIG_FMB_CONTROLLER_STACK_SIZE 4096
#define CONFIG_FMB_EVENT_QUEUE_TIMEOUT 500
#define CONFIG_FMB_TIMER_PORT_ENABLED 1
#define CONFIG_FMB_TIMER_GROUP 0
#define CONFIG_FMB_TIMER_INDEX 0
#define CONFIG_FREERTOS_NO_AFFINITY 0x7FFFFFFF
#define CONFIG_FREERTOS_CORETIMER_0 1
#define CONFIG_FREERTOS_HZ 100
#define CONFIG_FREERTOS_ASSERT_ON_UNTESTED_FUNCTION 1
#define CONFIG_FREERTOS_CHECK_STACKOVERFLOW_CANARY 1
#define CONFIG_FREERTOS_INTERRUPT_BACKTRACE 1
#define CONFIG_FREERTOS_THREAD_LOCAL_STORAGE_POINTERS 1
#define CONFIG_FREERTOS_ASSERT_FAIL_ABORT 1
#define CONFIG_FREERTOS_IDLE_TASK_STACKSIZE 1536
#define CONFIG_FREERTOS_ISR_STACKSIZE 1536
#define CONFIG_FREERTOS_MAX_TASK_NAME_LEN 16
#define CONFIG_FREERTOS_SUPPORT_STATIC_ALLOCATION 1
#define CONFIG_FREERTOS_TIMER_TASK_PRIORITY 1
#define CONFIG_FREERTOS_TIMER_TASK_STACK_DEPTH 2048
#define CONFIG_FREERTOS_TIMER_QUEUE_LENGTH 10
#define CONFIG_FREERTOS_QUEUE_REGISTRY_SIZE 0
#define CONFIG_FREERTOS_TASK_FUNCTION_WRAPPER 1
#define CONFIG_FREERTOS_CHECK_MUTEX_GIVEN_BY_OWNER 1
#define CONFIG_FREERTOS_DEBUG_OCDAWARE 1
#define CONFIG_HEAP_POISONING_DISABLED 1
#define CONFIG_HEAP_TRACING_OFF 1
#define CONFIG_LOG_DEFAULT_LEVEL_INFO 1
#define CONFIG_LOG_DEFAULT_LEVEL 3
#define CONFIG_LOG_COLORS 1
#define CONFIG_LOG_TIMESTAMP_SOURCE_RTOS 1
#define CONFIG_LWIP_LOCAL_HOSTNAME "espressif"
#define CONFIG_LWIP_DNS_SUPPORT_MDNS_QUERIES 1
#define CONFIG_LWIP_TIMERS_ONDEMAND 1
#define CONFIG_LWIP_MAX_SOCKETS 10
#define CONFIG_LWIP_SO_REUSE 1
#define CONFIG_LWIP_SO_REUSE_RXTOALL 1
#define CONFIG_LWIP_IP4_FRAG 1
#define CONFIG_LWIP_IP6_FRAG 1
#define CONFIG_LWIP_ESP_GRATUITOUS_ARP 1
#define CONFIG_LWIP_GARP_TMR_INTERVAL 60
#define CONFIG_LWIP_TCPIP_RECVMBOX_SIZE 32
#define CONFIG_LWIP_DHCP_DOES_ARP_CHECK 1
#define CONFIG_LWIP_DHCPS_LEASE_UNIT 60
#define CONFIG_LWIP_DHCPS_MAX_STATION_NUM 8
#define CONFIG_LWIP_NETIF_LOOPBACK 1
#define CONFIG_LWIP_LOOPBACK_MAX_PBUFS 8
#define CONFIG_LWIP_MAX_ACTIVE_TCP 16
#define CONFIG_LWIP_MAX_LISTENING_TCP 16
#define CONFIG_LWIP_TCP_HIGH_SPEED_RETRANSMISSION 1
#define CONFIG_LWIP_TCP_MAXRTX 12
#define CONFIG_LWIP_TCP_SYNMAXRTX 6
#define CONFIG_LWIP_TCP_MSS 1440
#define CONFIG_LWIP_TCP_TMR_INTERVAL 250
#define CONFIG_LWIP_TCP_MSL 60000
#define CONFIG_LWIP_TCP_SND_BUF_DEFAULT 5744
#define CONFIG_LWIP_TCP_WND_DEFAULT 5744
#define CONFIG_LWIP_TCP_RECVMBOX_SIZE 6
#define CONFIG_LWIP_TCP_QUEUE_OOSEQ 1
#define CONFIG_LWIP_TCP_OVERSIZE_MSS 1
#define CONFIG_LWIP_TCP_RTO_TIME 1500
#define CONFIG_LWIP_MAX_UDP_PCBS 16
#define CONFIG_LWIP_UDP_RECVMBOX_SIZE 6
#define CONFIG_LWIP_CHECKSUM_CHECK_ICMP 1
#define CONFIG_LWIP_TCPIP_TASK_STACK_SIZE 3072
#define CONFIG_LWIP_TCPIP_TASK_AFFINITY_NO_AFFINITY 1
#define CONFIG_LWIP_TCPIP_TASK_AFFINITY 0x7FFFFFFF
#define CONFIG_LWIP_IPV6_MEMP_NUM_ND6_QUEUE 3
#define CONFIG_LWIP_IPV6_ND6_NUM_NEIGHBORS 5
#define CONFIG_LWIP_MAX_RAW_PCBS 16
#define CONFIG_LWIP_DHCP_MAX_NTP_SERVERS 1
#define CONFIG_LWIP_SNTP_UPDATE_DELAY 3600000
#define CONFIG_LWIP_ESP_LWIP_ASSERT 1
#define CONFIG_LWIP_HOOK_TCP_ISN_DEFAULT 1
#define CONFIG_LWIP_HOOK_IP6_ROUTE_NONE 1
#define CONFIG_LWIP_HOOK_NETCONN_EXT_RESOLVE_NONE 1
#define CONFIG_MBEDTLS_INTERNAL_MEM_ALLOC 1
#define CONFIG_MBEDTLS_ASYMMETRIC_CONTENT_LEN 1
#define CONFIG_MBEDTLS_SSL_IN_CONTENT_LEN 16384
#define CONFIG_MBEDTLS_SSL_OUT_CONTENT_LEN 4096
#define CONFIG_MBEDTLS_CERTIFICATE_BUNDLE 1
#define CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_FULL 1
#define CONFIG_MBEDTLS_HARDWARE_AES 1
#define CONFIG_MBEDTLS_HARDWARE_MPI 1
#define CONFIG_MBEDTLS_HARDWARE_SHA 1
#define CONFIG_MBEDTLS_HAVE_TIME 1
#define CONFIG_MBEDTLS_ECDSA_DETERMINISTIC 1
#define CONFIG_MBEDTLS_SHA512_C 1
#define CONFIG_MBEDTLS_TLS_SERVER_AND_CLIENT 1
#define CONFIG_MBEDTLS_TLS_SERVER 1
#define CONFIG_MBEDTLS_TLS_CLIENT 1
#define CONFIG_MBEDTLS_TLS_ENABLED 1
#define CONFIG_MBEDTLS_KEY_EXCHANGE_RSA 1
#define CONFIG_MBEDTLS_KEY_EXCHANGE_DHE_RSA 1
#define CONFIG_MBEDTLS_KEY_EXCHANGE_ELLIPTIC_CURVE 1
#define CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_RSA 1
#define CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA 1
#define CONFIG_MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA 1
#define CONFIG_MBEDTLS_KEY_EXCHANGE_ECDH_RSA 1
#define CONFIG_MBEDTLS_SSL_RENEGOTIATION 1
#define CONFIG_MBEDTLS_SSL_PROTO_TLS1 1
#define CONFIG_MBEDTLS_SSL_PROTO_TLS1_1 1
#define CONFIG_MBEDTLS_SSL_PROTO_TLS1_2 1
#define CONFIG_MBEDTLS_SSL_ALPN 1
#define CONFIG_MBEDTLS_CLIENT_SSL_SESSION_TICKETS 1
#define CONFIG_MBEDTLS_SERVER_SSL_SESSION_TICKETS 1
#define CONFIG_MBEDTLS_AES_C 1
#define CONFIG_MBEDTLS_RC4_DISABLED 1
#define CONFIG_MBEDTLS_CCM_C 1
#define CONFIG_MBEDTLS_GCM_C 1
#define CONFIG_MBEDTLS_PEM_PARSE_C 1
#define CONFIG_MBEDTLS_PEM_WRITE_C 1
#define CONFIG_MBEDTLS_X509_CRL_PARSE_C 1
#define CONFIG_MBEDTLS_X509_CSR_PARSE_C 1
#define CONFIG_MBEDTLS_ECP_C 1
#define CONFIG_MBEDTLS_ECDH_C 1
#define CONFIG_MBEDTLS_ECDSA_C 1
#define CONFIG_MBEDTLS_ECP_DP_SECP192R1_ENABLED 1
#define CONFIG_MBEDTLS_ECP_DP_SECP224R1_ENABLED 1
#define CONFIG_MBEDTLS_ECP_DP_SECP256R1_ENABLED 1
#define CONFIG_MBEDTLS_ECP_DP_SECP384R1_ENABLED 1
#define CONFIG_MBEDTLS_ECP_DP_SECP521R1_ENABLED 1
#define CONFIG_MBEDTLS_ECP_DP_SECP192K1_ENABLED 1
#define CONFIG_MBEDTLS_ECP_DP_SECP224K1_ENABLED 1
#define CONFIG_MBEDTLS_ECP_DP_SECP256K1_ENABLED 1
#define CONFIG_MBEDTLS_ECP_DP_BP256R1_ENABLED 1
#define CONFIG_MBEDTLS_ECP_DP_BP384R1_ENABLED 1
#define CONFIG_MBEDTLS_ECP_DP_BP512R1_ENABLED 1
#define CONFIG_MBEDTLS_ECP_DP_CURVE25519_ENABLED 1
#define CONFIG_MBEDTLS_ECP_NIST_OPTIM 1
#define CONFIG_MDNS_MAX_SERVICES 10
#define CONFIG_MDNS_TASK_PRIORITY 1
#define CONFIG_MDNS_TASK_STACK_SIZE 4096
#define CONFIG_MDNS_TASK_AFFINITY_CPU0 1
#define CONFIG_MDNS_TASK_AFFINITY 0x0
#define CONFIG_MDNS_SERVICE_ADD_TIMEOUT_MS 2000
#define CONFIG_MDNS_TIMER_PERIOD_MS 100
#define CONFIG_MQTT_PROTOCOL_311 1
#define CONFIG_MQTT_TRANSPORT_SSL 1
#define CONFIG_MQTT_TRANSPORT_WEBSOCKET 1
#define CONFIG_MQTT_TRANSPORT_WEBSOCKET_SECURE 1
#define CONFIG_NEWLIB_STDOUT_LINE_ENDING_CRLF 1
#define CONFIG_NEWLIB_STDIN_LINE_ENDING_CR 1
#define CONFIG_OPENSSL_ERROR_STACK 1
#define CONFIG_OPENSSL_ASSERT_EXIT 1
#define CONFIG_PTHREAD_TASK_PRIO_DEFAULT 5
#define CONFIG_PTHREAD_TASK_STACK_SIZE_DEFAULT 3072
#define CONFIG_PTHREAD_STACK_MIN 768
#define CONFIG_PTHREAD_DEFAULT_CORE_NO_AFFINITY 1
#define CONFIG_PTHREAD_TASK_CORE_DEFAULT -1
#define CONFIG_PTHREAD_TASK_NAME_DEFAULT "pthread"
#define CONFIG_SPI_FLASH_ROM_DRIVER_PATCH 1
#define CONFIG_SPI_FLASH_DANGEROUS_WRITE_ABORTS 1
#define CONFIG_SPI_FLASH_YIELD_DURING_ERASE 1
#define CONFIG_SPI_FLASH_ERASE_YIELD_DURATION_MS 20
#define CONFIG_SPI_FLASH_ERASE_YIELD_TICKS 1
#define CONFIG_SPI_FLASH_WRITE_CHUNK_SIZE 8192
#define CONFIG_SPI_FLASH_SUPPORT_ISSI_CHIP 1
#define CONFIG_SPI_FLASH_SUPPORT_MXIC_CHIP 1
#define CONFIG_SPI_FLASH_SUPPORT_GD_CHIP 1
#define CONFIG_SPI_FLASH_SUPPORT_WINBOND_CHIP 1
#define CONFIG_SPIFFS_MAX_PARTITIONS 3
#define CONFIG_SPIFFS_CACHE 1
#define CONFIG_SPIFFS_CACHE_WR 1
#define CONFIG_SPIFFS_PAGE_CHECK 1
#define CONFIG_SPIFFS_GC_MAX_RUNS 10
#define CONFIG_SPIFFS_PAGE_SIZE 256
#define CONFIG_SPIFFS_OBJ_NAME_LEN 32
#define CONFIG_SPIFFS_USE_MAGIC 1
#define CONFIG_SPIFFS_USE_MAGIC_LENGTH 1
#define CONFIG_SPIFFS_META_LENGTH 4
#define CONFIG_SPIFFS_USE_MTIME 1
#define CONFIG_WS_BUFFER_SIZE 1024
#define CONFIG_UNITY_ENABLE_FLOAT 1
#define CONFIG_UNITY_ENABLE_DOUBLE 1
#define CONFIG_UNITY_ENABLE_IDF_TEST_RUNNER 1
#define CONFIG_VFS_SUPPORT_IO 1
#define CONFIG_VFS_SUPPORT_DIR 1
#define CONFIG_VFS_SUPPORT_SELECT 1
#define CONFIG_VFS_SUPPRESS_SELECT_DEBUG_OUTPUT 1
#define CONFIG_VFS_SUPPORT_TERMIOS 1
#define CONFIG_VFS_SEMIHOSTFS_MAX_MOUNT_POINTS 1
#define CONFIG_VFS_SEMIHOSTFS_HOST_PATH_MAX_LEN 128
#define CONFIG_WL_SECTOR_SIZE_4096 1
#define CONFIG_WL_SECTOR_SIZE 4096
#define CONFIG_WIFI_PROV_SCAN_MAX_ENTRIES 16
#define CONFIG_WIFI_PROV_AUTOSTOP_TIMEOUT 30
#define CONFIG_WPA_MBEDTLS_CRYPTO 1

/* List of deprecated options */
#define CONFIG_ADC2_DISABLE_DAC CONFIG_ADC_DISABLE_DAC
#define CONFIG_BROWNOUT_DET CONFIG_ESP32_BROWNOUT_DET
#define CONFIG_BROWNOUT_DET_LVL_SEL_0 CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_0
#define CONFIG_COMPILER_OPTIMIZATION_LEVEL_DEBUG CONFIG_COMPILER_OPTIMIZATION_DEFAULT
#define CONFIG_CONSOLE_UART_DEFAULT CONFIG_ESP_CONSOLE_UART_DEFAULT
#define CONFIG_ESP32S2_PANIC_PRINT_REBOOT CONFIG_ESP_SYSTEM_PANIC_PRINT_REBOOT
#define CONFIG_ESP32_APPTRACE_DEST_NONE CONFIG_APPTRACE_DEST_NONE
#define CONFIG_ESP32_DEFAULT_PTHREAD_CORE_NO_AFFINITY CONFIG_PTHREAD_DEFAULT_CORE_NO_AFFINITY
#define CONFIG_ESP32_ENABLE_COREDUMP_TO_NONE CONFIG_ESP_COREDUMP_ENABLE_TO_NONE
#define CONFIG_ESP32_PANIC_PRINT_REBOOT CONFIG_ESP_SYSTEM_PANIC_PRINT_REBOOT
#define CONFIG_ESP32_PTHREAD_STACK_MIN CONFIG_PTHREAD_STACK_MIN
#define CONFIG_ESP32_PTHREAD_TASK_NAME_DEFAULT CONFIG_PTHREAD_TASK_NAME_DEFAULT
#define CONFIG_ESP32_PTHREAD_TASK_PRIO_DEFAULT CONFIG_PTHREAD_TASK_PRIO_DEFAULT
#define CONFIG_ESP32_PTHREAD_TASK_STACK_SIZE_DEFAULT CONFIG_PTHREAD_TASK_STACK_SIZE_DEFAULT
#define CONFIG_ESP32_RTC_CLOCK_SOURCE_INTERNAL_RC CONFIG_ESP32_RTC_CLK_SRC_INT_RC
#define CONFIG_ESP_GRATUITOUS_ARP CONFIG_LWIP_ESP_GRATUITOUS_ARP
#define CONFIG_FLASHMODE_DIO CONFIG_ESPTOOLPY_FLASHMODE_DIO
#define CONFIG_FOUR_UNIVERSAL_MAC_ADDRESS CONFIG_ESP32_UNIVERSAL_MAC_ADDRESSES_FOUR
#define CONFIG_GARP_TMR_INTERVAL CONFIG_LWIP_GARP_TMR_INTERVAL
#define CONFIG_INT_WDT CONFIG_ESP_INT_WDT
#define CONFIG_INT_WDT_CHECK_CPU1 CONFIG_ESP_INT_WDT_CHECK_CPU1
#define CONFIG_INT_WDT_TIMEOUT_MS CONFIG_ESP_INT_WDT_TIMEOUT_MS
#define CONFIG_IPC_TASK_STACK_SIZE CONFIG_ESP_IPC_TASK_STACK_SIZE
#define CONFIG_LOG_BOOTLOADER_LEVEL_INFO CONFIG_BOOTLOADER_LOG_LEVEL_INFO
#define CONFIG_MAIN_TASK_STACK_SIZE CONFIG_ESP_MAIN_TASK_STACK_SIZE
#define CONFIG_MB_CONTROLLER_NOTIFY_QUEUE_SIZE CONFIG_FMB_CONTROLLER_NOTIFY_QUEUE_SIZE
#define CONFIG_MB_CONTROLLER_NOTIFY_TIMEOUT CONFIG_FMB_CONTROLLER_NOTIFY_TIMEOUT
#define CONFIG_MB_CONTROLLER_STACK_SIZE CONFIG_FMB_CONTROLLER_STACK_SIZE
#define CONFIG_MB_EVENT_QUEUE_TIMEOUT CONFIG_FMB_EVENT_QUEUE_TIMEOUT
#define CONFIG_MB_MASTER_DELAY_MS_CONVERT CONFIG_FMB_MASTER_DELAY_MS_CONVERT
#define CONFIG_MB_MASTER_TIMEOUT_MS_RESPOND CONFIG_FMB_MASTER_TIMEOUT_MS_RESPOND
#define CONFIG_MB_QUEUE_LENGTH CONFIG_FMB_QUEUE_LENGTH
#define CONFIG_MB_SERIAL_BUF_SIZE CONFIG_FMB_SERIAL_BUF_SIZE
#define CONFIG_MB_SERIAL_TASK_PRIO CONFIG_FMB_PORT_TASK_PRIO
#define CONFIG_MB_SERIAL_TASK_STACK_SIZE CONFIG_FMB_PORT_TASK_STACK_SIZE
#define CONFIG_MB_TIMER_GROUP CONFIG_FMB_TIMER_GROUP
#define CONFIG_MB_TIMER_INDEX CONFIG_FMB_TIMER_INDEX
#define CONFIG_MB_TIMER_PORT_ENABLED CONFIG_FMB_TIMER_PORT_ENABLED
#define CONFIG_MONITOR_BAUD_115200B CONFIG_ESPTOOLPY_MONITOR_BAUD_115200B
#define CONFIG_OPTIMIZATION_ASSERTIONS_ENABLED CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_ENABLE
#define CONFIG_OPTIMIZATION_LEVEL_DEBUG CONFIG_COMPILER_OPTIMIZATION_DEFAULT
#define CONFIG_POST_EVENTS_FROM_IRAM_ISR CONFIG_ESP_EVENT_POST_FROM_IRAM_ISR
#define CONFIG_POST_EVENTS_FROM_ISR CONFIG_ESP_EVENT_POST_FROM_ISR
#define CONFIG_REDUCE_PHY_TX_POWER CONFIG_ESP32_REDUCE_PHY_TX_POWER
#define CONFIG_SEMIHOSTFS_HOST_PATH_MAX_LEN CONFIG_VFS_SEMIHOSTFS_HOST_PATH_MAX_LEN
#define CONFIG_SEMIHOSTFS_MAX_MOUNT_POINTS CONFIG_VFS_SEMIHOSTFS_MAX_MOUNT_POINTS
#define CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_ABORTS CONFIG_SPI_FLASH_DANGEROUS_WRITE_ABORTS
#define CONFIG_STACK_CHECK_NONE CONFIG_COMPILER_STACK_CHECK_MODE_NONE
#define CONFIG_SUPPORT_TERMIOS CONFIG_VFS_SUPPORT_TERMIOS
#define CONFIG_SUPPRESS_SELECT_DEBUG_OUTPUT CONFIG_VFS_SUPPRESS_SELECT_DEBUG_OUTPUT
#define CONFIG_SYSTEM_EVENT_QUEUE_SIZE CONFIG_ESP_SYSTEM_EVENT_QUEUE_SIZE
#define CONFIG_SYSTEM_EVENT_TASK_STACK_SIZE CONFIG_ESP_SYSTEM_EVENT_TASK_STACK_SIZE
#define CONFIG_TASK_WDT CONFIG_ESP_TASK_WDT
#define CONFIG_TASK_WDT_CHECK_IDLE_TASK_CPU0 CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU0
#define CONFIG_TASK_WDT_CHECK_IDLE_TASK_CPU1 CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU1
#define CONFIG_TASK_WDT_TIMEOUT_S CONFIG_ESP_TASK_WDT_TIMEOUT_S
#define CONFIG_TCPIP_RECVMBOX_SIZE CONFIG_LWIP_TCPIP_RECVMBOX_SIZE
#define CONFIG_TCPIP_TASK_AFFINITY_NO_AFFINITY CONFIG_LWIP_TCPIP_TASK_AFFINITY_NO_AFFINITY
#define CONFIG_TCPIP_TASK_STACK_SIZE CONFIG_LWIP_TCPIP_TASK_STACK_SIZE
#define CONFIG_TCP_MAXRTX CONFIG_LWIP_TCP_MAXRTX
#define CONFIG_TCP_MSL CONFIG_LWIP_TCP_MSL
#define CONFIG_TCP_MSS CONFIG_LWIP_TCP_MSS
#define CONFIG_TCP_OVERSIZE_MSS CONFIG_LWIP_TCP_OVERSIZE_MSS
#define CONFIG_TCP_QUEUE_OOSEQ CONFIG_LWIP_TCP_QUEUE_OOSEQ
#define CONFIG_TCP_RECVMBOX_SIZE CONFIG_LWIP_TCP_RECVMBOX_SIZE
#define CONFIG_TCP_SND_BUF_DEFAULT CONFIG_LWIP_TCP_SND_BUF_DEFAULT
#define CONFIG_TCP_SYNMAXRTX CONFIG_LWIP_TCP_SYNMAXRTX
#define CONFIG_TCP_WND_DEFAULT CONFIG_LWIP_TCP_WND_DEFAULT
#define CONFIG_TIMER_QUEUE_LENGTH CONFIG_FREERTOS_TIMER_QUEUE_LENGTH
#define CONFIG_TIMER_TASK_PRIORITY CONFIG_FREERTOS_TIMER_TASK_PRIORITY
#define CONFIG_TIMER_TASK_STACK_DEPTH CONFIG_FREERTOS_TIMER_TASK_STACK_DEPTH
#define CONFIG_TIMER_TASK_STACK_SIZE CONFIG_ESP_TIMER_TASK_STACK_SIZE
#define CONFIG_TOOLPREFIX CONFIG_SDK_TOOLPREFIX
#define CONFIG_UDP_RECVMBOX_SIZE CONFIG_LWIP_UDP_RECVMBOX_SIZE

main.c

// Copyright 2016-2019 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include "string.h"
#include "esp_log.h"
#include "esp_wifi.h"
#include "esp_event.h"
#include "nvs_flash.h"
#include "esp_netif.h"
#include "esp_bit_defs.h"

#include "mbcontroller.h"
#include "sdkconfig.h"
#define CONFIG_EXAMPLE_WIFI_SSID "CONFIG_EXAMPLE_WIFI_SSID"
#define CONFIG_EXAMPLE_WIFI_PASSWORD "CONFIG_EXAMPLE_WIFI_PASSWORD"
#ifndef _DEVICE_PARAMS
#define _DEVICE_PARAMS

// This file defines structure of modbus parameters which reflect correspond modbus address space
// for each modbus register type (coils, discreet inputs, holding registers, input registers)
#pragma pack(push, 1)
typedef struct
{
    uint8_t discrete_input0:1;
    uint8_t discrete_input1:1;
    uint8_t discrete_input2:1;
    uint8_t discrete_input3:1;
    uint8_t discrete_input4:1;
    uint8_t discrete_input5:1;
    uint8_t discrete_input6:1;
    uint8_t discrete_input7:1;
    uint8_t discrete_input_port1:8;
} discrete_reg_params_t;
#pragma pack(pop)

#pragma pack(push, 1)
typedef struct
{
    uint8_t coils_port0;
    uint8_t coils_port1;
} coil_reg_params_t;
#pragma pack(pop)

#pragma pack(push, 1)
typedef struct
{
    float input_data0;
    float input_data1;
    float input_data2;
    float input_data3;
    uint16_t data[150];
} input_reg_params_t;
#pragma pack(pop)

#pragma pack(push, 1)
typedef struct
{
    float holding_data0;
    float holding_data1;
    float holding_data2;
    float holding_data3;
    uint16_t test_regs[150];
} holding_reg_params_t;
#pragma pack(pop)

extern holding_reg_params_t holding_reg_params;
extern input_reg_params_t input_reg_params;
extern coil_reg_params_t coil_reg_params;
extern discrete_reg_params_t discrete_reg_params;

#endif // !defined(_DEVICE_PARAMS)
holding_reg_params_t holding_reg_params = { 0 };

input_reg_params_t input_reg_params = { 0 };

coil_reg_params_t coil_reg_params = { 0 };

discrete_reg_params_t discrete_reg_params = { 0 };

#define MB_PORT_NUM     (CONFIG_MB_UART_PORT_NUM)   // Number of UART port used for Modbus connection
#define MB_DEV_SPEED    (CONFIG_MB_UART_BAUD_RATE)  // The communication speed of the UART

// Note: Some pins on target chip cannot be assigned for UART communication.
// See UART documentation for selected board and target to configure pins using Kconfig.

// The number of parameters that intended to be used in the particular control process
#define MASTER_MAX_CIDS num_device_parameters

// Number of reading of parameters from slave
#define MASTER_MAX_RETRY                1000

// Timeout to update cid over Modbus
#define UPDATE_CIDS_TIMEOUT_MS          (500)
#define UPDATE_CIDS_TIMEOUT_TICS        (UPDATE_CIDS_TIMEOUT_MS / portTICK_RATE_MS)

// Timeout between polls
#define POLL_TIMEOUT_MS                 (1)
#define POLL_TIMEOUT_TICS               (POLL_TIMEOUT_MS / portTICK_RATE_MS)

#define MASTER_TAG "MASTER_TEST"

#define MASTER_CHECK(a, ret_val, str, ...) \
    if (!(a)) { \
        ESP_LOGE(MASTER_TAG, "%s(%u): " str, __FUNCTION__, __LINE__, ##__VA_ARGS__); \
        return (ret_val); \
    }

// The macro to get offset for parameter in the appropriate structure
#define HOLD_OFFSET(field) ((uint16_t)(offsetof(holding_reg_params_t, field) + 1))
#define INPUT_OFFSET(field) ((uint16_t)(offsetof(input_reg_params_t, field) + 1))
#define COIL_OFFSET(field) ((uint16_t)(offsetof(coil_reg_params_t, field) + 1))
// Discrete offset macro
#define DISCR_OFFSET(field) ((uint16_t)(offsetof(discrete_reg_params_t, field) + 1))

#define STR(fieldname) ((const char*)( fieldname ))
// Options can be used as bit masks or parameter limits
#define OPTS(min_val, max_val, step_val) { .opt1 = min_val, .opt2 = max_val, .opt3 = step_val }

// Enumeration of modbus device addresses accessed by master device
enum {
    MB_DEVICE_ADDR1 = 1 // Only one slave device used for the test (add other slave addresses here)
};

// Enumeration of all supported CIDs for device (used in parameter definition table)
enum {
    CID_INP_DATA_0 = 0,
    CID_HOLD_DATA_0,
    CID_INP_DATA_1,
    CID_HOLD_DATA_1,
    CID_INP_DATA_2,
    CID_HOLD_DATA_2,
    CID_HOLD_TEST_REG,
    CID_RELAY_P1,
    CID_RELAY_P2,
    CID_COUNT
};

// Example Data (Object) Dictionary for Modbus parameters:
// The CID field in the table must be unique.
// Modbus Slave Addr field defines slave address of the device with correspond parameter.
// Modbus Reg Type - Type of Modbus register area (Holding register, Input Register and such).
// Reg Start field defines the start Modbus register number and Reg Size defines the number of registers for the characteristic accordingly.
// The Instance Offset defines offset in the appropriate parameter structure that will be used as instance to save parameter value.
// Data Type, Data Size specify type of the characteristic and its data size.
// Parameter Options field specifies the options that can be used to process parameter value (limits or masks).
// Access Mode - can be used to implement custom options for processing of characteristic (Read/Write restrictions, factory mode values and etc).
const mb_parameter_descriptor_t device_parameters[] = {
    // { CID, Param Name, Units, Modbus Slave Addr, Modbus Reg Type, Reg Start, Reg Size, Instance Offset, Data Type, Data Size, Parameter Options, Access Mode}
    { CID_INP_DATA_0, STR("Data_channel_0"), STR("Volts"), MB_DEVICE_ADDR1, MB_PARAM_INPUT, 0, 2,
                    INPUT_OFFSET(input_data0), PARAM_TYPE_FLOAT, 4, OPTS( -10, 10, 1 ), PAR_PERMS_READ_WRITE_TRIGGER },
    { CID_HOLD_DATA_0, STR("Humidity_1"), STR("%rH"), MB_DEVICE_ADDR1, MB_PARAM_HOLDING, 0, 2,
            HOLD_OFFSET(holding_data0), PARAM_TYPE_FLOAT, 4, OPTS( 0, 100, 1 ), PAR_PERMS_READ_WRITE_TRIGGER },
    { CID_INP_DATA_1, STR("Temperature_1"), STR("C"), MB_DEVICE_ADDR1, MB_PARAM_INPUT, 2, 2,
            INPUT_OFFSET(input_data1), PARAM_TYPE_FLOAT, 4, OPTS( -40, 100, 1 ), PAR_PERMS_READ_WRITE_TRIGGER },
    { CID_HOLD_DATA_1, STR("Humidity_2"), STR("%rH"), MB_DEVICE_ADDR1, MB_PARAM_HOLDING, 2, 2,
            HOLD_OFFSET(holding_data1), PARAM_TYPE_FLOAT, 4, OPTS( 0, 100, 1 ), PAR_PERMS_READ_WRITE_TRIGGER },
    { CID_INP_DATA_2, STR("Temperature_2"), STR("C"), MB_DEVICE_ADDR1, MB_PARAM_INPUT, 4, 2,
            INPUT_OFFSET(input_data2), PARAM_TYPE_FLOAT, 4, OPTS( -40, 100, 1 ), PAR_PERMS_READ_WRITE_TRIGGER },
    { CID_HOLD_DATA_2, STR("Humidity_3"), STR("%rH"), MB_DEVICE_ADDR1, MB_PARAM_HOLDING, 4, 2,
            HOLD_OFFSET(holding_data2), PARAM_TYPE_FLOAT, 4, OPTS( 0, 100, 1 ), PAR_PERMS_READ_WRITE_TRIGGER },

     { CID_HOLD_TEST_REG, STR("Humidity_3"), STR("%rH"), MB_DEVICE_ADDR1, MB_PARAM_HOLDING, 4, 2,
            HOLD_OFFSET(holding_data2), PARAM_TYPE_FLOAT, 4, OPTS( 0, 100, 1 ), PAR_PERMS_READ_WRITE_TRIGGER },

    { CID_RELAY_P1, STR("RelayP1"), STR("on/off"), MB_DEVICE_ADDR1, MB_PARAM_COIL, 0, 8,
            COIL_OFFSET(coils_port0), PARAM_TYPE_U16, 2, OPTS( BIT1, 0, 0 ), PAR_PERMS_READ_WRITE_TRIGGER },
    { CID_RELAY_P2, STR("RelayP2"), STR("on/off"), MB_DEVICE_ADDR1, MB_PARAM_COIL, 8, 8,
            COIL_OFFSET(coils_port1), PARAM_TYPE_U16, 2, OPTS( BIT0, 0, 0 ), PAR_PERMS_READ_WRITE_TRIGGER }
};

// Calculate number of parameters in the table
const uint16_t num_device_parameters = (sizeof(device_parameters)/sizeof(device_parameters[0]));

// The function to get pointer to parameter storage (instance) according to parameter description table
static void* master_get_param_data(const mb_parameter_descriptor_t* param_descriptor)
{
    assert(param_descriptor != NULL);
    void* instance_ptr = NULL;
    if (param_descriptor->param_offset != 0) {
       switch(param_descriptor->mb_param_type)
       {
           case MB_PARAM_HOLDING:
               instance_ptr = ((void*)&holding_reg_params + param_descriptor->param_offset - 1);
               break;
           case MB_PARAM_INPUT:
               instance_ptr = ((void*)&input_reg_params + param_descriptor->param_offset - 1);
               break;
           case MB_PARAM_COIL:
               instance_ptr = ((void*)&coil_reg_params + param_descriptor->param_offset - 1);
               break;
           case MB_PARAM_DISCRETE:
               instance_ptr = ((void*)&discrete_reg_params + param_descriptor->param_offset - 1);
               break;
           default:
               instance_ptr = NULL;
               break;
       }
    } else {
        ESP_LOGE(MASTER_TAG, "Wrong parameter offset for CID #%d", param_descriptor->cid);
        assert(instance_ptr != NULL);
    }
    return instance_ptr;
}

// User operation function to read slave values and check alarm
static void master_operation_func(void *arg)
{
    esp_err_t err = ESP_OK;
    float value = 0;
    bool alarm_state = false;
    const mb_parameter_descriptor_t* param_descriptor = NULL;

    ESP_LOGI(MASTER_TAG, "Start modbus test...");

    while (true)
    {
       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++)
        {
            // Get data from parameters description table
            // and use this information to fill the characteristics description table
            // and having all required fields in just one table
            err = mbc_master_get_cid_info(cid, &param_descriptor);
            if ((err != ESP_ERR_NOT_FOUND) && (param_descriptor != NULL)) {
                void* temp_data_ptr = master_get_param_data(param_descriptor);
                assert(temp_data_ptr);
                uint8_t type = 0;
                if ((param_descriptor->param_type == PARAM_TYPE_ASCII) &&
                        (param_descriptor->cid == CID_HOLD_TEST_REG)) {
                   // Check for long array of registers of type PARAM_TYPE_ASCII
                    err = mbc_master_get_parameter(cid, (char*)param_descriptor->param_key,
                                                                            (uint8_t*)temp_data_ptr, &type);
                    if (err == ESP_OK) {
                        ESP_LOGI(MASTER_TAG, "Characteristic #%d %s (%s) value = (0x%08x) read successful.",
                                                 param_descriptor->cid,
                                                 (char*)param_descriptor->param_key,
                                                 (char*)param_descriptor->param_units,
                                                 *(uint32_t*)temp_data_ptr);
                        // Initialize data of test array and write to slave
                        if (*(uint32_t*)temp_data_ptr != 0xAAAAAAAA) {
                            memset((void*)temp_data_ptr, 0xAA, param_descriptor->param_size);
                            *(uint32_t*)temp_data_ptr = 0xAAAAAAAA;
                            err = mbc_master_set_parameter(cid, (char*)param_descriptor->param_key,
                                                              (uint8_t*)temp_data_ptr, &type);
                            if (err == ESP_OK) {
                                ESP_LOGI(MASTER_TAG, "Characteristic #%d %s (%s) value = (0x%08x), write successful.",
                                                            param_descriptor->cid,
                                                            (char*)param_descriptor->param_key,
                                                            (char*)param_descriptor->param_units,
                                                            *(uint32_t*)temp_data_ptr);
                            } else {
                                ESP_LOGE(MASTER_TAG, "Characteristic #%d (%s) write fail, err = 0x%x (%s).",
                                                        param_descriptor->cid,
                                                        (char*)param_descriptor->param_key,
                                                        (int)err,
                                                        (char*)esp_err_to_name(err));
                            }
                        }
                    } else {
                        ESP_LOGE(MASTER_TAG, "Characteristic #%d (%s) read fail, err = 0x%x (%s).",
                                                param_descriptor->cid,
                                                (char*)param_descriptor->param_key,
                                                (int)err,
                                                (char*)esp_err_to_name(err));
                    }
                } else {
                    err = mbc_master_get_parameter(cid, (char*)param_descriptor->param_key,
                                                        (uint8_t*)&value, &type);
                    if (err == ESP_OK) {
                        *(float*)temp_data_ptr = value;
                        if ((param_descriptor->mb_param_type == MB_PARAM_HOLDING) ||
                            (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_units,
                                            value,
                                            *(uint32_t*)temp_data_ptr);
                            if (((value > param_descriptor->param_opts.max) ||
                                (value < param_descriptor->param_opts.min))) {
                                    alarm_state = true;
                                    break;
                            }
                        } else {
                            uint16_t state = *(uint16_t*)temp_data_ptr;
                            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_units,
                                            (const char*)rw_str,
                                            *(uint16_t*)temp_data_ptr);
                            if (state & param_descriptor->param_opts.opt1) {
                                alarm_state = true;
                                break;
                            }
                        }
                    } else {
                        ESP_LOGE(MASTER_TAG, "Characteristic #%d (%s) read fail, err = 0x%x (%s).",
                                            param_descriptor->cid,
                                            (char*)param_descriptor->param_key,
                                            (int)err,
                                            (char*)esp_err_to_name(err));
                    }
                }

            }
        }

    }
    }

    if (alarm_state) {
        ESP_LOGI(MASTER_TAG, "Alarm triggered by cid #%d.",
                                        param_descriptor->cid);
    } else {
        ESP_LOGE(MASTER_TAG, "Alarm is not triggered after %d retries.",
                                        MASTER_MAX_RETRY);
    }
    ESP_LOGI(MASTER_TAG, "Destroy master...");
    ESP_ERROR_CHECK(mbc_master_destroy());
}

// Modbus master initialization
static esp_err_t master_init(void)
{
    // Initialize and start Modbus controller
    mb_communication_info_t comm = {
            .port = MB_PORT_NUM,
#if CONFIG_MB_COMM_MODE_ASCII
            .mode = MB_MODE_ASCII,
#elif CONFIG_MB_COMM_MODE_RTU
            .mode = MB_MODE_RTU,
#endif
            .baudrate = MB_DEV_SPEED,
            .parity = MB_PARITY_NONE
    };
    void* master_handler = NULL;

    esp_err_t err = mbc_master_init(MB_PORT_SERIAL_MASTER, &master_handler);
    MASTER_CHECK((master_handler != NULL), ESP_ERR_INVALID_STATE,
                                "mb controller initialization fail.");
    MASTER_CHECK((err == ESP_OK), ESP_ERR_INVALID_STATE,
                            "mb controller initialization fail, returns(0x%x).",
                            (uint32_t)err);
    err = mbc_master_setup((void*)&comm);
    MASTER_CHECK((err == ESP_OK), ESP_ERR_INVALID_STATE,
                            "mb controller setup fail, returns(0x%x).",
                            (uint32_t)err);

    // Set UART pin numbers
    err = uart_set_pin(MB_PORT_NUM, CONFIG_MB_UART_TXD, CONFIG_MB_UART_RXD,
                              CONFIG_MB_UART_RTS, UART_PIN_NO_CHANGE);

    err = mbc_master_start();
    MASTER_CHECK((err == ESP_OK), ESP_ERR_INVALID_STATE,
                            "mb controller start fail, returns(0x%x).",
                            (uint32_t)err);

    MASTER_CHECK((err == ESP_OK), ESP_ERR_INVALID_STATE,
            "mb serial set pin failure, uart_set_pin() returned (0x%x).", (uint32_t)err);
    // Set driver mode to Half Duplex
    err = uart_set_mode(MB_PORT_NUM, UART_MODE_RS485_HALF_DUPLEX);
    MASTER_CHECK((err == ESP_OK), ESP_ERR_INVALID_STATE,
            "mb serial set mode failure, uart_set_mode() returned (0x%x).", (uint32_t)err);

    vTaskDelay(5);
    err = mbc_master_set_descriptor(&device_parameters[0], num_device_parameters);
    MASTER_CHECK((err == ESP_OK), ESP_ERR_INVALID_STATE,
                                "mb controller set descriptor fail, returns(0x%x).",
                                (uint32_t)err);
    ESP_LOGI(MASTER_TAG, "Modbus master stack initialized...");
    return err;
}

#include "sdkconfig.h"

EventGroupHandle_t wifi_event_group;
#define CONNECTED_BIT (1 << BIT1)

/*
static esp_err_t wifi_event_handler(void *ctx, system_event_t *event)
{
    switch (event->event_id) {
    case SYSTEM_EVENT_STA_START:
        esp_wifi_connect();
        break;
    case SYSTEM_EVENT_STA_GOT_IP:
        xEventGroupSetBits(wifi_event_group, CONNECTED_BIT);
        // Initialization of device peripheral and objects
        ESP_ERROR_CHECK(master_init());
        xTaskCreate(&master_operation_func, "modbus_task", 16384, NULL, 5, NULL);
        vTaskDelay(300);
        esp_restart();
        vTaskDelay(10);
        break;
    case SYSTEM_EVENT_STA_DISCONNECTED:
        esp_wifi_connect();
        xEventGroupClearBits(wifi_event_group, CONNECTED_BIT);
        break;
    default:
        break;
    }
    return ESP_OK;
}
*/

static esp_ip4_addr_t s_ip_addr;

static bool is_our_netif(const char *prefix, esp_netif_t *netif)
{
    return strncmp(prefix, esp_netif_get_desc(netif), strlen(prefix) - 1) == 0;
}

static void on_got_ip(void *arg, esp_event_base_t event_base,
                      int32_t event_id, void *event_data)
{
    ip_event_got_ip_t *event = (ip_event_got_ip_t *)event_data;
    if (!is_our_netif(MASTER_TAG, event->esp_netif)) {
        ESP_LOGW(MASTER_TAG, "Got IPv4 from another interface \"%s\": ignored", esp_netif_get_desc(event->esp_netif));
        return;
    }
    ESP_LOGI(MASTER_TAG, "Got IPv4 event: Interface \"%s\" address: " IPSTR, esp_netif_get_desc(event->esp_netif), IP2STR(&event->ip_info.ip));
    memcpy(&s_ip_addr, &event->ip_info.ip, sizeof(s_ip_addr));
    xEventGroupSetBits(wifi_event_group, CONNECTED_BIT);

    // Initialization of device peripheral and objects
    ESP_ERROR_CHECK(master_init());
    xTaskCreate(&master_operation_func, "modbus_task", 16384, NULL, 5, NULL);
    vTaskDelay(1000);
    esp_restart();
    vTaskDelay(10);
}

static void on_wifi_disconnect(void *arg, esp_event_base_t event_base,
                               int32_t event_id, void *event_data)
{
    ESP_LOGI(MASTER_TAG, "Wi-Fi disconnected, trying to reconnect...");
    xEventGroupClearBits(wifi_event_group, CONNECTED_BIT);
    esp_err_t err = esp_wifi_connect();
    if (err == ESP_ERR_WIFI_NOT_STARTED) {
        return;
    }
    ESP_ERROR_CHECK(err);
}

static void on_wifi_connect(void *esp_netif, esp_event_base_t event_base,
                            int32_t event_id, void *event_data)
{
    ESP_LOGI(MASTER_TAG, "Wi-Fi connect handler...");
    //esp_wifi_connect();
}

static void on_wifi_start(void *esp_netif, esp_event_base_t event_base,
                            int32_t event_id, void *event_data)
{
    ESP_LOGI(MASTER_TAG, "Wi-Fi start handler...");
    esp_wifi_connect();
}
static void wifi_init(void)
{
    char *desc;
    //tcpip_adapter_init(); // depricated
    esp_netif_init();
    ESP_ERROR_CHECK(esp_event_loop_create_default());
    wifi_event_group = xEventGroupCreate();
    //ESP_ERROR_CHECK(esp_event_loop_init(wifi_event_handler, NULL)); // depricated
    wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
    ESP_ERROR_CHECK(esp_wifi_init(&cfg));
    esp_netif_inherent_config_t esp_netif_config = ESP_NETIF_INHERENT_DEFAULT_WIFI_STA();
    // Prefix the interface description with the module TAG
    // Warning: the interface desc is used in tests to capture actual connection details (IP, gw, mask)
    asprintf(&desc, "%s: %s", MASTER_TAG, esp_netif_config.if_desc);
    esp_netif_config.if_desc = desc;
    esp_netif_config.route_prio = 128;
    esp_netif_t *netif = esp_netif_create_wifi(WIFI_IF_STA, &esp_netif_config);
    free(desc);
    esp_wifi_set_default_wifi_sta_handlers();

    ESP_ERROR_CHECK(esp_event_handler_register(WIFI_EVENT, WIFI_EVENT_STA_START, &on_wifi_start, NULL));
    ESP_ERROR_CHECK(esp_event_handler_register(WIFI_EVENT, WIFI_EVENT_STA_DISCONNECTED, &on_wifi_disconnect, NULL));
    ESP_ERROR_CHECK(esp_event_handler_register(IP_EVENT, IP_EVENT_STA_GOT_IP, &on_got_ip, NULL));
    ESP_ERROR_CHECK(esp_event_handler_register(WIFI_EVENT, WIFI_EVENT_STA_CONNECTED, &on_wifi_connect, netif));

    ESP_ERROR_CHECK(esp_wifi_set_storage(WIFI_STORAGE_RAM));
    wifi_config_t wifi_config = {
        .sta = {
            .ssid = CONFIG_EXAMPLE_WIFI_SSID,
            .password = CONFIG_EXAMPLE_WIFI_PASSWORD,
        },
    };
    ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA));
    ESP_ERROR_CHECK(esp_wifi_set_config(ESP_IF_WIFI_STA, &wifi_config));
    ESP_LOGI(MASTER_TAG, "start the WIFI SSID:[%s]", CONFIG_EXAMPLE_WIFI_SSID);
    ESP_ERROR_CHECK(esp_wifi_start());
    ESP_LOGI(MASTER_TAG, "Waiting for wifi");
    xEventGroupWaitBits(wifi_event_group, CONNECTED_BIT, false, true, portMAX_DELAY);
}

void app_main(void)
{
    //Initialize NVS
    esp_err_t ret = nvs_flash_init();
    if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) {
        ESP_ERROR_CHECK(nvs_flash_erase());
        ret = nvs_flash_init();
    }
    ESP_ERROR_CHECK(ret);
    ESP_LOGI(MASTER_TAG, "ESP_WIFI_MODE_STA");
    wifi_init();

    // Initialization of device peripheral and objects
    //ESP_ERROR_CHECK(master_init());
    //vTaskDelay(10);

    //xTaskCreate(&master_operation_func, "modbus_task", 16384, NULL, 5, NULL);
    //vTaskDelay(300);

    //esp_restart();

    //master_operation_func(NULL);
}

Debug Logs

Compressed 717024 bytes to 449515...
Writing at 0x00010000... (3 %)
Writing at 0x00014000... (7 %)
Writing at 0x00018000... (10 %)
Writing at 0x0001c000... (14 %)
Writing at 0x00020000... (17 %)
Writing at 0x00024000... (21 %)
Writing at 0x00028000... (25 %)
Writing at 0x0002c000... (28 %)
Writing at 0x00030000... (32 %)
Writing at 0x00034000... (35 %)
Writing at 0x00038000... (39 %)
Writing at 0x0003c000... (42 %)
Writing at 0x00040000... (46 %)
Writing at 0x00044000... (50 %)
Writing at 0x00048000... (53 %)
Writing at 0x0004c000... (57 %)
Writing at 0x00050000... (60 %)
Writing at 0x00054000... (64 %)
Writing at 0x00058000... (67 %)
Writing at 0x0005c000... (71 %)
Writing at 0x00060000... (75 %)
Writing at 0x00064000... (78 %)
Writing at 0x00068000... (82 %)
Writing at 0x0006c000... (85 %)
Writing at 0x00070000... (89 %)
Writing at 0x00074000... (92 %)
Writing at 0x00078000... (96 %)
Writing at 0x0007c000... (100 %)
Wrote 717024 bytes (449515 compressed) at 0x00010000 in 11.4 seconds (effective 505.0 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...
Executing action: monitor
Running idf_monitor in directory /Applications/ESP-32/DAIVIET-MODBUS485/source/rs485_module
Executing "/Users/nguyentri/.espressif/python_env/idf4.3_py2.7_env/bin/python /Users/nguyentri/esp/esp-idf/tools/idf_monitor.py -p /dev/cu.usbserial-14240 -b 115200 --toolchain-prefix xtensa-esp32-elf- /Applications/ESP-32/DAIVIET-MODBUS485/source/rs485_module/build/DaiVietIoT.elf -m '/Users/nguyentri/.espressif/python_env/idf4.3_py2.7_env/bin/python' '/Users/nguyentri/esp/esp-idf/tools/idf.py'"...
--- idf_monitor on /dev/cu.usbserial-14240 115200 ---
--- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
ets Jun  8 2016 00:22:57

rst:0x1 (POWERON_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:4
load:0x3fff0034,len:6972
load:0x40078000,len:14332
ho 0 tail 12 room 4
load:0x40080400,len:3672
0x40080400: _init at ??:?

entry 0x40080678
I (31) boot: ESP-IDF v4.3-dev-2398-g2bfdd036b 2nd stage bootloader
I (31) boot: compile time 12:13:26
I (31) boot: chip revision: 1
I (35) boot_comm: chip revision: 1, min. bootloader chip revision: 0
I (42) boot.esp32: SPI Speed      : 40MHz
I (47) boot.esp32: SPI Mode       : DIO
I (51) boot.esp32: SPI Flash Size : 4MB
I (56) boot: Enabling RNG early entropy source...
I (61) boot: Partition Table:
I (65) boot: ## Label            Usage          Type ST Offset   Length
I (72) boot:  0 nvs              WiFi data        01 02 00009000 00004000
I (80) boot:  1 otadata          OTA data         01 00 0000d000 00002000
I (87) boot:  2 phy_init         RF data          01 01 0000f000 00001000
I (95) boot:  3 factory          factory app      00 00 00010000 00100000
I (102) boot:  4 ota_0            OTA app          00 10 00110000 00100000
I (110) boot:  5 ota_1            OTA app          00 11 00210000 00100000
I (117) boot: End of partition table
I (122) boot: Defaulting to factory image
I (126) boot_comm: chip revision: 1, min. application chip revision: 0
I (133) esp_image: segment 0: paddr=00010020 vaddr=3f400020 size=1b374h (111476) map
I (184) esp_image: segment 1: paddr=0002b39c vaddr=3ffb0000 size=03f50h ( 16208) load
I (191) esp_image: segment 2: paddr=0002f2f4 vaddr=40080000 size=00404h (  1028) load
I (192) esp_image: segment 3: paddr=0002f700 vaddr=40080404 size=00918h (  2328) load
I (200) esp_image: segment 4: paddr=00030020 vaddr=400d0020 size=79dc4h (499140) map
I (397) esp_image: segment 5: paddr=000a9dec vaddr=40080d1c size=152cch ( 86732) load
I (448) boot: Loaded app from partition at offset 0x10000
I (448) boot: Disabling RNG early entropy source...
I (459) cpu_start: Pro cpu up.
I (459) cpu_start: Starting app cpu, entry point is 0x40081260
0x40081260: call_start_cpu1 at /Users/nguyentri/esp/esp-idf/components/esp_system/port/cpu_start.c:133

I (0) cpu_start: App cpu up.
I (474) cpu_start: Pro cpu start user code
I (474) cpu_start: cpu freq: 160000000
I (474) cpu_start: Application information:
I (478) cpu_start: Project name:     DaiVietIoT
I (483) cpu_start: App version:      cb6f346-dirty
I (489) cpu_start: Compile time:     Jan 27 2021 23:06:03
I (495) cpu_start: ELF file SHA256:  a9c175cddee84f25...
I (501) cpu_start: ESP-IDF:          v4.3-dev-2398-g2bfdd036b
I (508) heap_init: Initializing. RAM available for dynamic allocation:
I (515) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
I (521) heap_init: At 3FFB8150 len 00027EB0 (159 KiB): DRAM
I (527) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (533) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (540) heap_init: At 40095FE8 len 0000A018 (40 KiB): IRAM
I (547) spi_flash: detected chip: generic
I (551) spi_flash: flash io: dio
I (556) cpu_start: Starting scheduler on PRO CPU.
I (0) cpu_start: Starting scheduler on APP CPU.
I (645) MASTER_TEST: ESP_WIFI_MODE_STA
I (655) wifi:wifi driver task: 3ffc1378, prio:23, stack:6656, core=0
I (655) system_api: Base MAC address is not set
I (655) system_api: read default base MAC address from EFUSE
I (675) wifi:wifi firmware version: 9a688d0
I (675) wifi:wifi certification version: v7.0
I (675) wifi:config NVS flash: enabled
I (675) wifi:config nano formating: disabled
I (685) wifi:Init data frame dynamic rx buffer num: 32
I (685) wifi:Init management frame dynamic rx buffer num: 32
I (695) wifi:Init management short buffer num: 32
I (695) wifi:Init dynamic tx buffer num: 32
I (705) wifi:Init static rx buffer size: 1600
I (705) wifi:Init static rx buffer num: 10
I (715) wifi:Init dynamic rx buffer num: 32
I (715) wifi_init: rx ba win: 6
I (715) wifi_init: tcpip mbox: 32
I (725) wifi_init: udp mbox: 6
I (725) wifi_init: tcp mbox: 6
I (725) wifi_init: tcp tx win: 5744
I (735) wifi_init: tcp rx win: 5744
I (735) wifi_init: tcp mss: 1440
I (745) wifi_init: WiFi IRAM OP enabled
I (745) wifi_init: WiFi RX IRAM OP enabled
I (755) MASTER_TEST: start the WIFI SSID:[www.iotdaiviet2.com]
I (755) phy_init: phy_version 4660,0162888,Dec 23 2020
I (865) wifi:mode : sta (98:f4:ab:22:5d:d8)
I (865) wifi:enable tsf
I (865) MASTER_TEST: Waiting for wifi
I (865) MASTER_TEST: Wi-Fi start handler...
I (875) wifi:new:<1,0>, old:<1,0>, ap:<255,255>, sta:<1,0>, prof:1
I (1895) wifi:state: init -> auth (b0)
I (1905) wifi:state: auth -> assoc (0)
I (1925) wifi:state: assoc -> run (10)
I (1945) wifi:connected with www.iotdaiviet2.com, aid = 7, channel 1, BW20, bssid = 36:32:c8:9d:09:ad
I (1945) wifi:security: WPA2-PSK, phy: bgn, rssi: -70
I (1945) wifi:pm start, type: 1

I (1945) MASTER_TEST: Wi-Fi connect handler...
I (1945) wifi:AP's beacon interval = 102400 us, DTIM period = 2
I (2645) esp_netif_handlers: MASTER_TEST: sta ip: 192.168.43.142, mask: 255.255.255.0, gw: 192.168.43.86
I (2645) MASTER_TEST: Got IPv4 event: Interface "MASTER_TEST: sta" address: 192.168.43.142
I (2655) uart: queue free spaces: 20
I (2705) MASTER_TEST: Modbus master stack initialized...
I (2705) MASTER_TEST: Start modbus test...
I (2775) MASTER_TEST: Characteristic #0 Data_channel_0 (Volts) value = 0.000000 (0x0) read successful.
I (2855) MASTER_TEST: Characteristic #1 Humidity_1 (%rH) value = 0.000000 (0x0) read successful.
I (2935) MASTER_TEST: Characteristic #2 Temperature_1 (C) value = 0.000000 (0x0) read successful.
I (3015) MASTER_TEST: Characteristic #3 Humidity_2 (%rH) value = 0.000000 (0x0) read successful.
I (3095) MASTER_TEST: Characteristic #4 Temperature_2 (C) value = 0.000000 (0x0) read successful.
I (3175) MASTER_TEST: Characteristic #5 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (3175) MASTER_TEST: Characteristic #6 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (3255) MASTER_TEST: Characteristic #7 RelayP1 (on/off) value = OFF (0x0) read successful.
I (3335) MASTER_TEST: Characteristic #8 RelayP2 (on/off) value = OFF (0x0) read successful.
I (3415) MASTER_TEST: Characteristic #0 Data_channel_0 (Volts) value = 0.000000 (0x0) read successful.
I (3495) MASTER_TEST: Characteristic #1 Humidity_1 (%rH) value = 0.000000 (0x0) read successful.
I (3575) MASTER_TEST: Characteristic #2 Temperature_1 (C) value = 0.000000 (0x0) read successful.
I (3655) MASTER_TEST: Characteristic #3 Humidity_2 (%rH) value = 0.000000 (0x0) read successful.
I (3735) MASTER_TEST: Characteristic #4 Temperature_2 (C) value = 0.000000 (0x0) read successful.
I (3815) MASTER_TEST: Characteristic #5 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (3815) MASTER_TEST: Characteristic #6 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (3895) MASTER_TEST: Characteristic #7 RelayP1 (on/off) value = OFF (0x0) read successful.
I (3975) MASTER_TEST: Characteristic #8 RelayP2 (on/off) value = OFF (0x0) read successful.
I (4055) MASTER_TEST: Characteristic #0 Data_channel_0 (Volts) value = 0.000000 (0x0) read successful.
I (4135) MASTER_TEST: Characteristic #1 Humidity_1 (%rH) value = 0.000000 (0x0) read successful.
I (4215) MASTER_TEST: Characteristic #2 Temperature_1 (C) value = 0.000000 (0x0) read successful.
I (4295) MASTER_TEST: Characteristic #3 Humidity_2 (%rH) value = 0.000000 (0x0) read successful.
I (4375) MASTER_TEST: Characteristic #4 Temperature_2 (C) value = 0.000000 (0x0) read successful.
I (4455) MASTER_TEST: Characteristic #5 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (4455) MASTER_TEST: Characteristic #6 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (4535) MASTER_TEST: Characteristic #7 RelayP1 (on/off) value = OFF (0x0) read successful.
I (4615) MASTER_TEST: Characteristic #8 RelayP2 (on/off) value = OFF (0x0) read successful.
I (4695) MASTER_TEST: Characteristic #0 Data_channel_0 (Volts) value = 0.000000 (0x0) read successful.
I (4775) MASTER_TEST: Characteristic #1 Humidity_1 (%rH) value = 0.000000 (0x0) read successful.
I (4855) MASTER_TEST: Characteristic #2 Temperature_1 (C) value = 0.000000 (0x0) read successful.
I (4935) MASTER_TEST: Characteristic #3 Humidity_2 (%rH) value = 0.000000 (0x0) read successful.
I (5015) MASTER_TEST: Characteristic #4 Temperature_2 (C) value = 0.000000 (0x0) read successful.
I (5095) MASTER_TEST: Characteristic #5 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (5095) MASTER_TEST: Characteristic #6 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (5175) MASTER_TEST: Characteristic #7 RelayP1 (on/off) value = OFF (0x0) read successful.
I (5255) MASTER_TEST: Characteristic #8 RelayP2 (on/off) value = OFF (0x0) read successful.
I (5335) MASTER_TEST: Characteristic #0 Data_channel_0 (Volts) value = 0.000000 (0x0) read successful.
I (5415) MASTER_TEST: Characteristic #1 Humidity_1 (%rH) value = 0.000000 (0x0) read successful.
I (5495) MASTER_TEST: Characteristic #2 Temperature_1 (C) value = 0.000000 (0x0) read successful.
I (5575) MASTER_TEST: Characteristic #3 Humidity_2 (%rH) value = 0.000000 (0x0) read successful.
I (5655) MASTER_TEST: Characteristic #4 Temperature_2 (C) value = 0.000000 (0x0) read successful.
I (5735) MASTER_TEST: Characteristic #5 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (5735) MASTER_TEST: Characteristic #6 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (5815) MASTER_TEST: Characteristic #7 RelayP1 (on/off) value = OFF (0x0) read successful.
I (5895) MASTER_TEST: Characteristic #8 RelayP2 (on/off) value = OFF (0x0) read successful.
I (5975) MASTER_TEST: Characteristic #0 Data_channel_0 (Volts) value = 0.000000 (0x0) read successful.
I (6055) MASTER_TEST: Characteristic #1 Humidity_1 (%rH) value = 0.000000 (0x0) read successful.
I (6135) MASTER_TEST: Characteristic #2 Temperature_1 (C) value = 0.000000 (0x0) read successful.
I (6215) MASTER_TEST: Characteristic #3 Humidity_2 (%rH) value = 0.000000 (0x0) read successful.
I (6295) MASTER_TEST: Characteristic #4 Temperature_2 (C) value = 0.000000 (0x0) read successful.
I (6375) MASTER_TEST: Characteristic #5 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (6375) MASTER_TEST: Characteristic #6 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (6455) MASTER_TEST: Characteristic #7 RelayP1 (on/off) value = OFF (0x0) read successful.
I (6535) MASTER_TEST: Characteristic #8 RelayP2 (on/off) value = OFF (0x0) read successful.
I (6615) MASTER_TEST: Characteristic #0 Data_channel_0 (Volts) value = 0.000000 (0x0) read successful.
I (6695) MASTER_TEST: Characteristic #1 Humidity_1 (%rH) value = 0.000000 (0x0) read successful.
I (6775) MASTER_TEST: Characteristic #2 Temperature_1 (C) value = 0.000000 (0x0) read successful.
I (6855) MASTER_TEST: Characteristic #3 Humidity_2 (%rH) value = 0.000000 (0x0) read successful.
I (6935) MASTER_TEST: Characteristic #4 Temperature_2 (C) value = 0.000000 (0x0) read successful.
I (7015) MASTER_TEST: Characteristic #5 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (7015) MASTER_TEST: Characteristic #6 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (7095) MASTER_TEST: Characteristic #7 RelayP1 (on/off) value = OFF (0x0) read successful.
I (7175) MASTER_TEST: Characteristic #8 RelayP2 (on/off) value = OFF (0x0) read successful.
I (7255) MASTER_TEST: Characteristic #0 Data_channel_0 (Volts) value = 0.000000 (0x0) read successful.
I (7335) MASTER_TEST: Characteristic #1 Humidity_1 (%rH) value = 0.000000 (0x0) read successful.
I (7415) MASTER_TEST: Characteristic #2 Temperature_1 (C) value = 0.000000 (0x0) read successful.
I (7495) MASTER_TEST: Characteristic #3 Humidity_2 (%rH) value = 0.000000 (0x0) read successful.
I (7575) MASTER_TEST: Characteristic #4 Temperature_2 (C) value = 0.000000 (0x0) read successful.
I (7655) MASTER_TEST: Characteristic #5 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (7655) MASTER_TEST: Characteristic #6 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (7735) MASTER_TEST: Characteristic #7 RelayP1 (on/off) value = OFF (0x0) read successful.
I (7815) MASTER_TEST: Characteristic #8 RelayP2 (on/off) value = OFF (0x0) read successful.
I (7895) MASTER_TEST: Characteristic #0 Data_channel_0 (Volts) value = 0.000000 (0x0) read successful.
I (7975) MASTER_TEST: Characteristic #1 Humidity_1 (%rH) value = 0.000000 (0x0) read successful.
I (8055) MASTER_TEST: Characteristic #2 Temperature_1 (C) value = 0.000000 (0x0) read successful.
I (8135) MASTER_TEST: Characteristic #3 Humidity_2 (%rH) value = 0.000000 (0x0) read successful.
I (8215) MASTER_TEST: Characteristic #4 Temperature_2 (C) value = 0.000000 (0x0) read successful.
I (8295) MASTER_TEST: Characteristic #5 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (8295) MASTER_TEST: Characteristic #6 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (8365) MASTER_TEST: Characteristic #7 RelayP1 (on/off) value = OFF (0x0) read successful.
I (8455) MASTER_TEST: Characteristic #8 RelayP2 (on/off) value = OFF (0x0) read successful.
I (8535) MASTER_TEST: Characteristic #0 Data_channel_0 (Volts) value = 0.000000 (0x0) read successful.
I (8615) MASTER_TEST: Characteristic #1 Humidity_1 (%rH) value = 0.000000 (0x0) read successful.
I (8695) MASTER_TEST: Characteristic #2 Temperature_1 (C) value = 0.000000 (0x0) read successful.
I (8775) MASTER_TEST: Characteristic #3 Humidity_2 (%rH) value = 0.000000 (0x0) read successful.
I (8855) MASTER_TEST: Characteristic #4 Temperature_2 (C) value = 0.000000 (0x0) read successful.
I (8935) MASTER_TEST: Characteristic #5 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (8935) MASTER_TEST: Characteristic #6 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (9005) MASTER_TEST: Characteristic #7 RelayP1 (on/off) value = OFF (0x0) read successful.
I (9095) MASTER_TEST: Characteristic #8 RelayP2 (on/off) value = OFF (0x0) read successful.
I (9175) MASTER_TEST: Characteristic #0 Data_channel_0 (Volts) value = 0.000000 (0x0) read successful.
I (9255) MASTER_TEST: Characteristic #1 Humidity_1 (%rH) value = 0.000000 (0x0) read successful.
I (9335) MASTER_TEST: Characteristic #2 Temperature_1 (C) value = 0.000000 (0x0) read successful.
I (9415) MASTER_TEST: Characteristic #3 Humidity_2 (%rH) value = 0.000000 (0x0) read successful.
I (9495) MASTER_TEST: Characteristic #4 Temperature_2 (C) value = 0.000000 (0x0) read successful.
I (9575) MASTER_TEST: Characteristic #5 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (9575) MASTER_TEST: Characteristic #6 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (9645) MASTER_TEST: Characteristic #7 RelayP1 (on/off) value = OFF (0x0) read successful.
I (9725) MASTER_TEST: Characteristic #8 RelayP2 (on/off) value = OFF (0x0) read successful.
I (9815) MASTER_TEST: Characteristic #0 Data_channel_0 (Volts) value = 0.000000 (0x0) read successful.
I (9895) MASTER_TEST: Characteristic #1 Humidity_1 (%rH) value = 0.000000 (0x0) read successful.
I (9975) MASTER_TEST: Characteristic #2 Temperature_1 (C) value = 0.000000 (0x0) read successful.
I (10055) MASTER_TEST: Characteristic #3 Humidity_2 (%rH) value = 0.000000 (0x0) read successful.
I (10135) MASTER_TEST: Characteristic #4 Temperature_2 (C) value = 0.000000 (0x0) read successful.
I (10215) MASTER_TEST: Characteristic #5 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (10215) MASTER_TEST: Characteristic #6 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (10285) MASTER_TEST: Characteristic #7 RelayP1 (on/off) value = OFF (0x0) read successful.
I (10365) MASTER_TEST: Characteristic #8 RelayP2 (on/off) value = OFF (0x0) read successful.
I (10455) MASTER_TEST: Characteristic #0 Data_channel_0 (Volts) value = 0.000000 (0x0) read successful.
I (10535) MASTER_TEST: Characteristic #1 Humidity_1 (%rH) value = 0.000000 (0x0) read successful.
I (10615) MASTER_TEST: Characteristic #2 Temperature_1 (C) value = 0.000000 (0x0) read successful.
I (10695) MASTER_TEST: Characteristic #3 Humidity_2 (%rH) value = 0.000000 (0x0) read successful.
I (10775) MASTER_TEST: Characteristic #4 Temperature_2 (C) value = 0.000000 (0x0) read successful.
I (10855) MASTER_TEST: Characteristic #5 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (10855) MASTER_TEST: Characteristic #6 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (10925) MASTER_TEST: Characteristic #7 RelayP1 (on/off) value = OFF (0x0) read successful.
I (11005) MASTER_TEST: Characteristic #8 RelayP2 (on/off) value = OFF (0x0) read successful.
I (11095) MASTER_TEST: Characteristic #0 Data_channel_0 (Volts) value = 0.000000 (0x0) read successful.
I (11175) MASTER_TEST: Characteristic #1 Humidity_1 (%rH) value = 0.000000 (0x0) read successful.
I (11255) MASTER_TEST: Characteristic #2 Temperature_1 (C) value = 0.000000 (0x0) read successful.
I (11335) MASTER_TEST: Characteristic #3 Humidity_2 (%rH) value = 0.000000 (0x0) read successful.
I (11415) MASTER_TEST: Characteristic #4 Temperature_2 (C) value = 0.000000 (0x0) read successful.
I (11495) MASTER_TEST: Characteristic #5 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (11495) MASTER_TEST: Characteristic #6 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (11565) MASTER_TEST: Characteristic #7 RelayP1 (on/off) value = OFF (0x0) read successful.
I (11645) MASTER_TEST: Characteristic #8 RelayP2 (on/off) value = OFF (0x0) read successful.
I (11735) MASTER_TEST: Characteristic #0 Data_channel_0 (Volts) value = 0.000000 (0x0) read successful.
I (11815) MASTER_TEST: Characteristic #1 Humidity_1 (%rH) value = 0.000000 (0x0) read successful.
I (11895) MASTER_TEST: Characteristic #2 Temperature_1 (C) value = 0.000000 (0x0) read successful.
I (11975) MASTER_TEST: Characteristic #3 Humidity_2 (%rH) value = 0.000000 (0x0) read successful.
I (12055) MASTER_TEST: Characteristic #4 Temperature_2 (C) value = 0.000000 (0x0) read successful.
I (12135) MASTER_TEST: Characteristic #5 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (12135) MASTER_TEST: Characteristic #6 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (12205) MASTER_TEST: Characteristic #7 RelayP1 (on/off) value = OFF (0x0) read successful.
I (12285) MASTER_TEST: Characteristic #8 RelayP2 (on/off) value = OFF (0x0) read successful.
I (12375) MASTER_TEST: Characteristic #0 Data_channel_0 (Volts) value = 0.000000 (0x0) read successful.
I (12455) MASTER_TEST: Characteristic #1 Humidity_1 (%rH) value = 0.000000 (0x0) read successful.
I (12535) MASTER_TEST: Characteristic #2 Temperature_1 (C) value = 0.000000 (0x0) read successful.
I (12615) MASTER_TEST: Characteristic #3 Humidity_2 (%rH) value = 0.000000 (0x0) read successful.
I (12695) MASTER_TEST: Characteristic #4 Temperature_2 (C) value = 0.000000 (0x0) read successful.
I (12705) wifi:state: run -> init (0)
I (12705) wifi:pm stop, total sleep time: 9911835 us / 10756026 us

I (12705) wifi:new:<1,0>, old:<1,0>, ap:<255,255>, sta:<1,0>, prof:1
I (12745) wifi:flush txq
I (12745) wifi:stop sw txq
I (12745) wifi:lmac stop hw txq
ets Jun  8 2016 00:22:57

rst:0xc (SW_CPU_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:4
load:0x3fff0034,len:6972
load:0x40078000,len:14332
ho 0 tail 12 room 4
load:0x40080400,len:3672
0x40080400: _init at ??:?

entry 0x40080678
I (31) boot: ESP-IDF v4.3-dev-2398-g2bfdd036b 2nd stage bootloader
I (31) boot: compile time 12:13:26
I (31) boot: chip revision: 1
I (35) boot_comm: chip revision: 1, min. bootloader chip revision: 0
I (42) boot.esp32: SPI Speed      : 40MHz
I (47) boot.esp32: SPI Mode       : DIO
I (51) boot.esp32: SPI Flash Size : 4MB
I (56) boot: Enabling RNG early entropy source...
I (61) boot: Partition Table:
I (65) boot: ## Label            Usage          Type ST Offset   Length
I (72) boot:  0 nvs              WiFi data        01 02 00009000 00004000
I (80) boot:  1 otadata          OTA data         01 00 0000d000 00002000
I (87) boot:  2 phy_init         RF data          01 01 0000f000 00001000
I (95) boot:  3 factory          factory app      00 00 00010000 00100000
I (102) boot:  4 ota_0            OTA app          00 10 00110000 00100000
I (110) boot:  5 ota_1            OTA app          00 11 00210000 00100000
I (117) boot: End of partition table
I (122) boot: Defaulting to factory image
I (126) boot_comm: chip revision: 1, min. application chip revision: 0
I (133) esp_image: segment 0: paddr=00010020 vaddr=3f400020 size=1b374h (111476) map
I (184) esp_image: segment 1: paddr=0002b39c vaddr=3ffb0000 size=03f50h ( 16208) load
I (192) esp_image: segment 2: paddr=0002f2f4 vaddr=40080000 size=00404h (  1028) load
I (192) esp_image: segment 3: paddr=0002f700 vaddr=40080404 size=00918h (  2328) load
I (200) esp_image: segment 4: paddr=00030020 vaddr=400d0020 size=79dc4h (499140) map
I (397) esp_image: segment 5: paddr=000a9dec vaddr=40080d1c size=152cch ( 86732) load
I (448) boot: Loaded app from partition at offset 0x10000
I (448) boot: Disabling RNG early entropy source...
I (459) cpu_start: Pro cpu up.
I (459) cpu_start: Starting app cpu, entry point is 0x40081260
0x40081260: call_start_cpu1 at /Users/nguyentri/esp/esp-idf/components/esp_system/port/cpu_start.c:133

I (444) cpu_start: App cpu up.
I (474) cpu_start: Pro cpu start user code
I (474) cpu_start: cpu freq: 160000000
I (474) cpu_start: Application information:
I (478) cpu_start: Project name:     DaiVietIoT
I (484) cpu_start: App version:      cb6f346-dirty
I (489) cpu_start: Compile time:     Jan 27 2021 23:06:03
I (495) cpu_start: ELF file SHA256:  a9c175cddee84f25...
I (501) cpu_start: ESP-IDF:          v4.3-dev-2398-g2bfdd036b
I (508) heap_init: Initializing. RAM available for dynamic allocation:
I (515) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
I (521) heap_init: At 3FFB8150 len 00027EB0 (159 KiB): DRAM
I (527) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (533) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (540) heap_init: At 40095FE8 len 0000A018 (40 KiB): IRAM
I (547) spi_flash: detected chip: generic
I (551) spi_flash: flash io: dio
I (556) cpu_start: Starting scheduler on PRO CPU.
I (0) cpu_start: Starting scheduler on APP CPU.
I (645) MASTER_TEST: ESP_WIFI_MODE_STA
I (655) wifi:wifi driver task: 3ffc1378, prio:23, stack:6656, core=0
I (655) system_api: Base MAC address is not set
I (655) system_api: read default base MAC address from EFUSE
I (675) wifi:wifi firmware version: 9a688d0
I (675) wifi:wifi certification version: v7.0
I (675) wifi:config NVS flash: enabled
I (675) wifi:config nano formating: disabled
I (685) wifi:Init data frame dynamic rx buffer num: 32
I (685) wifi:Init management frame dynamic rx buffer num: 32
I (695) wifi:Init management short buffer num: 32
I (695) wifi:Init dynamic tx buffer num: 32
I (705) wifi:Init static rx buffer size: 1600
I (705) wifi:Init static rx buffer num: 10
I (715) wifi:Init dynamic rx buffer num: 32
I (715) wifi_init: rx ba win: 6
I (715) wifi_init: tcpip mbox: 32
I (725) wifi_init: udp mbox: 6
I (725) wifi_init: tcp mbox: 6
I (725) wifi_init: tcp tx win: 5744
I (735) wifi_init: tcp rx win: 5744
I (735) wifi_init: tcp mss: 1440
I (745) wifi_init: WiFi IRAM OP enabled
I (745) wifi_init: WiFi RX IRAM OP enabled
I (755) MASTER_TEST: start the WIFI SSID:[www.iotdaiviet2.com]
I (755) phy_init: phy_version 4660,0162888,Dec 23 2020
I (865) wifi:mode : sta (98:f4:ab:22:5d:d8)
I (865) wifi:enable tsf
I (865) MASTER_TEST: Waiting for wifi
I (865) MASTER_TEST: Wi-Fi start handler...
I (875) wifi:new:<1,0>, old:<1,0>, ap:<255,255>, sta:<1,0>, prof:1
I (1895) wifi:state: init -> auth (b0)
I (1905) wifi:state: auth -> assoc (0)
I (1935) wifi:state: assoc -> run (10)
I (1955) wifi:connected with www.iotdaiviet2.com, aid = 8, channel 1, BW20, bssid = 36:32:c8:9d:09:ad
I (1955) wifi:security: WPA2-PSK, phy: bgn, rssi: -69
I (1955) wifi:pm start, type: 1

I (1965) MASTER_TEST: Wi-Fi connect handler...
I (2045) wifi:AP's beacon interval = 102400 us, DTIM period = 2
I (2645) esp_netif_handlers: MASTER_TEST: sta ip: 192.168.43.142, mask: 255.255.255.0, gw: 192.168.43.86
I (2645) MASTER_TEST: Got IPv4 event: Interface "MASTER_TEST: sta" address: 192.168.43.142
I (2655) uart: queue free spaces: 20
I (2705) MASTER_TEST: Modbus master stack initialized...
I (2705) MASTER_TEST: Start modbus test...
I (2785) MASTER_TEST: Characteristic #0 Data_channel_0 (Volts) value = 0.000000 (0x0) read successful.
I (2865) MASTER_TEST: Characteristic #1 Humidity_1 (%rH) value = 0.000000 (0x0) read successful.
I (2935) MASTER_TEST: Characteristic #2 Temperature_1 (C) value = 0.000000 (0x0) read successful.
I (3025) MASTER_TEST: Characteristic #3 Humidity_2 (%rH) value = 0.000000 (0x0) read successful.
I (3105) MASTER_TEST: Characteristic #4 Temperature_2 (C) value = 0.000000 (0x0) read successful.
I (3185) MASTER_TEST: Characteristic #5 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (3185) MASTER_TEST: Characteristic #6 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (3255) MASTER_TEST: Characteristic #7 RelayP1 (on/off) value = OFF (0x0) read successful.
I (3325) MASTER_TEST: Characteristic #8 RelayP2 (on/off) value = OFF (0x0) read successful.
I (3405) MASTER_TEST: Characteristic #0 Data_channel_0 (Volts) value = 0.000000 (0x0) read successful.
I (3485) MASTER_TEST: Characteristic #1 Humidity_1 (%rH) value = 0.000000 (0x0) read successful.
I (3565) MASTER_TEST: Characteristic #2 Temperature_1 (C) value = 0.000000 (0x0) read successful.
I (3645) MASTER_TEST: Characteristic #3 Humidity_2 (%rH) value = 0.000000 (0x0) read successful.
I (3725) MASTER_TEST: Characteristic #4 Temperature_2 (C) value = 0.000000 (0x0) read successful.
I (3805) MASTER_TEST: Characteristic #5 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (3805) MASTER_TEST: Characteristic #6 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (3885) MASTER_TEST: Characteristic #7 RelayP1 (on/off) value = OFF (0x0) read successful.
I (3965) MASTER_TEST: Characteristic #8 RelayP2 (on/off) value = OFF (0x0) read successful.
I (4045) MASTER_TEST: Characteristic #0 Data_channel_0 (Volts) value = 0.000000 (0x0) read successful.
I (4125) MASTER_TEST: Characteristic #1 Humidity_1 (%rH) value = 0.000000 (0x0) read successful.
I (4205) MASTER_TEST: Characteristic #2 Temperature_1 (C) value = 0.000000 (0x0) read successful.
I (4285) MASTER_TEST: Characteristic #3 Humidity_2 (%rH) value = 0.000000 (0x0) read successful.
I (4365) MASTER_TEST: Characteristic #4 Temperature_2 (C) value = 0.000000 (0x0) read successful.
I (4445) MASTER_TEST: Characteristic #5 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (4445) MASTER_TEST: Characteristic #6 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (4525) MASTER_TEST: Characteristic #7 RelayP1 (on/off) value = OFF (0x0) read successful.
I (4605) MASTER_TEST: Characteristic #8 RelayP2 (on/off) value = OFF (0x0) read successful.
I (4685) MASTER_TEST: Characteristic #0 Data_channel_0 (Volts) value = 0.000000 (0x0) read successful.
I (4765) MASTER_TEST: Characteristic #1 Humidity_1 (%rH) value = 0.000000 (0x0) read successful.
I (4845) MASTER_TEST: Characteristic #2 Temperature_1 (C) value = 0.000000 (0x0) read successful.
I (4925) MASTER_TEST: Characteristic #3 Humidity_2 (%rH) value = 0.000000 (0x0) read successful.
I (5005) MASTER_TEST: Characteristic #4 Temperature_2 (C) value = 0.000000 (0x0) read successful.
I (5085) MASTER_TEST: Characteristic #5 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (5085) MASTER_TEST: Characteristic #6 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (5165) MASTER_TEST: Characteristic #7 RelayP1 (on/off) value = OFF (0x0) read successful.
I (5245) MASTER_TEST: Characteristic #8 RelayP2 (on/off) value = OFF (0x0) read successful.
I (5325) MASTER_TEST: Characteristic #0 Data_channel_0 (Volts) value = 0.000000 (0x0) read successful.
I (5405) MASTER_TEST: Characteristic #1 Humidity_1 (%rH) value = 0.000000 (0x0) read successful.
I (5485) MASTER_TEST: Characteristic #2 Temperature_1 (C) value = 0.000000 (0x0) read successful.
I (5575) MASTER_TEST: Characteristic #3 Humidity_2 (%rH) value = 0.000000 (0x0) read successful.
I (5645) MASTER_TEST: Characteristic #4 Temperature_2 (C) value = 0.000000 (0x0) read successful.
I (5725) MASTER_TEST: Characteristic #5 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (5725) MASTER_TEST: Characteristic #6 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (5795) MASTER_TEST: Characteristic #7 RelayP1 (on/off) value = OFF (0x0) read successful.
I (5885) MASTER_TEST: Characteristic #8 RelayP2 (on/off) value = OFF (0x0) read successful.
I (5965) MASTER_TEST: Characteristic #0 Data_channel_0 (Volts) value = 0.000000 (0x0) read successful.
I (6045) MASTER_TEST: Characteristic #1 Humidity_1 (%rH) value = 0.000000 (0x0) read successful.
I (6125) MASTER_TEST: Characteristic #2 Temperature_1 (C) value = 0.000000 (0x0) read successful.
I (6205) MASTER_TEST: Characteristic #3 Humidity_2 (%rH) value = 0.000000 (0x0) read successful.
I (6285) MASTER_TEST: Characteristic #4 Temperature_2 (C) value = 0.000000 (0x0) read successful.
I (6365) MASTER_TEST: Characteristic #5 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (6365) MASTER_TEST: Characteristic #6 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (6445) MASTER_TEST: Characteristic #7 RelayP1 (on/off) value = OFF (0x0) read successful.
I (6525) MASTER_TEST: Characteristic #8 RelayP2 (on/off) value = OFF (0x0) read successful.
I (6605) MASTER_TEST: Characteristic #0 Data_channel_0 (Volts) value = 0.000000 (0x0) read successful.
I (6685) MASTER_TEST: Characteristic #1 Humidity_1 (%rH) value = 0.000000 (0x0) read successful.
I (6765) MASTER_TEST: Characteristic #2 Temperature_1 (C) value = 0.000000 (0x0) read successful.
I (6845) MASTER_TEST: Characteristic #3 Humidity_2 (%rH) value = 0.000000 (0x0) read successful.
I (6925) MASTER_TEST: Characteristic #4 Temperature_2 (C) value = 0.000000 (0x0) read successful.
I (7005) MASTER_TEST: Characteristic #5 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (7005) MASTER_TEST: Characteristic #6 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (7085) MASTER_TEST: Characteristic #7 RelayP1 (on/off) value = OFF (0x0) read successful.
I (7155) MASTER_TEST: Characteristic #8 RelayP2 (on/off) value = OFF (0x0) read successful.
I (7245) MASTER_TEST: Characteristic #0 Data_channel_0 (Volts) value = 0.000000 (0x0) read successful.
I (7325) MASTER_TEST: Characteristic #1 Humidity_1 (%rH) value = 0.000000 (0x0) read successful.
I (7405) MASTER_TEST: Characteristic #2 Temperature_1 (C) value = 0.000000 (0x0) read successful.
I (7485) MASTER_TEST: Characteristic #3 Humidity_2 (%rH) value = 0.000000 (0x0) read successful.
I (7565) MASTER_TEST: Characteristic #4 Temperature_2 (C) value = 0.000000 (0x0) read successful.
I (7645) MASTER_TEST: Characteristic #5 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (7645) MASTER_TEST: Characteristic #6 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (7725) MASTER_TEST: Characteristic #7 RelayP1 (on/off) value = OFF (0x0) read successful.
I (7795) MASTER_TEST: Characteristic #8 RelayP2 (on/off) value = OFF (0x0) read successful.
I (7885) MASTER_TEST: Characteristic #0 Data_channel_0 (Volts) value = 0.000000 (0x0) read successful.
I (7965) MASTER_TEST: Characteristic #1 Humidity_1 (%rH) value = 0.000000 (0x0) read successful.
I (8045) MASTER_TEST: Characteristic #2 Temperature_1 (C) value = 0.000000 (0x0) read successful.
I (8125) MASTER_TEST: Characteristic #3 Humidity_2 (%rH) value = 0.000000 (0x0) read successful.
I (8205) MASTER_TEST: Characteristic #4 Temperature_2 (C) value = 0.000000 (0x0) read successful.
I (8285) MASTER_TEST: Characteristic #5 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (8285) MASTER_TEST: Characteristic #6 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (8355) MASTER_TEST: Characteristic #7 RelayP1 (on/off) value = OFF (0x0) read successful.
I (8435) MASTER_TEST: Characteristic #8 RelayP2 (on/off) value = OFF (0x0) read successful.
I (8525) MASTER_TEST: Characteristic #0 Data_channel_0 (Volts) value = 0.000000 (0x0) read successful.
I (8605) MASTER_TEST: Characteristic #1 Humidity_1 (%rH) value = 0.000000 (0x0) read successful.
I (8685) MASTER_TEST: Characteristic #2 Temperature_1 (C) value = 0.000000 (0x0) read successful.
I (8765) MASTER_TEST: Characteristic #3 Humidity_2 (%rH) value = 0.000000 (0x0) read successful.
I (8845) MASTER_TEST: Characteristic #4 Temperature_2 (C) value = 0.000000 (0x0) read successful.
I (8925) MASTER_TEST: Characteristic #5 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (8925) MASTER_TEST: Characteristic #6 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (8995) MASTER_TEST: Characteristic #7 RelayP1 (on/off) value = OFF (0x0) read successful.
I (9075) MASTER_TEST: Characteristic #8 RelayP2 (on/off) value = OFF (0x0) read successful.
I (9165) MASTER_TEST: Characteristic #0 Data_channel_0 (Volts) value = 0.000000 (0x0) read successful.
I (9245) MASTER_TEST: Characteristic #1 Humidity_1 (%rH) value = 0.000000 (0x0) read successful.
I (9325) MASTER_TEST: Characteristic #2 Temperature_1 (C) value = 0.000000 (0x0) read successful.
I (9405) MASTER_TEST: Characteristic #3 Humidity_2 (%rH) value = 0.000000 (0x0) read successful.
I (9485) MASTER_TEST: Characteristic #4 Temperature_2 (C) value = 0.000000 (0x0) read successful.
I (9565) MASTER_TEST: Characteristic #5 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (9565) MASTER_TEST: Characteristic #6 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (9635) MASTER_TEST: Characteristic #7 RelayP1 (on/off) value = OFF (0x0) read successful.
I (9715) MASTER_TEST: Characteristic #8 RelayP2 (on/off) value = OFF (0x0) read successful.
I (9805) MASTER_TEST: Characteristic #0 Data_channel_0 (Volts) value = 0.000000 (0x0) read successful.
I (9885) MASTER_TEST: Characteristic #1 Humidity_1 (%rH) value = 0.000000 (0x0) read successful.
I (9965) MASTER_TEST: Characteristic #2 Temperature_1 (C) value = 0.000000 (0x0) read successful.
I (10045) MASTER_TEST: Characteristic #3 Humidity_2 (%rH) value = 0.000000 (0x0) read successful.
I (10125) MASTER_TEST: Characteristic #4 Temperature_2 (C) value = 0.000000 (0x0) read successful.
I (10205) MASTER_TEST: Characteristic #5 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (10205) MASTER_TEST: Characteristic #6 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (10275) MASTER_TEST: Characteristic #7 RelayP1 (on/off) value = OFF (0x0) read successful.
I (10355) MASTER_TEST: Characteristic #8 RelayP2 (on/off) value = OFF (0x0) read successful.
I (10445) MASTER_TEST: Characteristic #0 Data_channel_0 (Volts) value = 0.000000 (0x0) read successful.
I (10525) MASTER_TEST: Characteristic #1 Humidity_1 (%rH) value = 0.000000 (0x0) read successful.
I (10605) MASTER_TEST: Characteristic #2 Temperature_1 (C) value = 0.000000 (0x0) read successful.
I (10685) MASTER_TEST: Characteristic #3 Humidity_2 (%rH) value = 0.000000 (0x0) read successful.
I (10765) MASTER_TEST: Characteristic #4 Temperature_2 (C) value = 0.000000 (0x0) read successful.
I (10845) MASTER_TEST: Characteristic #5 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (10845) MASTER_TEST: Characteristic #6 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (10915) MASTER_TEST: Characteristic #7 RelayP1 (on/off) value = OFF (0x0) read successful.
I (10995) MASTER_TEST: Characteristic #8 RelayP2 (on/off) value = OFF (0x0) read successful.
I (11075) MASTER_TEST: Characteristic #0 Data_channel_0 (Volts) value = 0.000000 (0x0) read successful.
I (11165) MASTER_TEST: Characteristic #1 Humidity_1 (%rH) value = 0.000000 (0x0) read successful.
I (11245) MASTER_TEST: Characteristic #2 Temperature_1 (C) value = 0.000000 (0x0) read successful.
I (11325) MASTER_TEST: Characteristic #3 Humidity_2 (%rH) value = 0.000000 (0x0) read successful.
I (11395) MASTER_TEST: Characteristic #4 Temperature_2 (C) value = 0.000000 (0x0) read successful.
I (11485) MASTER_TEST: Characteristic #5 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (11485) MASTER_TEST: Characteristic #6 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (11555) MASTER_TEST: Characteristic #7 RelayP1 (on/off) value = OFF (0x0) read successful.
I (11635) MASTER_TEST: Characteristic #8 RelayP2 (on/off) value = OFF (0x0) read successful.
I (11725) MASTER_TEST: Characteristic #0 Data_channel_0 (Volts) value = 0.000000 (0x0) read successful.
I (11805) MASTER_TEST: Characteristic #1 Humidity_1 (%rH) value = 0.000000 (0x0) read successful.
I (11875) MASTER_TEST: Characteristic #2 Temperature_1 (C) value = 0.000000 (0x0) read successful.
I (11965) MASTER_TEST: Characteristic #3 Humidity_2 (%rH) value = 0.000000 (0x0) read successful.
I (12045) MASTER_TEST: Characteristic #4 Temperature_2 (C) value = 0.000000 (0x0) read successful.
I (12125) MASTER_TEST: Characteristic #5 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (12125) MASTER_TEST: Characteristic #6 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (12195) MASTER_TEST: Characteristic #7 RelayP1 (on/off) value = OFF (0x0) read successful.
I (12275) MASTER_TEST: Characteristic #8 RelayP2 (on/off) value = OFF (0x0) read successful.
I (12355) MASTER_TEST: Characteristic #0 Data_channel_0 (Volts) value = 0.000000 (0x0) read successful.
I (12445) MASTER_TEST: Characteristic #1 Humidity_1 (%rH) value = 0.000000 (0x0) read successful.
I (12515) MASTER_TEST: Characteristic #2 Temperature_1 (C) value = 0.000000 (0x0) read successful.
I (12605) MASTER_TEST: Characteristic #3 Humidity_2 (%rH) value = 0.000000 (0x0) read successful.
I (12675) MASTER_TEST: Characteristic #4 Temperature_2 (C) value = 0.000000 (0x0) read successful.
I (12705) wifi:state: run -> init (0)
I (12705) wifi:pm stop, total sleep time: 9734471 us / 10744002 us

I (12705) wifi:new:<1,0>, old:<1,0>, ap:<255,255>, sta:<1,0>, prof:1
I (12745) wifi:flush txq
I (12745) wifi:stop sw txq
I (12745) wifi:lmac stop hw txq
ets Jun  8 2016 00:22:57

rst:0xc (SW_CPU_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:4
load:0x3fff0034,len:6972
load:0x40078000,len:14332
ho 0 tail 12 room 4
load:0x40080400,len:3672
0x40080400: _init at ??:?

entry 0x40080678
I (31) boot: ESP-IDF v4.3-dev-2398-g2bfdd036b 2nd stage bootloader
I (31) boot: compile time 12:13:26
I (31) boot: chip revision: 1
I (35) boot_comm: chip revision: 1, min. bootloader chip revision: 0
I (42) boot.esp32: SPI Speed      : 40MHz
I (47) boot.esp32: SPI Mode       : DIO
I (51) boot.esp32: SPI Flash Size : 4MB
I (56) boot: Enabling RNG early entropy source...
I (61) boot: Partition Table:
I (65) boot: ## Label            Usage          Type ST Offset   Length
I (72) boot:  0 nvs              WiFi data        01 02 00009000 00004000
I (80) boot:  1 otadata          OTA data         01 00 0000d000 00002000
I (87) boot:  2 phy_init         RF data          01 01 0000f000 00001000
I (95) boot:  3 factory          factory app      00 00 00010000 00100000
I (102) boot:  4 ota_0            OTA app          00 10 00110000 00100000
I (110) boot:  5 ota_1            OTA app          00 11 00210000 00100000
I (117) boot: End of partition table
I (122) boot: Defaulting to factory image
I (126) boot_comm: chip revision: 1, min. application chip revision: 0
I (133) esp_image: segment 0: paddr=00010020 vaddr=3f400020 size=1b374h (111476) map
I (184) esp_image: segment 1: paddr=0002b39c vaddr=3ffb0000 size=03f50h ( 16208) load
I (192) esp_image: segment 2: paddr=0002f2f4 vaddr=40080000 size=00404h (  1028) load
I (192) esp_image: segment 3: paddr=0002f700 vaddr=40080404 size=00918h (  2328) load
I (200) esp_image: segment 4: paddr=00030020 vaddr=400d0020 size=79dc4h (499140) map
I (397) esp_image: segment 5: paddr=000a9dec vaddr=40080d1c size=152cch ( 86732) load
I (448) boot: Loaded app from partition at offset 0x10000
I (448) boot: Disabling RNG early entropy source...
I (459) cpu_start: Pro cpu up.
I (459) cpu_start: Starting app cpu, entry point is 0x40081260
0x40081260: call_start_cpu1 at /Users/nguyentri/esp/esp-idf/components/esp_system/port/cpu_start.c:133

I (444) cpu_start: App cpu up.
I (474) cpu_start: Pro cpu start user code
I (474) cpu_start: cpu freq: 160000000
I (474) cpu_start: Application information:
I (478) cpu_start: Project name:     DaiVietIoT
I (484) cpu_start: App version:      cb6f346-dirty
I (489) cpu_start: Compile time:     Jan 27 2021 23:06:03
I (495) cpu_start: ELF file SHA256:  a9c175cddee84f25...
I (501) cpu_start: ESP-IDF:          v4.3-dev-2398-g2bfdd036b
I (508) heap_init: Initializing. RAM available for dynamic allocation:
I (515) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
I (521) heap_init: At 3FFB8150 len 00027EB0 (159 KiB): DRAM
I (527) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (533) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (540) heap_init: At 40095FE8 len 0000A018 (40 KiB): IRAM
I (547) spi_flash: detected chip: generic
I (551) spi_flash: flash io: dio
I (556) cpu_start: Starting scheduler on PRO CPU.
I (0) cpu_start: Starting scheduler on APP CPU.
I (645) MASTER_TEST: ESP_WIFI_MODE_STA
I (655) wifi:wifi driver task: 3ffc1378, prio:23, stack:6656, core=0
I (655) system_api: Base MAC address is not set
I (655) system_api: read default base MAC address from EFUSE
I (675) wifi:wifi firmware version: 9a688d0
I (675) wifi:wifi certification version: v7.0
I (675) wifi:config NVS flash: enabled
I (675) wifi:config nano formating: disabled
I (685) wifi:Init data frame dynamic rx buffer num: 32
I (685) wifi:Init management frame dynamic rx buffer num: 32
I (695) wifi:Init management short buffer num: 32
I (695) wifi:Init dynamic tx buffer num: 32
I (705) wifi:Init static rx buffer size: 1600
I (705) wifi:Init static rx buffer num: 10
I (715) wifi:Init dynamic rx buffer num: 32
I (715) wifi_init: rx ba win: 6
I (715) wifi_init: tcpip mbox: 32
I (725) wifi_init: udp mbox: 6
I (725) wifi_init: tcp mbox: 6
I (725) wifi_init: tcp tx win: 5744
I (735) wifi_init: tcp rx win: 5744
I (735) wifi_init: tcp mss: 1440
I (745) wifi_init: WiFi IRAM OP enabled
I (745) wifi_init: WiFi RX IRAM OP enabled
I (755) MASTER_TEST: start the WIFI SSID:[www.iotdaiviet2.com]
I (755) phy_init: phy_version 4660,0162888,Dec 23 2020
I (865) wifi:mode : sta (98:f4:ab:22:5d:d8)
I (865) wifi:enable tsf
I (865) MASTER_TEST: Waiting for wifi
I (865) MASTER_TEST: Wi-Fi start handler...
I (905) wifi:new:<1,0>, old:<1,0>, ap:<255,255>, sta:<1,0>, prof:1
I (1925) wifi:state: init -> auth (b0)
I (1935) wifi:state: auth -> assoc (0)
I (1955) wifi:state: assoc -> run (10)
I (1965) wifi:connected with www.iotdaiviet2.com, aid = 9, channel 1, BW20, bssid = 36:32:c8:9d:09:ad
I (1965) wifi:security: WPA2-PSK, phy: bgn, rssi: -76
I (1965) wifi:pm start, type: 1

I (1975) MASTER_TEST: Wi-Fi connect handler...
I (2025) wifi:AP's beacon interval = 102400 us, DTIM period = 2
I (2645) esp_netif_handlers: MASTER_TEST: sta ip: 192.168.43.142, mask: 255.255.255.0, gw: 192.168.43.86
I (2645) MASTER_TEST: Got IPv4 event: Interface "MASTER_TEST: sta" address: 192.168.43.142
I (2655) uart: queue free spaces: 20
I (2705) MASTER_TEST: Modbus master stack initialized...
I (2705) MASTER_TEST: Start modbus test...
I (2775) MASTER_TEST: Characteristic #0 Data_channel_0 (Volts) value = 0.000000 (0x0) read successful.
E (2775) MB_PORT_COMMON: vMBMasterRunResRelease(194): Resource release failure.
I (2845) MASTER_TEST: Characteristic #1 Humidity_1 (%rH) value = 0.000000 (0x0) read successful.
I (2925) MASTER_TEST: Characteristic #2 Temperature_1 (C) value = 0.000000 (0x0) read successful.
I (3005) MASTER_TEST: Characteristic #3 Humidity_2 (%rH) value = 0.000000 (0x0) read successful.
I (3095) MASTER_TEST: Characteristic #4 Temperature_2 (C) value = 0.000000 (0x0) read successful.
I (3165) MASTER_TEST: Characteristic #5 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (3175) MASTER_TEST: Characteristic #6 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (3245) MASTER_TEST: Characteristic #7 RelayP1 (on/off) value = OFF (0x0) read successful.
I (3325) MASTER_TEST: Characteristic #8 RelayP2 (on/off) value = OFF (0x0) read successful.
I (3405) MASTER_TEST: Characteristic #0 Data_channel_0 (Volts) value = 0.000000 (0x0) read successful.
I (3485) MASTER_TEST: Characteristic #1 Humidity_1 (%rH) value = 0.000000 (0x0) read successful.
I (3565) MASTER_TEST: Characteristic #2 Temperature_1 (C) value = 0.000000 (0x0) read successful.
I (3645) MASTER_TEST: Characteristic #3 Humidity_2 (%rH) value = 0.000000 (0x0) read successful.
I (3735) MASTER_TEST: Characteristic #4 Temperature_2 (C) value = 0.000000 (0x0) read successful.
I (3805) MASTER_TEST: Characteristic #5 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (3815) MASTER_TEST: Characteristic #6 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (3885) MASTER_TEST: Characteristic #7 RelayP1 (on/off) value = OFF (0x0) read successful.
I (3965) MASTER_TEST: Characteristic #8 RelayP2 (on/off) value = OFF (0x0) read successful.
I (4035) MASTER_TEST: Characteristic #0 Data_channel_0 (Volts) value = 0.000000 (0x0) read successful.
I (4115) MASTER_TEST: Characteristic #1 Humidity_1 (%rH) value = 0.000000 (0x0) read successful.
I (4195) MASTER_TEST: Characteristic #2 Temperature_1 (C) value = 0.000000 (0x0) read successful.
I (4275) MASTER_TEST: Characteristic #3 Humidity_2 (%rH) value = 0.000000 (0x0) read successful.
I (4355) MASTER_TEST: Characteristic #4 Temperature_2 (C) value = 0.000000 (0x0) read successful.
I (4435) MASTER_TEST: Characteristic #5 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (4435) MASTER_TEST: Characteristic #6 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (4515) MASTER_TEST: Characteristic #7 RelayP1 (on/off) value = OFF (0x0) read successful.
I (4595) MASTER_TEST: Characteristic #8 RelayP2 (on/off) value = OFF (0x0) read successful.
I (4675) MASTER_TEST: Characteristic #0 Data_channel_0 (Volts) value = 0.000000 (0x0) read successful.
I (4755) MASTER_TEST: Characteristic #1 Humidity_1 (%rH) value = 0.000000 (0x0) read successful.
I (4835) MASTER_TEST: Characteristic #2 Temperature_1 (C) value = 0.000000 (0x0) read successful.
I (4915) MASTER_TEST: Characteristic #3 Humidity_2 (%rH) value = 0.000000 (0x0) read successful.
I (4995) MASTER_TEST: Characteristic #4 Temperature_2 (C) value = 0.000000 (0x0) read successful.
I (5075) MASTER_TEST: Characteristic #5 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (5075) MASTER_TEST: Characteristic #6 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (5155) MASTER_TEST: Characteristic #7 RelayP1 (on/off) value = OFF (0x0) read successful.
I (5235) MASTER_TEST: Characteristic #8 RelayP2 (on/off) value = OFF (0x0) read successful.
I (5315) MASTER_TEST: Characteristic #0 Data_channel_0 (Volts) value = 0.000000 (0x0) read successful.
I (5395) MASTER_TEST: Characteristic #1 Humidity_1 (%rH) value = 0.000000 (0x0) read successful.
I (5475) MASTER_TEST: Characteristic #2 Temperature_1 (C) value = 0.000000 (0x0) read successful.
I (5555) MASTER_TEST: Characteristic #3 Humidity_2 (%rH) value = 0.000000 (0x0) read successful.
I (5635) MASTER_TEST: Characteristic #4 Temperature_2 (C) value = 0.000000 (0x0) read successful.
I (5715) MASTER_TEST: Characteristic #5 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (5715) MASTER_TEST: Characteristic #6 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (5785) MASTER_TEST: Characteristic #7 RelayP1 (on/off) value = OFF (0x0) read successful.
I (5855) MASTER_TEST: Characteristic #8 RelayP2 (on/off) value = OFF (0x0) read successful.
I (5935) MASTER_TEST: Characteristic #0 Data_channel_0 (Volts) value = 0.000000 (0x0) read successful.
I (6015) MASTER_TEST: Characteristic #1 Humidity_1 (%rH) value = 0.000000 (0x0) read successful.
I (6095) MASTER_TEST: Characteristic #2 Temperature_1 (C) value = 0.000000 (0x0) read successful.
I (6175) MASTER_TEST: Characteristic #3 Humidity_2 (%rH) value = 0.000000 (0x0) read successful.
I (6255) MASTER_TEST: Characteristic #4 Temperature_2 (C) value = 0.000000 (0x0) read successful.
I (6335) MASTER_TEST: Characteristic #5 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (6335) MASTER_TEST: Characteristic #6 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (6415) MASTER_TEST: Characteristic #7 RelayP1 (on/off) value = OFF (0x0) read successful.
I (6495) MASTER_TEST: Characteristic #8 RelayP2 (on/off) value = OFF (0x0) read successful.
I (6575) MASTER_TEST: Characteristic #0 Data_channel_0 (Volts) value = 0.000000 (0x0) read successful.
I (6655) MASTER_TEST: Characteristic #1 Humidity_1 (%rH) value = 0.000000 (0x0) read successful.
I (6735) MASTER_TEST: Characteristic #2 Temperature_1 (C) value = 0.000000 (0x0) read successful.
I (6815) MASTER_TEST: Characteristic #3 Humidity_2 (%rH) value = 0.000000 (0x0) read successful.
I (6895) MASTER_TEST: Characteristic #4 Temperature_2 (C) value = 0.000000 (0x0) read successful.
I (6975) MASTER_TEST: Characteristic #5 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (6975) MASTER_TEST: Characteristic #6 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (7055) MASTER_TEST: Characteristic #7 RelayP1 (on/off) value = OFF (0x0) read successful.
I (7135) MASTER_TEST: Characteristic #8 RelayP2 (on/off) value = OFF (0x0) read successful.
I (7215) MASTER_TEST: Characteristic #0 Data_channel_0 (Volts) value = 0.000000 (0x0) read successful.
I (7295) MASTER_TEST: Characteristic #1 Humidity_1 (%rH) value = 0.000000 (0x0) read successful.
I (7375) MASTER_TEST: Characteristic #2 Temperature_1 (C) value = 0.000000 (0x0) read successful.
I (7455) MASTER_TEST: Characteristic #3 Humidity_2 (%rH) value = 0.000000 (0x0) read successful.
I (7535) MASTER_TEST: Characteristic #4 Temperature_2 (C) value = 0.000000 (0x0) read successful.
I (7615) MASTER_TEST: Characteristic #5 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (7615) MASTER_TEST: Characteristic #6 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (7695) MASTER_TEST: Characteristic #7 RelayP1 (on/off) value = OFF (0x0) read successful.
I (7775) MASTER_TEST: Characteristic #8 RelayP2 (on/off) value = OFF (0x0) read successful.
I (7855) MASTER_TEST: Characteristic #0 Data_channel_0 (Volts) value = 0.000000 (0x0) read successful.
I (7935) MASTER_TEST: Characteristic #1 Humidity_1 (%rH) value = 0.000000 (0x0) read successful.
I (8015) MASTER_TEST: Characteristic #2 Temperature_1 (C) value = 0.000000 (0x0) read successful.
I (8095) MASTER_TEST: Characteristic #3 Humidity_2 (%rH) value = 0.000000 (0x0) read successful.
I (8175) MASTER_TEST: Characteristic #4 Temperature_2 (C) value = 0.000000 (0x0) read successful.
I (8255) MASTER_TEST: Characteristic #5 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (8255) MASTER_TEST: Characteristic #6 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (8335) MASTER_TEST: Characteristic #7 RelayP1 (on/off) value = OFF (0x0) read successful.
I (8415) MASTER_TEST: Characteristic #8 RelayP2 (on/off) value = OFF (0x0) read successful.
I (8495) MASTER_TEST: Characteristic #0 Data_channel_0 (Volts) value = 0.000000 (0x0) read successful.
I (8575) MASTER_TEST: Characteristic #1 Humidity_1 (%rH) value = 0.000000 (0x0) read successful.
I (8655) MASTER_TEST: Characteristic #2 Temperature_1 (C) value = 0.000000 (0x0) read successful.
I (8735) MASTER_TEST: Characteristic #3 Humidity_2 (%rH) value = 0.000000 (0x0) read successful.
I (8815) MASTER_TEST: Characteristic #4 Temperature_2 (C) value = 0.000000 (0x0) read successful.
I (8895) MASTER_TEST: Characteristic #5 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (8895) MASTER_TEST: Characteristic #6 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (8975) MASTER_TEST: Characteristic #7 RelayP1 (on/off) value = OFF (0x0) read successful.
I (9055) MASTER_TEST: Characteristic #8 RelayP2 (on/off) value = OFF (0x0) read successful.
I (9135) MASTER_TEST: Characteristic #0 Data_channel_0 (Volts) value = 0.000000 (0x0) read successful.
I (9215) MASTER_TEST: Characteristic #1 Humidity_1 (%rH) value = 0.000000 (0x0) read successful.
I (9295) MASTER_TEST: Characteristic #2 Temperature_1 (C) value = 0.000000 (0x0) read successful.
I (9375) MASTER_TEST: Characteristic #3 Humidity_2 (%rH) value = 0.000000 (0x0) read successful.
I (9455) MASTER_TEST: Characteristic #4 Temperature_2 (C) value = 0.000000 (0x0) read successful.
I (9535) MASTER_TEST: Characteristic #5 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (9535) MASTER_TEST: Characteristic #6 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (9615) MASTER_TEST: Characteristic #7 RelayP1 (on/off) value = OFF (0x0) read successful.
I (9695) MASTER_TEST: Characteristic #8 RelayP2 (on/off) value = OFF (0x0) read successful.
I (9775) MASTER_TEST: Characteristic #0 Data_channel_0 (Volts) value = 0.000000 (0x0) read successful.
I (9855) MASTER_TEST: Characteristic #1 Humidity_1 (%rH) value = 0.000000 (0x0) read successful.
I (9935) MASTER_TEST: Characteristic #2 Temperature_1 (C) value = 0.000000 (0x0) read successful.
I (10015) MASTER_TEST: Characteristic #3 Humidity_2 (%rH) value = 0.000000 (0x0) read successful.
I (10095) MASTER_TEST: Characteristic #4 Temperature_2 (C) value = 0.000000 (0x0) read successful.
I (10175) MASTER_TEST: Characteristic #5 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (10175) MASTER_TEST: Characteristic #6 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (10255) MASTER_TEST: Characteristic #7 RelayP1 (on/off) value = OFF (0x0) read successful.
I (10335) MASTER_TEST: Characteristic #8 RelayP2 (on/off) value = OFF (0x0) read successful.
I (10415) MASTER_TEST: Characteristic #0 Data_channel_0 (Volts) value = 0.000000 (0x0) read successful.
I (10495) MASTER_TEST: Characteristic #1 Humidity_1 (%rH) value = 0.000000 (0x0) read successful.
I (10575) MASTER_TEST: Characteristic #2 Temperature_1 (C) value = 0.000000 (0x0) read successful.
I (10655) MASTER_TEST: Characteristic #3 Humidity_2 (%rH) value = 0.000000 (0x0) read successful.
I (10735) MASTER_TEST: Characteristic #4 Temperature_2 (C) value = 0.000000 (0x0) read successful.
I (10815) MASTER_TEST: Characteristic #5 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (10815) MASTER_TEST: Characteristic #6 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (10895) MASTER_TEST: Characteristic #7 RelayP1 (on/off) value = OFF (0x0) read successful.
I (10975) MASTER_TEST: Characteristic #8 RelayP2 (on/off) value = OFF (0x0) read successful.
I (11055) MASTER_TEST: Characteristic #0 Data_channel_0 (Volts) value = 0.000000 (0x0) read successful.
I (11135) MASTER_TEST: Characteristic #1 Humidity_1 (%rH) value = 0.000000 (0x0) read successful.
I (11215) MASTER_TEST: Characteristic #2 Temperature_1 (C) value = 0.000000 (0x0) read successful.
I (11295) MASTER_TEST: Characteristic #3 Humidity_2 (%rH) value = 0.000000 (0x0) read successful.
I (11385) MASTER_TEST: Characteristic #4 Temperature_2 (C) value = 0.000000 (0x0) read successful.
I (11455) MASTER_TEST: Characteristic #5 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (11455) MASTER_TEST: Characteristic #6 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (11535) MASTER_TEST: Characteristic #7 RelayP1 (on/off) value = OFF (0x0) read successful.
I (11615) MASTER_TEST: Characteristic #8 RelayP2 (on/off) value = OFF (0x0) read successful.
I (11695) MASTER_TEST: Characteristic #0 Data_channel_0 (Volts) value = 0.000000 (0x0) read successful.
I (11775) MASTER_TEST: Characteristic #1 Humidity_1 (%rH) value = 0.000000 (0x0) read successful.
I (11855) MASTER_TEST: Characteristic #2 Temperature_1 (C) value = 0.000000 (0x0) read successful.
I (11935) MASTER_TEST: Characteristic #3 Humidity_2 (%rH) value = 0.000000 (0x0) read successful.
I (12015) MASTER_TEST: Characteristic #4 Temperature_2 (C) value = 0.000000 (0x0) read successful.
I (12095) MASTER_TEST: Characteristic #5 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (12095) MASTER_TEST: Characteristic #6 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (12175) MASTER_TEST: Characteristic #7 RelayP1 (on/off) value = OFF (0x0) read successful.
I (12255) MASTER_TEST: Characteristic #8 RelayP2 (on/off) value = OFF (0x0) read successful.
I (12335) MASTER_TEST: Characteristic #0 Data_channel_0 (Volts) value = 0.000000 (0x0) read successful.
I (12415) MASTER_TEST: Characteristic #1 Humidity_1 (%rH) value = 0.000000 (0x0) read successful.
I (12495) MASTER_TEST: Characteristic #2 Temperature_1 (C) value = 0.000000 (0x0) read successful.
I (12575) MASTER_TEST: Characteristic #3 Humidity_2 (%rH) value = 0.000000 (0x0) read successful.
I (12655) MASTER_TEST: Characteristic #4 Temperature_2 (C) value = 0.000000 (0x0) read successful.
I (12705) wifi:state: run -> init (0)
I (12705) wifi:pm stop, total sleep time: 10077995 us / 10730476 us

I (12705) wifi:new:<1,0>, old:<1,0>, ap:<255,255>, sta:<1,0>, prof:1
I (12735) wifi:flush txq
I (12735) wifi:stop sw txq
I (12735) wifi:lmac stop hw txq
ets Jun  8 2016 00:22:57

rst:0xc (SW_CPU_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:4
load:0x3fff0034,len:6972
load:0x40078000,len:14332
ho 0 tail 12 room 4
load:0x40080400,len:3672
0x40080400: _init at ??:?

entry 0x40080678
I (31) boot: ESP-IDF v4.3-dev-2398-g2bfdd036b 2nd stage bootloader
I (31) boot: compile time 12:13:26
I (31) boot: chip revision: 1
I (35) boot_comm: chip revision: 1, min. bootloader chip revision: 0
I (42) boot.esp32: SPI Speed      : 40MHz
I (47) boot.esp32: SPI Mode       : DIO
I (51) boot.esp32: SPI Flash Size : 4MB
I (56) boot: Enabling RNG early entropy source...
I (61) boot: Partition Table:
I (65) boot: ## Label            Usage          Type ST Offset   Length
I (72) boot:  0 nvs              WiFi data        01 02 00009000 00004000
I (80) boot:  1 otadata          OTA data         01 00 0000d000 00002000
I (87) boot:  2 phy_init         RF data          01 01 0000f000 00001000
I (95) boot:  3 factory          factory app      00 00 00010000 00100000
I (102) boot:  4 ota_0            OTA app          00 10 00110000 00100000
I (110) boot:  5 ota_1            OTA app          00 11 00210000 00100000
I (117) boot: End of partition table
I (122) boot: Defaulting to factory image
I (126) boot_comm: chip revision: 1, min. application chip revision: 0
I (133) esp_image: segment 0: paddr=00010020 vaddr=3f400020 size=1b374h (111476) map
I (184) esp_image: segment 1: paddr=0002b39c vaddr=3ffb0000 size=03f50h ( 16208) load
I (192) esp_image: segment 2: paddr=0002f2f4 vaddr=40080000 size=00404h (  1028) load
I (192) esp_image: segment 3: paddr=0002f700 vaddr=40080404 size=00918h (  2328) load
I (200) esp_image: segment 4: paddr=00030020 vaddr=400d0020 size=79dc4h (499140) map
I (397) esp_image: segment 5: paddr=000a9dec vaddr=40080d1c size=152cch ( 86732) load
I (448) boot: Loaded app from partition at offset 0x10000
I (448) boot: Disabling RNG early entropy source...
I (459) cpu_start: Pro cpu up.
I (459) cpu_start: Starting app cpu, entry point is 0x40081260
0x40081260: call_start_cpu1 at /Users/nguyentri/esp/esp-idf/components/esp_system/port/cpu_start.c:133

I (444) cpu_start: App cpu up.
I (474) cpu_start: Pro cpu start user code
I (474) cpu_start: cpu freq: 160000000
I (474) cpu_start: Application information:
I (478) cpu_start: Project name:     DaiVietIoT
I (484) cpu_start: App version:      cb6f346-dirty
I (489) cpu_start: Compile time:     Jan 27 2021 23:06:03
I (495) cpu_start: ELF file SHA256:  a9c175cddee84f25...
I (501) cpu_start: ESP-IDF:          v4.3-dev-2398-g2bfdd036b
I (508) heap_init: Initializing. RAM available for dynamic allocation:
I (515) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
I (521) heap_init: At 3FFB8150 len 00027EB0 (159 KiB): DRAM
I (527) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (533) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (540) heap_init: At 40095FE8 len 0000A018 (40 KiB): IRAM
I (547) spi_flash: detected chip: generic
I (551) spi_flash: flash io: dio
I (556) cpu_start: Starting scheduler on PRO CPU.
I (0) cpu_start: Starting scheduler on APP CPU.
I (645) MASTER_TEST: ESP_WIFI_MODE_STA
I (655) wifi:wifi driver task: 3ffc1378, prio:23, stack:6656, core=0
I (655) system_api: Base MAC address is not set
I (655) system_api: read default base MAC address from EFUSE
I (675) wifi:wifi firmware version: 9a688d0
I (675) wifi:wifi certification version: v7.0
I (675) wifi:config NVS flash: enabled
I (675) wifi:config nano formating: disabled
I (685) wifi:Init data frame dynamic rx buffer num: 32
I (685) wifi:Init management frame dynamic rx buffer num: 32
I (695) wifi:Init management short buffer num: 32
I (695) wifi:Init dynamic tx buffer num: 32
I (705) wifi:Init static rx buffer size: 1600
I (705) wifi:Init static rx buffer num: 10
I (715) wifi:Init dynamic rx buffer num: 32
I (715) wifi_init: rx ba win: 6
I (715) wifi_init: tcpip mbox: 32
I (725) wifi_init: udp mbox: 6
I (725) wifi_init: tcp mbox: 6
I (725) wifi_init: tcp tx win: 5744
I (735) wifi_init: tcp rx win: 5744
I (735) wifi_init: tcp mss: 1440
I (745) wifi_init: WiFi IRAM OP enabled
I (745) wifi_init: WiFi RX IRAM OP enabled
I (755) MASTER_TEST: start the WIFI SSID:[www.iotdaiviet2.com]
I (755) phy_init: phy_version 4660,0162888,Dec 23 2020
I (855) wifi:mode : sta (98:f4:ab:22:5d:d8)
I (865) wifi:enable tsf
I (865) MASTER_TEST: Waiting for wifi
I (865) MASTER_TEST: Wi-Fi start handler...
I (905) wifi:new:<1,0>, old:<1,0>, ap:<255,255>, sta:<1,0>, prof:1
I (1925) wifi:state: init -> auth (b0)
I (1935) wifi:state: auth -> assoc (0)
I (1955) wifi:state: assoc -> run (10)
I (1975) wifi:connected with www.iotdaiviet2.com, aid = 10, channel 1, BW20, bssid = 36:32:c8:9d:09:ad
I (1975) wifi:security: WPA2-PSK, phy: bgn, rssi: -74
I (1975) wifi:pm start, type: 1

I (1975) MASTER_TEST: Wi-Fi connect handler...
I (2025) wifi:AP's beacon interval = 102400 us, DTIM period = 2
I (2645) esp_netif_handlers: MASTER_TEST: sta ip: 192.168.43.142, mask: 255.255.255.0, gw: 192.168.43.86
I (2645) MASTER_TEST: Got IPv4 event: Interface "MASTER_TEST: sta" address: 192.168.43.142
I (2655) uart: queue free spaces: 20
- Users/nguyentri/esp/esp-idf/components/freertos/event_groups.c:531 (xEventGroupSetBits)- assert failed!

- abort() was called at PC 0x4008b5f3 on core 0
- 0x4008b5f3: xEventGroupSetBits at /Users/nguyentri/esp/esp-idf/components/freertos/event_groups.c:531 (discriminator 1)

- Backtrace:0x40088a8b:0x3ffbc500 0x40089295:0x3ffbc520 0x4009028a:0x3ffbc540 0x4008b5f3:0x3ffbc5b0 - - - 0x4008b6cd:0x3ffbc5d0 0x4008b9ed:0x3ffbc5f0 0x4008bafb:0x3ffbc630 0x4008bbfd:0x3ffbc660
- 0x40088a8b: panic_abort at /Users/nguyentri/esp/esp-idf/components/esp_system/panic.c:356

- 0x40089295: esp_system_abort at /Users/nguyentri/esp/esp-idf/components/esp_system/system_api.c:108

- 0x4009028a: abort at /Users/nguyentri/esp/esp-idf/components/newlib/abort.c:46

- 0x4008b5f3: xEventGroupSetBits at /Users/nguyentri/esp/esp-idf/components/freertos/event_groups.c:531 (discriminator 1)

- 0x4008b6cd: vEventGroupSetBitsCallback at /Users/nguyentri/esp/esp-idf/components/freertos/event_groups.c:661

- 0x4008b9ed: prvProcessReceivedCommands at /Users/nguyentri/esp/esp-idf/components/freertos/timers.c:731(discriminator 2)

- 0x4008bafb: prvTimerTask at /Users/nguyentri/esp/esp-idf/components/freertos/timers.c:558 (discriminator 1)

- 0x4008bbfd: vPortTaskWrapper at /Users/nguyentri/esp/esp-idf/components/freertos/port/xtensa/port.c:168

ELF file SHA256: a9c175cddee84f25

Rebooting...
ets Jun  8 2016 00:22:57

rst:0xc (SW_CPU_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:4
load:0x3fff0034,len:6972
load:0x40078000,len:14332
ho 0 tail 12 room 4
load:0x40080400,len:3672
0x40080400: _init at ??:?

entry 0x40080678
I (31) boot: ESP-IDF v4.3-dev-2398-g2bfdd036b 2nd stage bootloader
I (31) boot: compile time 12:13:26
I (31) boot: chip revision: 1
I (35) boot_comm: chip revision: 1, min. bootloader chip revision: 0
I (42) boot.esp32: SPI Speed      : 40MHz
I (47) boot.esp32: SPI Mode       : DIO
I (51) boot.esp32: SPI Flash Size : 4MB
I (56) boot: Enabling RNG early entropy source...
I (61) boot: Partition Table:
I (65) boot: ## Label            Usage          Type ST Offset   Length
I (72) boot:  0 nvs              WiFi data        01 02 00009000 00004000
I (80) boot:  1 otadata          OTA data         01 00 0000d000 00002000
I (87) boot:  2 phy_init         RF data          01 01 0000f000 00001000
I (95) boot:  3 factory          factory app      00 00 00010000 00100000
I (102) boot:  4 ota_0            OTA app          00 10 00110000 00100000
I (110) boot:  5 ota_1            OTA app          00 11 00210000 00100000
I (117) boot: End of partition table
I (122) boot: Defaulting to factory image
I (126) boot_comm: chip revision: 1, min. application chip revision: 0
I (133) esp_image: segment 0: paddr=00010020 vaddr=3f400020 size=1b374h (111476) map
I (184) esp_image: segment 1: paddr=0002b39c vaddr=3ffb0000 size=03f50h ( 16208) load
I (192) esp_image: segment 2: paddr=0002f2f4 vaddr=40080000 size=00404h (  1028) load
I (192) esp_image: segment 3: paddr=0002f700 vaddr=40080404 size=00918h (  2328) load
I (200) esp_image: segment 4: paddr=00030020 vaddr=400d0020 size=79dc4h (499140) map
I (397) esp_image: segment 5: paddr=000a9dec vaddr=40080d1c size=152cch ( 86732) load
I (448) boot: Loaded app from partition at offset 0x10000
I (448) boot: Disabling RNG early entropy source...
I (459) cpu_start: Pro cpu up.
I (459) cpu_start: Starting app cpu, entry point is 0x40081260
0x40081260: call_start_cpu1 at /Users/nguyentri/esp/esp-idf/components/esp_system/port/cpu_start.c:133

I (444) cpu_start: App cpu up.
I (474) cpu_start: Pro cpu start user code
I (474) cpu_start: cpu freq: 160000000
I (474) cpu_start: Application information:
I (478) cpu_start: Project name:     DaiVietIoT
I (484) cpu_start: App version:      cb6f346-dirty
I (489) cpu_start: Compile time:     Jan 27 2021 23:06:03
I (495) cpu_start: ELF file SHA256:  a9c175cddee84f25...
I (501) cpu_start: ESP-IDF:          v4.3-dev-2398-g2bfdd036b
I (508) heap_init: Initializing. RAM available for dynamic allocation:
I (515) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
I (521) heap_init: At 3FFB8150 len 00027EB0 (159 KiB): DRAM
I (527) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (533) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (540) heap_init: At 40095FE8 len 0000A018 (40 KiB): IRAM
I (547) spi_flash: detected chip: generic
I (551) spi_flash: flash io: dio
I (556) cpu_start: Starting scheduler on PRO CPU.
I (0) cpu_start: Starting scheduler on APP CPU.
I (645) MASTER_TEST: ESP_WIFI_MODE_STA
I (655) wifi:wifi driver task: 3ffc1378, prio:23, stack:6656, core=0
I (655) system_api: Base MAC address is not set
I (655) system_api: read default base MAC address from EFUSE
I (675) wifi:wifi firmware version: 9a688d0
I (675) wifi:wifi certification version: v7.0
I (675) wifi:config NVS flash: enabled
I (675) wifi:config nano formating: disabled
I (685) wifi:Init data frame dynamic rx buffer num: 32
I (685) wifi:Init management frame dynamic rx buffer num: 32
I (695) wifi:Init management short buffer num: 32
I (695) wifi:Init dynamic tx buffer num: 32
I (705) wifi:Init static rx buffer size: 1600
I (705) wifi:Init static rx buffer num: 10
I (715) wifi:Init dynamic rx buffer num: 32
I (715) wifi_init: rx ba win: 6
I (715) wifi_init: tcpip mbox: 32
I (725) wifi_init: udp mbox: 6
I (725) wifi_init: tcp mbox: 6
I (725) wifi_init: tcp tx win: 5744
I (735) wifi_init: tcp rx win: 5744
I (735) wifi_init: tcp mss: 1440
I (745) wifi_init: WiFi IRAM OP enabled
I (745) wifi_init: WiFi RX IRAM OP enabled
I (755) MASTER_TEST: start the WIFI SSID:[www.iotdaiviet2.com]
I (755) phy_init: phy_version 4660,0162888,Dec 23 2020
I (855) wifi:mode : sta (98:f4:ab:22:5d:d8)
I (865) wifi:enable tsf
I (865) MASTER_TEST: Waiting for wifi
I (865) MASTER_TEST: Wi-Fi start handler...
I (905) wifi:new:<1,0>, old:<1,0>, ap:<255,255>, sta:<1,0>, prof:1
I (1925) wifi:state: init -> auth (b0)
I (1925) wifi:state: auth -> init (1c0)
I (1935) wifi:new:<1,0>, old:<1,0>, ap:<255,255>, sta:<1,0>, prof:1
I (1935) MASTER_TEST: Wi-Fi disconnected, trying to reconnect...
I (3985) MASTER_TEST: Wi-Fi disconnected, trying to reconnect...
I (3995) wifi:new:<1,0>, old:<1,0>, ap:<255,255>, sta:<1,0>, prof:1
I (3995) wifi:state: init -> auth (b0)
I (3995) wifi:state: auth -> assoc (0)
I (4025) wifi:state: assoc -> run (10)
I (4035) wifi:connected with www.iotdaiviet2.com, aid = 2, channel 1, BW20, bssid = 36:32:c8:9d:09:ad
I (4035) wifi:security: WPA2-PSK, phy: bgn, rssi: -73
I (4045) wifi:pm start, type: 1

I (4045) MASTER_TEST: Wi-Fi connect handler...
I (4075) wifi:AP's beacon interval = 102400 us, DTIM period = 2
I (4645) esp_netif_handlers: MASTER_TEST: sta ip: 192.168.43.142, mask: 255.255.255.0, gw: 192.168.43.86
I (4645) MASTER_TEST: Got IPv4 event: Interface "MASTER_TEST: sta" address: 192.168.43.142
I (4655) uart: queue free spaces: 20
I (4705) MASTER_TEST: Modbus master stack initialized...
I (4705) MASTER_TEST: Start modbus test...
I (4775) MASTER_TEST: Characteristic #0 Data_channel_0 (Volts) value = 0.000000 (0x0) read successful.
I (4855) MASTER_TEST: Characteristic #1 Humidity_1 (%rH) value = 0.000000 (0x0) read successful.
I (4935) MASTER_TEST: Characteristic #2 Temperature_1 (C) value = 0.000000 (0x0) read successful.
I (5015) MASTER_TEST: Characteristic #3 Humidity_2 (%rH) value = 0.000000 (0x0) read successful.
I (5095) MASTER_TEST: Characteristic #4 Temperature_2 (C) value = 0.000000 (0x0) read successful.
I (5175) MASTER_TEST: Characteristic #5 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (5175) MASTER_TEST: Characteristic #6 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (5255) MASTER_TEST: Characteristic #7 RelayP1 (on/off) value = OFF (0x0) read successful.
I (5335) MASTER_TEST: Characteristic #8 RelayP2 (on/off) value = OFF (0x0) read successful.
I (5415) MASTER_TEST: Characteristic #0 Data_channel_0 (Volts) value = 0.000000 (0x0) read successful.
I (5495) MASTER_TEST: Characteristic #1 Humidity_1 (%rH) value = 0.000000 (0x0) read successful.
I (5575) MASTER_TEST: Characteristic #2 Temperature_1 (C) value = 0.000000 (0x0) read successful.
I (5655) MASTER_TEST: Characteristic #3 Humidity_2 (%rH) value = 0.000000 (0x0) read successful.
I (5735) MASTER_TEST: Characteristic #4 Temperature_2 (C) value = 0.000000 (0x0) read successful.
I (5815) MASTER_TEST: Characteristic #5 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (5815) MASTER_TEST: Characteristic #6 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (5895) MASTER_TEST: Characteristic #7 RelayP1 (on/off) value = OFF (0x0) read successful.
I (5975) MASTER_TEST: Characteristic #8 RelayP2 (on/off) value = OFF (0x0) read successful.
I (6055) MASTER_TEST: Characteristic #0 Data_channel_0 (Volts) value = 0.000000 (0x0) read successful.
I (6135) MASTER_TEST: Characteristic #1 Humidity_1 (%rH) value = 0.000000 (0x0) read successful.
I (6215) MASTER_TEST: Characteristic #2 Temperature_1 (C) value = 0.000000 (0x0) read successful.
I (6295) MASTER_TEST: Characteristic #3 Humidity_2 (%rH) value = 0.000000 (0x0) read successful.
I (6375) MASTER_TEST: Characteristic #4 Temperature_2 (C) value = 0.000000 (0x0) read successful.
I (6455) MASTER_TEST: Characteristic #5 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (6455) MASTER_TEST: Characteristic #6 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (6535) MASTER_TEST: Characteristic #7 RelayP1 (on/off) value = OFF (0x0) read successful.
I (6615) MASTER_TEST: Characteristic #8 RelayP2 (on/off) value = OFF (0x0) read successful.
I (6695) MASTER_TEST: Characteristic #0 Data_channel_0 (Volts) value = 0.000000 (0x0) read successful.
I (6775) MASTER_TEST: Characteristic #1 Humidity_1 (%rH) value = 0.000000 (0x0) read successful.
I (6855) MASTER_TEST: Characteristic #2 Temperature_1 (C) value = 0.000000 (0x0) read successful.
I (6935) MASTER_TEST: Characteristic #3 Humidity_2 (%rH) value = 0.000000 (0x0) read successful.
I (7015) MASTER_TEST: Characteristic #4 Temperature_2 (C) value = 0.000000 (0x0) read successful.
I (7095) MASTER_TEST: Characteristic #5 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (7095) MASTER_TEST: Characteristic #6 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (7175) MASTER_TEST: Characteristic #7 RelayP1 (on/off) value = OFF (0x0) read successful.
I (7255) MASTER_TEST: Characteristic #8 RelayP2 (on/off) value = OFF (0x0) read successful.
I (7335) MASTER_TEST: Characteristic #0 Data_channel_0 (Volts) value = 0.000000 (0x0) read successful.
I (7415) MASTER_TEST: Characteristic #1 Humidity_1 (%rH) value = 0.000000 (0x0) read successful.
I (7495) MASTER_TEST: Characteristic #2 Temperature_1 (C) value = 0.000000 (0x0) read successful.
I (7575) MASTER_TEST: Characteristic #3 Humidity_2 (%rH) value = 0.000000 (0x0) read successful.
I (7655) MASTER_TEST: Characteristic #4 Temperature_2 (C) value = 0.000000 (0x0) read successful.
I (7735) MASTER_TEST: Characteristic #5 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (7735) MASTER_TEST: Characteristic #6 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (7815) MASTER_TEST: Characteristic #7 RelayP1 (on/off) value = OFF (0x0) read successful.
I (7895) MASTER_TEST: Characteristic #8 RelayP2 (on/off) value = OFF (0x0) read successful.
I (7975) MASTER_TEST: Characteristic #0 Data_channel_0 (Volts) value = 0.000000 (0x0) read successful.
I (8055) MASTER_TEST: Characteristic #1 Humidity_1 (%rH) value = 0.000000 (0x0) read successful.
I (8135) MASTER_TEST: Characteristic #2 Temperature_1 (C) value = 0.000000 (0x0) read successful.
I (8215) MASTER_TEST: Characteristic #3 Humidity_2 (%rH) value = 0.000000 (0x0) read successful.
I (8295) MASTER_TEST: Characteristic #4 Temperature_2 (C) value = 0.000000 (0x0) read successful.
I (8375) MASTER_TEST: Characteristic #5 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (8375) MASTER_TEST: Characteristic #6 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (8455) MASTER_TEST: Characteristic #7 RelayP1 (on/off) value = OFF (0x0) read successful.
I (8535) MASTER_TEST: Characteristic #8 RelayP2 (on/off) value = OFF (0x0) read successful.
I (8615) MASTER_TEST: Characteristic #0 Data_channel_0 (Volts) value = 0.000000 (0x0) read successful.
I (8695) MASTER_TEST: Characteristic #1 Humidity_1 (%rH) value = 0.000000 (0x0) read successful.
I (8775) MASTER_TEST: Characteristic #2 Temperature_1 (C) value = 0.000000 (0x0) read successful.
I (8855) MASTER_TEST: Characteristic #3 Humidity_2 (%rH) value = 0.000000 (0x0) read successful.
I (8935) MASTER_TEST: Characteristic #4 Temperature_2 (C) value = 0.000000 (0x0) read successful.
I (9015) MASTER_TEST: Characteristic #5 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (9015) MASTER_TEST: Characteristic #6 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (9095) MASTER_TEST: Characteristic #7 RelayP1 (on/off) value = OFF (0x0) read successful.
I (9175) MASTER_TEST: Characteristic #8 RelayP2 (on/off) value = OFF (0x0) read successful.
I (9255) MASTER_TEST: Characteristic #0 Data_channel_0 (Volts) value = 0.000000 (0x0) read successful.
I (9335) MASTER_TEST: Characteristic #1 Humidity_1 (%rH) value = 0.000000 (0x0) read successful.
I (9415) MASTER_TEST: Characteristic #2 Temperature_1 (C) value = 0.000000 (0x0) read successful.
I (9495) MASTER_TEST: Characteristic #3 Humidity_2 (%rH) value = 0.000000 (0x0) read successful.
I (9575) MASTER_TEST: Characteristic #4 Temperature_2 (C) value = 0.000000 (0x0) read successful.
I (9655) MASTER_TEST: Characteristic #5 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (9655) MASTER_TEST: Characteristic #6 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (9735) MASTER_TEST: Characteristic #7 RelayP1 (on/off) value = OFF (0x0) read successful.
I (9805) MASTER_TEST: Characteristic #8 RelayP2 (on/off) value = OFF (0x0) read successful.
I (9895) MASTER_TEST: Characteristic #0 Data_channel_0 (Volts) value = 0.000000 (0x0) read successful.
I (9975) MASTER_TEST: Characteristic #1 Humidity_1 (%rH) value = 0.000000 (0x0) read successful.
I (10055) MASTER_TEST: Characteristic #2 Temperature_1 (C) value = 0.000000 (0x0) read successful.
I (10135) MASTER_TEST: Characteristic #3 Humidity_2 (%rH) value = 0.000000 (0x0) read successful.
I (10215) MASTER_TEST: Characteristic #4 Temperature_2 (C) value = 0.000000 (0x0) read successful.
I (10295) MASTER_TEST: Characteristic #5 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (10295) MASTER_TEST: Characteristic #6 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (10365) MASTER_TEST: Characteristic #7 RelayP1 (on/off) value = OFF (0x0) read successful.
I (10445) MASTER_TEST: Characteristic #8 RelayP2 (on/off) value = OFF (0x0) read successful.
I (10535) MASTER_TEST: Characteristic #0 Data_channel_0 (Volts) value = 0.000000 (0x0) read successful.
I (10615) MASTER_TEST: Characteristic #1 Humidity_1 (%rH) value = 0.000000 (0x0) read successful.
I (10695) MASTER_TEST: Characteristic #2 Temperature_1 (C) value = 0.000000 (0x0) read successful.
I (10775) MASTER_TEST: Characteristic #3 Humidity_2 (%rH) value = 0.000000 (0x0) read successful.
I (10855) MASTER_TEST: Characteristic #4 Temperature_2 (C) value = 0.000000 (0x0) read successful.
I (10935) MASTER_TEST: Characteristic #5 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (10935) MASTER_TEST: Characteristic #6 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (11005) MASTER_TEST: Characteristic #7 RelayP1 (on/off) value = OFF (0x0) read successful.
I (11085) MASTER_TEST: Characteristic #8 RelayP2 (on/off) value = OFF (0x0) read successful.
I (11175) MASTER_TEST: Characteristic #0 Data_channel_0 (Volts) value = 0.000000 (0x0) read successful.
I (11255) MASTER_TEST: Characteristic #1 Humidity_1 (%rH) value = 0.000000 (0x0) read successful.
I (11335) MASTER_TEST: Characteristic #2 Temperature_1 (C) value = 0.000000 (0x0) read successful.
I (11415) MASTER_TEST: Characteristic #3 Humidity_2 (%rH) value = 0.000000 (0x0) read successful.
I (11495) MASTER_TEST: Characteristic #4 Temperature_2 (C) value = 0.000000 (0x0) read successful.
I (11575) MASTER_TEST: Characteristic #5 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (11575) MASTER_TEST: Characteristic #6 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (11645) MASTER_TEST: Characteristic #7 RelayP1 (on/off) value = OFF (0x0) read successful.
I (11725) MASTER_TEST: Characteristic #8 RelayP2 (on/off) value = OFF (0x0) read successful.
I (11795) MASTER_TEST: Characteristic #0 Data_channel_0 (Volts) value = 0.000000 (0x0) read successful.
I (11875) MASTER_TEST: Characteristic #1 Humidity_1 (%rH) value = 0.000000 (0x0) read successful.
I (11955) MASTER_TEST: Characteristic #2 Temperature_1 (C) value = 0.000000 (0x0) read successful.
I (12035) MASTER_TEST: Characteristic #3 Humidity_2 (%rH) value = 0.000000 (0x0) read successful.
I (12115) MASTER_TEST: Characteristic #4 Temperature_2 (C) value = 0.000000 (0x0) read successful.
I (12195) MASTER_TEST: Characteristic #5 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (12195) MASTER_TEST: Characteristic #6 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (12275) MASTER_TEST: Characteristic #7 RelayP1 (on/off) value = OFF (0x0) read successful.
I (12355) MASTER_TEST: Characteristic #8 RelayP2 (on/off) value = OFF (0x0) read successful.
I (12435) MASTER_TEST: Characteristic #0 Data_channel_0 (Volts) value = 0.000000 (0x0) read successful.
I (12515) MASTER_TEST: Characteristic #1 Humidity_1 (%rH) value = 0.000000 (0x0) read successful.
I (12595) MASTER_TEST: Characteristic #2 Temperature_1 (C) value = 0.000000 (0x0) read successful.
I (12675) MASTER_TEST: Characteristic #3 Humidity_2 (%rH) value = 0.000000 (0x0) read successful.
I (12755) MASTER_TEST: Characteristic #4 Temperature_2 (C) value = 0.000000 (0x0) read successful.
I (12835) MASTER_TEST: Characteristic #5 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (12835) MASTER_TEST: Characteristic #6 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (12915) MASTER_TEST: Characteristic #7 RelayP1 (on/off) value = OFF (0x0) read successful.
I (12995) MASTER_TEST: Characteristic #8 RelayP2 (on/off) value = OFF (0x0) read successful.
I (13075) MASTER_TEST: Characteristic #0 Data_channel_0 (Volts) value = 0.000000 (0x0) read successful.
I (13155) MASTER_TEST: Characteristic #1 Humidity_1 (%rH) value = 0.000000 (0x0) read successful.
I (13235) MASTER_TEST: Characteristic #2 Temperature_1 (C) value = 0.000000 (0x0) read successful.
I (13315) MASTER_TEST: Characteristic #3 Humidity_2 (%rH) value = 0.000000 (0x0) read successful.
I (13395) MASTER_TEST: Characteristic #4 Temperature_2 (C) value = 0.000000 (0x0) read successful.
I (13475) MASTER_TEST: Characteristic #5 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (13475) MASTER_TEST: Characteristic #6 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (13555) MASTER_TEST: Characteristic #7 RelayP1 (on/off) value = OFF (0x0) read successful.
I (13635) MASTER_TEST: Characteristic #8 RelayP2 (on/off) value = OFF (0x0) read successful.
I (13715) MASTER_TEST: Characteristic #0 Data_channel_0 (Volts) value = 0.000000 (0x0) read successful.
I (13795) MASTER_TEST: Characteristic #1 Humidity_1 (%rH) value = 0.000000 (0x0) read successful.
I (13875) MASTER_TEST: Characteristic #2 Temperature_1 (C) value = 0.000000 (0x0) read successful.
I (13955) MASTER_TEST: Characteristic #3 Humidity_2 (%rH) value = 0.000000 (0x0) read successful.
I (14035) MASTER_TEST: Characteristic #4 Temperature_2 (C) value = 0.000000 (0x0) read successful.
I (14115) MASTER_TEST: Characteristic #5 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (14115) MASTER_TEST: Characteristic #6 Humidity_3 (%rH) value = 0.000000 (0x0) read successful.
I (14195) MASTER_TEST: Characteristic #7 RelayP1 (on/off) value = OFF (0x0) read successful.
I (14275) MASTER_TEST: Characteristic #8 RelayP2 (on/off) value = OFF (0x0) read successful.
I (14355) MASTER_TEST: Characteristic #0 Data_channel_0 (Volts) value = 0.000000 (0x0) read successful.
I (14435) MASTER_TEST: Characteristic #1 Humidity_1 (%rH) value = 0.000000 (0x0) read successful.
I (14515) MASTER_TEST: Characteristic #2 Temperature_1 (C) value = 0.000000 (0x0) read successful.
I (14595) MASTER_TEST: Characteristic #3 Humidity_2 (%rH) value = 0.000000 (0x0) read successful.
I (14675) MASTER_TEST: Characteristic #4 Temperature_2 (C) value = 0.000000 (0x0) read successful.
I (14705) wifi:state: run -> init (0)
I (14705) wifi:pm stop, total sleep time: 10002274 us / 10658783 us

I (14705) wifi:new:<1,0>, old:<1,0>, ap:<255,255>, sta:<1,0>, prof:1
I (14735) wifi:flush txq
I (14735) wifi:stop sw txq
I (14735) wifi:lmac stop hw txq
ets Jun  8 2016 00:22:57

rst:0xc (SW_CPU_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:4
load:0x3fff0034,len:6972
load:0x40078000,len:14332
ho 0 tail 12 room 4
load:0x40080400,len:3672
0x40080400: _init at ??:?

entry 0x40080678
alisitsyn commented 3 years ago

Hi @NguyenMinhTri,

Thank you for detailed report. I will let you know if found something new. Thanks.

alisitsyn commented 3 years ago

@NguyenMinhTri,

Thank you again for this issue. I was able to reproduce it and find possible solution. Here are some suggestions:

  1. In general, calling esp_restart should work both in task or even wifi callback. However it is not recommended doing complicated stuff in the wifi callback functions like Modbus initialization, start and so on. If the stack sufficient you can do more complex things there and it is not the reason for the issue but it is still not good approach.

I would propose to do it as in the app_main() or other task as below:

void app_main(void)
{
    //Initialize NVS
    esp_err_t ret = nvs_flash_init();
    if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) {
        ESP_ERROR_CHECK(nvs_flash_erase());
        ret = nvs_flash_init();
    }
    ESP_ERROR_CHECK(ret);
    ESP_LOGI(MASTER_TAG, "ESP_WIFI_MODE_STA");
    wifi_init();
    ESP_ERROR_CHECK(master_init());

    xTaskCreate(&master_operation_func, "modbus_task", 16384, NULL, 5, operation_task_handle);
    vTaskDelay(300);
    esp_restart();
  1. The Modbus uses timer groups to measure some related timeouts. I think due to a bug in the esp_restart_noos() this function does not reset the group timer peripheral correctly and causes the issue after restart.

Please apply the patch below to fix this issue.

0001_fix_esp_restart_does_not_reset_timer_groups_periph.diff

Please let me know if it works for your project. Thanks.

NguyenMinhTri commented 3 years ago

Hi @alisitsyn, thank you for supporting. I have applied your path then it worked on my project.

alisitsyn commented 3 years ago

Hi @NguyenMinhTri,

Thanks for update. The MR with this fix is under review. The issue will be closed once the MR is merged.

Alvin1Zhang commented 3 years ago

Thanks for reporting, fix on master branch is available at https://github.com/espressif/esp-idf/commit/f40ae9cae93f9ab6ac55c5cdaf82332272fc222e.

AxelLin commented 2 years ago

v4.3: e48f87468e290c8ec485d134614e3d77639e9cb5, this can be closed.

Alvin1Zhang commented 2 years ago

Thanks for sharing the updates, feel free to reopen if the issue happens again. Thanks.