Modbus power meter working with eModbus (Arduino), need insight(s) for FreeModbus (ESP-IDF)

brainstorm
Posts: 27
Joined: Mon Dec 12, 2016 12:22 pm

Modbus power meter working with eModbus (Arduino), need insight(s) for FreeModbus (ESP-IDF)

Postby brainstorm » Sat Mar 26, 2022 1:05 pm

Hello!

I've successfully setup an ESP32S2 Saola board with eModbus (https://emodbus.github.io), so I know for sure that there are no hardware issues and the values shown in the power meter's display match what I'm seeing over the Modbus-RTU twisted pair, see this thread for in-depth details on how I got the hardware up and running w/ Arduino:

https://github.com/eModbus/eModbus/discussions/166

Working with Arduino first:

Code: Select all

  // Relevant holding registers and example values:
  //
  //  0011:    0.193   <--- Amps panel 1
  //  0013:    0.258   <--- Amps panel 2
  //  0015:    0.210   <--- Amps panel 3
  //  0017:  219.600   <--- W total
  //  0019:   57.200   <--- var total

  //  0039:  105.200   <--- VA total
  //  0041:  236.550   <--- Volts panel 1
  //  0043:  236.580   <--- Volts panel 2
  //  0045:  236.480   <--- Volts panel 3

  //  001B:    0.828   <--- PF
  //  001D:   49.951   <--- Hz

  //  001F:    0.000   <---  uh
  //  0021:    0.070   <---  -uh
  //  0023:    0.000   <---  uAh
  //  0025:    0.030   <---  -uAh
Helped me put together the CID table I'd later use on the ESP-IDF branch (https://github.com/brainstorm/yigedianq ... #L122-L155) on which I use PlatformIO with ESP-IDF version 4.4.0 (via platform = https://github.com/tasmota/platform-esp ... asmota/203 branch on platform.ini):

Code: Select all

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_HOLD_DATA_0, STR("Amps_phase_1"), STR("A"), MB_DEVICE_ADDR1, MB_PARAM_HOLDING, 0x11, 2,
            HOLD_OFFSET(holding_data0), PARAM_TYPE_FLOAT, 4, OPTS( 0, 5000, .001 ), PAR_PERMS_READ },
    { CID_HOLD_DATA_1, STR("Amps_phase_2"), STR("A"), MB_DEVICE_ADDR1, MB_PARAM_HOLDING, 0x13, 2,
            HOLD_OFFSET(holding_data1), PARAM_TYPE_FLOAT, 4, OPTS( 0, 5000, .001 ), PAR_PERMS_READ },
    { CID_HOLD_DATA_2, STR("Amps_phase_3"), STR("A"), MB_DEVICE_ADDR1, MB_PARAM_HOLDING, 0x15, 2,
            HOLD_OFFSET(holding_data2), PARAM_TYPE_FLOAT, 4, OPTS( 0, 5000, .001 ), PAR_PERMS_READ },
    { CID_HOLD_DATA_3, STR("Watts"), STR("W"), MB_DEVICE_ADDR1, MB_PARAM_HOLDING, 0x17, 2,
            HOLD_OFFSET(holding_data3), PARAM_TYPE_FLOAT, 4, OPTS( 0, 5000, .001 ), PAR_PERMS_READ },
    { CID_HOLD_DATA_4, STR("var"), STR("W"), MB_DEVICE_ADDR1, MB_PARAM_HOLDING, 0x19, 2,
            HOLD_OFFSET(holding_data4), PARAM_TYPE_FLOAT, 4, OPTS( 0, 5000, .001 ), PAR_PERMS_READ },
    { CID_HOLD_DATA_5, STR("VA"), STR("VA"), MB_DEVICE_ADDR1, MB_PARAM_HOLDING, 0x39, 2,
            HOLD_OFFSET(holding_data5), PARAM_TYPE_FLOAT, 4, OPTS( 0, 400, .001 ), PAR_PERMS_READ },
    { CID_HOLD_DATA_6, STR("Volts_phase_1"), STR("V"), MB_DEVICE_ADDR1, MB_PARAM_HOLDING, 0x41, 2,
            HOLD_OFFSET(holding_data6), PARAM_TYPE_FLOAT, 4, OPTS( 0, 400, .001 ), PAR_PERMS_READ },
    { CID_HOLD_DATA_7, STR("Volts_phase_2"), STR("V"), MB_DEVICE_ADDR1, MB_PARAM_HOLDING, 0x43, 2,
            HOLD_OFFSET(holding_data7), PARAM_TYPE_FLOAT, 4, OPTS( 0, 400, .001 ), PAR_PERMS_READ },
    { CID_HOLD_DATA_8, STR("Volts_phase_3"), STR("V"), MB_DEVICE_ADDR1, MB_PARAM_HOLDING, 0x45, 2,
            HOLD_OFFSET(holding_data8), PARAM_TYPE_FLOAT, 4, OPTS( 0, 400, .001 ), PAR_PERMS_READ },
    { CID_HOLD_DATA_9, STR("PF"), STR(""), MB_DEVICE_ADDR1, MB_PARAM_HOLDING, 0x1B, 2,
            HOLD_OFFSET(holding_data9), PARAM_TYPE_FLOAT, 4, OPTS( 0, 1, .001 ), PAR_PERMS_READ },
    { CID_HOLD_DATA_10, STR("Hz"), STR("Hz"), MB_DEVICE_ADDR1, MB_PARAM_HOLDING, 0x1D, 2,
            HOLD_OFFSET(holding_data10), PARAM_TYPE_FLOAT, 4, OPTS( 0, 60, .001 ), PAR_PERMS_READ },
    { CID_HOLD_DATA_11, STR("uh"), STR("Wh"), MB_DEVICE_ADDR1, MB_PARAM_HOLDING, 0x1F, 2,
            HOLD_OFFSET(holding_data11), PARAM_TYPE_FLOAT, 4, OPTS( 0, 10000, .001 ), PAR_PERMS_READ },
    { CID_HOLD_DATA_12, STR("-uh"), STR("Wh"), MB_DEVICE_ADDR1, MB_PARAM_HOLDING, 0x21, 2,
            HOLD_OFFSET(holding_data12), PARAM_TYPE_FLOAT, 4, OPTS( 0, 10000, .001 ), PAR_PERMS_READ },
    { CID_HOLD_DATA_13, STR("uAh"), STR("Wh"), MB_DEVICE_ADDR1, MB_PARAM_HOLDING, 0x23, 2,
            HOLD_OFFSET(holding_data13), PARAM_TYPE_FLOAT, 4, OPTS( 0, 10000, .001 ), PAR_PERMS_READ },
    { CID_HOLD_DATA_14, STR("-uAh"), STR("Wh"), MB_DEVICE_ADDR1, MB_PARAM_HOLDING, 0x25, 2,
            HOLD_OFFSET(holding_data14), PARAM_TYPE_FLOAT, 4, OPTS( 0, 1000, .001 ), PAR_PERMS_READ },
};
Now I'm trying to tilt up the same experiment with ESP-IDF instead, since the RainMaker integration seems to be more mature for ESP-IDF (see: viewtopic.php?f=41&t=26552). See this branch for my work in progress w/ ESP-IDF:

https://github.com/brainstorm/yigedianq ... -rainmaker

Unfortunately I'm getting non stable and completely out of range values out of the code above, see the output logs from the serial dongle:

https://hardbin.com/ipfs/QmX8d9wYPyV51k ... z5ZpH2jUrq

For instance, in TL;DR form:

I (4202) app_modbus: Characteristic #0 Amps_phase_1 (A) value = -0.000000 (0xa2343fb4) read successful.
I (7142) app_modbus: Characteristic #0 Amps_phase_1 (A) value = 9896461401915671303770759400200863744.000000 (0x7cee3fa7) read successful.
I (10082) app_modbus: Characteristic #0 Amps_phase_1 (A) value = 41405882368.000000 (0x511a3fba) read successful.

So I suspect this is a case of not properly initialized variables or registers? Perhaps timing or race condition issues? Incorrect type casting?

Other than reviewing other user's ESP-IDF Modbus repo (solved) issues and this Forum's posts, I've noticed that Alex Lisitsyn (https://github.com/alisitsyn) has been extremely helpful troubleshooting other user's issues. I hope this post gets noticed by him or somebody else so that I get to finish up this project properly :)

brainstorm
Posts: 27
Joined: Mon Dec 12, 2016 12:22 pm

Re: Modbus power meter working with eModbus (Arduino), need insight(s) for FreeModbus (ESP-IDF)

Postby brainstorm » Sat Mar 26, 2022 4:02 pm

I've now removed the alarm code from the modbus master example (in https://github.com/brainstorm/yigedianq ... 09093d5e65) and it seems to iterate through the rest of the CID table, but the numbers do not look right at all still.

The FreeModbus raw buffer responses look a bit shorter than those from eModbus (see https://github.com/eModbus/eModbus/disc ... nt-2386579), which tells me that I might be either requesting too few bytes or reading the wrong ones when they are available on the buffer after a ModBus response. The dongle flashes on the RX/TX LEDs, so the readout is unlikely to be an uninitialized region of memory?

Also, the message "MB_MASTER_SERIAL: Timeout occured, processed: 10 bytes" concerns me too, I don't know if timeouts are supposed to occur, I'll check the esp-idf FreeModbus code to figure more things out of this.

Code: Select all

D (14970) intr_alloc: Connected src 38 to int 12 (cpu 0)
D (14970) MB_PORT_COMMON: xMBMasterPortSerialInit Init serial.
D (14980) intr_alloc: Connected src 15 to int 13 (cpu 0)
D (14980) MB_PORT_COMMON: eMBMasterRTUInit: Port exit critical
D (14990) MB_PORT_COMMON: eMBMasterRTUStart: Port enter critical.
D (14990) MB_PORT_COMMON: eMBMasterRTUStart: Port exit critical
I (15050) app_modbus: Modbus master stack initialized...
I (15050) app_modbus: Reading modbus holding registers from power meter...
D (15150) MB_PORT_COMMON: xMBMasterRunResTake:Take resource (80) (21 ticks).
D (15150) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_FRAME_TRANSMIT
D (15150) POLL transmit buffer: 03 00 11 00 02 
D (15150) MB_PORT_COMMON: eMBMasterRTUSend: Port enter critical.
D (15160) MB_PORT_COMMON: eMBMasterRTUSend: Port exit critical
D (15160) MB_PORT_COMMON: vMBMasterPortTimersRespondTimeoutEnable Respond enable timeout.
D (15170) MB_MASTER_SERIAL: MB_TX_buffer sent: (9) bytes.
D (15180) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_FRAME_SENT
D (15180) POLL sent buffer: 03 00 11 00 02 
D (15190) MB_MASTER_SERIAL: MB_uart[1] event:
D (15190) MB_MASTER_SERIAL: Data event, len: 9.
D (15200) MB_MASTER_SERIAL: Received data: 10(bytes in buffer)

D (15200) MB_MASTER_SERIAL: Timeout occured, processed: 10 bytes
D (15210) MB_PORT_COMMON: eMBMasterRTUReceive: Port enter critical.
D (15220) MB_PORT_COMMON: eMBMasterRTUReceive: Port exit critical
D (15220) MB_PORT_COMMON: eMBMasterPoll: Packet data received successfully (0).
D (15230) POLL receive buffer: 03 04 3f 97 be 77 
D (15230) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_EXECUTE
D (15240) MB_PORT_COMMON: eMBMasterPoll: set event EV_ERROR_OK
D (15240) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_ERROR_PROCESS
D (15250) MB_PORT_COMMON: vMBMasterCBRequestSuccess: Callback request success.
D (15260) MB_PORT_COMMON: vMBMasterRunResRelease: Release resource (80).
D (15270) MB_PORT_COMMON: eMBMasterWaitRequestFinish: returned event = 0x40
D (15270) MB_CONTROLLER_MASTER: mbc_serial_master_get_parameter: Good response for get cid(0) = ESP_OK
I (15380) app_modbus: Characteristic #0 Amps_phase_1 (A) value = -0.241454 (0xbe773f97) read successful.
D (15480) MB_PORT_COMMON: xMBMasterRunResTake:Take resource (80) (21 ticks).
D (15480) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_FRAME_TRANSMIT
D (15480) POLL transmit buffer: 03 00 13 00 02 
D (15480) MB_PORT_COMMON: eMBMasterRTUSend: Port enter critical.
D (15490) MB_PORT_COMMON: eMBMasterRTUSend: Port exit critical
D (15490) MB_PORT_COMMON: vMBMasterPortTimersRespondTimeoutEnable Respond enable timeout.
D (15500) MB_MASTER_SERIAL: MB_TX_buffer sent: (9) bytes.
D (15510) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_FRAME_SENT
D (15510) POLL sent buffer: 03 00 13 00 02 
D (15520) MB_MASTER_SERIAL: MB_uart[1] event:
D (15520) MB_MASTER_SERIAL: Data event, len: 9.
D (15530) MB_MASTER_SERIAL: Received data: 10(bytes in buffer)

D (15530) MB_MASTER_SERIAL: Timeout occured, processed: 10 bytes
D (15540) MB_PORT_COMMON: eMBMasterRTUReceive: Port enter critical.
D (15550) MB_PORT_COMMON: eMBMasterRTUReceive: Port exit critical
D (15550) MB_PORT_COMMON: eMBMasterPoll: Packet data received successfully (0).
D (15560) POLL receive buffer: 03 04 3f 9a 43 fe 
D (15560) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_EXECUTE
D (15570) MB_PORT_COMMON: eMBMasterPoll: set event EV_ERROR_OK
D (15580) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_ERROR_PROCESS
D (15580) MB_PORT_COMMON: vMBMasterCBRequestSuccess: Callback request success.
D (15590) MB_PORT_COMMON: vMBMasterRunResRelease: Release resource (80).
D (15600) MB_PORT_COMMON: eMBMasterWaitRequestFinish: returned event = 0x40
D (15600) MB_CONTROLLER_MASTER: mbc_serial_master_get_parameter: Good response for get cid(1) = ESP_OK
I (15710) app_modbus: Characteristic #1 Amps_phase_2 (A) value = 508.496887 (0x43fe3f9a) read successful.
D (15810) MB_PORT_COMMON: xMBMasterRunResTake:Take resource (80) (21 ticks).
D (15810) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_FRAME_TRANSMIT
D (15810) POLL transmit buffer: 03 00 15 00 02 
D (15810) MB_PORT_COMMON: eMBMasterRTUSend: Port enter critical.
D (15820) MB_PORT_COMMON: eMBMasterRTUSend: Port exit critical
D (15820) MB_PORT_COMMON: vMBMasterPortTimersRespondTimeoutEnable Respond enable timeout.
D (15830) MB_MASTER_SERIAL: MB_TX_buffer sent: (9) bytes.
D (15840) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_FRAME_SENT
D (15840) POLL sent buffer: 03 00 15 00 02 
D (15850) MB_MASTER_SERIAL: MB_uart[1] event:
D (15850) MB_MASTER_SERIAL: Data event, len: 9.
D (15860) MB_MASTER_SERIAL: Received data: 10(bytes in buffer)

D (15860) MB_MASTER_SERIAL: Timeout occured, processed: 10 bytes
D (15870) MB_PORT_COMMON: eMBMasterRTUReceive: Port enter critical.
D (15880) MB_PORT_COMMON: eMBMasterRTUReceive: Port exit critical
D (15880) MB_PORT_COMMON: eMBMasterPoll: Packet data received successfully (0).
D (15890) POLL receive buffer: 03 04 3f 98 89 a0 
D (15890) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_EXECUTE
D (15900) MB_PORT_COMMON: eMBMasterPoll: set event EV_ERROR_OK
D (15910) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_ERROR_PROCESS
D (15910) MB_PORT_COMMON: vMBMasterCBRequestSuccess: Callback request success.
D (15920) MB_PORT_COMMON: vMBMasterRunResRelease: Release resource (80).
D (15930) MB_PORT_COMMON: eMBMasterWaitRequestFinish: returned event = 0x40
D (15930) MB_CONTROLLER_MASTER: mbc_serial_master_get_parameter: Good response for get cid(2) = ESP_OK
I (16040) app_modbus: Characteristic #2 Amps_phase_3 (A) value = -0.000000 (0x89a03f98) read successful.
D (16140) MB_PORT_COMMON: xMBMasterRunResTake:Take resource (80) (21 ticks).
D (16140) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_FRAME_TRANSMIT
D (16140) POLL transmit buffer: 03 00 17 00 02 
D (16140) MB_PORT_COMMON: eMBMasterRTUSend: Port enter critical.
D (16150) MB_PORT_COMMON: eMBMasterRTUSend: Port exit critical
D (16150) MB_PORT_COMMON: vMBMasterPortTimersRespondTimeoutEnable Respond enable timeout.
D (16160) MB_MASTER_SERIAL: MB_TX_buffer sent: (9) bytes.
D (16170) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_FRAME_SENT
D (16170) POLL sent buffer: 03 00 17 00 02 
D (16180) MB_MASTER_SERIAL: MB_uart[1] event:
D (16180) MB_MASTER_SERIAL: Data event, len: 9.
D (16190) MB_MASTER_SERIAL: Received data: 10(bytes in buffer)

D (16190) MB_MASTER_SERIAL: Timeout occured, processed: 10 bytes
D (16200) MB_PORT_COMMON: eMBMasterRTUReceive: Port enter critical.
D (16210) MB_PORT_COMMON: eMBMasterRTUReceive: Port exit critical
D (16210) MB_PORT_COMMON: eMBMasterPoll: Packet data received successfully (0).
D (16220) POLL receive buffer: 03 04 44 3e 4c cd 
D (16220) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_EXECUTE
D (16230) MB_PORT_COMMON: eMBMasterPoll: set event EV_ERROR_OK
D (16240) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_ERROR_PROCESS
D (16240) MB_PORT_COMMON: vMBMasterCBRequestSuccess: Callback request success.
D (16250) MB_PORT_COMMON: vMBMasterRunResRelease: Release resource (80).
D (16260) MB_PORT_COMMON: eMBMasterWaitRequestFinish: returned event = 0x40
D (16260) MB_CONTROLLER_MASTER: mbc_serial_master_get_parameter: Good response for get cid(3) = ESP_OK
I (16370) app_modbus: Characteristic #3 Watts (W) value = 107618800.000000 (0x4ccd443e) read successful.
D (16470) MB_PORT_COMMON: xMBMasterRunResTake:Take resource (80) (21 ticks).
D (16470) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_FRAME_TRANSMIT
D (16470) POLL transmit buffer: 03 00 19 00 02 
D (16470) MB_PORT_COMMON: eMBMasterRTUSend: Port enter critical.
D (16480) MB_PORT_COMMON: eMBMasterRTUSend: Port exit critical
D (16480) MB_PORT_COMMON: vMBMasterPortTimersRespondTimeoutEnable Respond enable timeout.
D (16490) MB_MASTER_SERIAL: MB_TX_buffer sent: (9) bytes.
D (16500) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_FRAME_SENT
D (16500) POLL sent buffer: 03 00 19 00 02 
D (16510) MB_MASTER_SERIAL: MB_uart[1] event:
D (16510) MB_MASTER_SERIAL: Data event, len: 9.
D (16520) MB_MASTER_SERIAL: Received data: 10(bytes in buffer)

D (16520) MB_MASTER_SERIAL: Timeout occured, processed: 10 bytes
D (16530) MB_PORT_COMMON: eMBMasterRTUReceive: Port enter critical.
D (16540) MB_PORT_COMMON: eMBMasterRTUReceive: Port exit critical
D (16540) MB_PORT_COMMON: eMBMasterPoll: Packet data received successfully (0).
D (16550) POLL receive buffer: 03 04 41 20 00 00 
D (16550) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_EXECUTE
D (16560) MB_PORT_COMMON: eMBMasterPoll: set event EV_ERROR_OK
D (16570) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_ERROR_PROCESS
D (16570) MB_PORT_COMMON: vMBMasterCBRequestSuccess: Callback request success.
D (16580) MB_PORT_COMMON: vMBMasterRunResRelease: Release resource (80).
D (16590) MB_PORT_COMMON: eMBMasterWaitRequestFinish: returned event = 0x40
D (16590) MB_CONTROLLER_MASTER: mbc_serial_master_get_parameter: Good response for get cid(4) = ESP_OK
I (16700) app_modbus: Characteristic #4 var (W) value = 0.000000 (0x4120) read successful.
D (16800) MB_PORT_COMMON: xMBMasterRunResTake:Take resource (80) (21 ticks).
D (16800) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_FRAME_TRANSMIT
D (16800) POLL transmit buffer: 03 00 39 00 02 
D (16800) MB_PORT_COMMON: eMBMasterRTUSend: Port enter critical.
D (16810) MB_PORT_COMMON: eMBMasterRTUSend: Port exit critical
D (16810) MB_PORT_COMMON: vMBMasterPortTimersRespondTimeoutEnable Respond enable timeout.
D (16820) MB_MASTER_SERIAL: MB_TX_buffer sent: (9) bytes.
D (16830) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_FRAME_SENT
D (16830) POLL sent buffer: 03 00 39 00 02 
D (16840) MB_MASTER_SERIAL: MB_uart[1] event:
D (16840) MB_MASTER_SERIAL: Data event, len: 9.
D (16850) MB_MASTER_SERIAL: Received data: 10(bytes in buffer)

D (16850) MB_MASTER_SERIAL: Timeout occured, processed: 10 bytes
D (16860) MB_PORT_COMMON: eMBMasterRTUReceive: Port enter critical.
D (16870) MB_PORT_COMMON: eMBMasterRTUReceive: Port exit critical
D (16870) MB_PORT_COMMON: eMBMasterPoll: Packet data received successfully (0).
D (16880) POLL receive buffer: 03 04 44 3e 53 33 
D (16880) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_EXECUTE
D (16890) MB_PORT_COMMON: eMBMasterPoll: set event EV_ERROR_OK
D (16900) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_ERROR_PROCESS
D (16900) MB_PORT_COMMON: vMBMasterCBRequestSuccess: Callback request success.
D (16910) MB_PORT_COMMON: vMBMasterRunResRelease: Release resource (80).
D (16920) MB_PORT_COMMON: eMBMasterWaitRequestFinish: returned event = 0x40
D (16920) MB_CONTROLLER_MASTER: mbc_serial_master_get_parameter: Good response for get cid(5) = ESP_OK
I (17030) app_modbus: Characteristic #5 VA (VA) value = 769944059904.000000 (0x5333443e) read successful.
D (17130) MB_PORT_COMMON: xMBMasterRunResTake:Take resource (80) (21 ticks).
D (17130) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_FRAME_TRANSMIT
D (17130) POLL transmit buffer: 03 00 41 00 02 
D (17130) MB_PORT_COMMON: eMBMasterRTUSend: Port enter critical.
D (17140) MB_PORT_COMMON: eMBMasterRTUSend: Port exit critical
D (17140) MB_PORT_COMMON: vMBMasterPortTimersRespondTimeoutEnable Respond enable timeout.
D (17150) MB_MASTER_SERIAL: MB_TX_buffer sent: (9) bytes.
D (17160) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_FRAME_SENT
D (17160) POLL sent buffer: 03 00 41 00 02 
D (17170) MB_MASTER_SERIAL: MB_uart[1] event:
D (17170) MB_MASTER_SERIAL: Data event, len: 9.
D (17180) MB_MASTER_SERIAL: Received data: 10(bytes in buffer)

D (17180) MB_MASTER_SERIAL: Timeout occured, processed: 10 bytes
D (17190) MB_PORT_COMMON: eMBMasterRTUReceive: Port enter critical.
D (17200) MB_PORT_COMMON: eMBMasterRTUReceive: Port exit critical
D (17200) MB_PORT_COMMON: eMBMasterPoll: Packet data received successfully (0).
D (17210) POLL receive buffer: 03 04 43 55 dc 29 
D (17210) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_EXECUTE
D (17220) MB_PORT_COMMON: eMBMasterPoll: set event EV_ERROR_OK
D (17230) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_ERROR_PROCESS
D (17230) MB_PORT_COMMON: vMBMasterCBRequestSuccess: Callback request success.
D (17240) MB_PORT_COMMON: vMBMasterRunResRelease: Release resource (80).
D (17250) MB_PORT_COMMON: eMBMasterWaitRequestFinish: returned event = 0x40
D (17250) MB_CONTROLLER_MASTER: mbc_serial_master_get_parameter: Good response for get cid(6) = ESP_OK
I (17360) app_modbus: Characteristic #6 Volts_phase_1 (V) value = -190573213661528064.000000 (0xdc294355) read successful.
D (17460) MB_PORT_COMMON: xMBMasterRunResTake:Take resource (80) (21 ticks).
D (17460) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_FRAME_TRANSMIT
D (17460) POLL transmit buffer: 03 00 43 00 02 
D (17460) MB_PORT_COMMON: eMBMasterRTUSend: Port enter critical.
D (17470) MB_PORT_COMMON: eMBMasterRTUSend: Port exit critical
D (17470) MB_PORT_COMMON: vMBMasterPortTimersRespondTimeoutEnable Respond enable timeout.
D (17480) MB_MASTER_SERIAL: MB_TX_buffer sent: (9) bytes.
D (17490) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_FRAME_SENT
D (17490) POLL sent buffer: 03 00 43 00 02 
D (17500) MB_MASTER_SERIAL: MB_uart[1] event:
D (17500) MB_MASTER_SERIAL: Data event, len: 9.
D (17510) MB_MASTER_SERIAL: Received data: 10(bytes in buffer)

D (17510) MB_MASTER_SERIAL: Timeout occured, processed: 10 bytes
D (17520) MB_PORT_COMMON: eMBMasterRTUReceive: Port enter critical.
D (17530) MB_PORT_COMMON: eMBMasterRTUReceive: Port exit critical
D (17530) MB_PORT_COMMON: eMBMasterPoll: Packet data received successfully (0).
D (17540) POLL receive buffer: 03 04 43 55 eb 85 
D (17540) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_EXECUTE
D (17550) MB_PORT_COMMON: eMBMasterPoll: set event EV_ERROR_OK
D (17560) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_ERROR_PROCESS
D (17560) MB_PORT_COMMON: vMBMasterCBRequestSuccess: Callback request success.
D (17570) MB_PORT_COMMON: vMBMasterRunResRelease: Release resource (80).
D (17580) MB_PORT_COMMON: eMBMasterWaitRequestFinish: returned event = 0x40
D (17580) MB_CONTROLLER_MASTER: mbc_serial_master_get_parameter: Good response for get cid(7) = ESP_OK
I (17690) app_modbus: Characteristic #7 Volts_phase_2 (V) value = -322210201072688423554252800.000000 (0xeb854355) read successful.
D (17790) MB_PORT_COMMON: xMBMasterRunResTake:Take resource (80) (21 ticks).
D (17790) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_FRAME_TRANSMIT
D (17790) POLL transmit buffer: 03 00 45 00 02 
D (17790) MB_PORT_COMMON: eMBMasterRTUSend: Port enter critical.
D (17800) MB_PORT_COMMON: eMBMasterRTUSend: Port exit critical
D (17800) MB_PORT_COMMON: vMBMasterPortTimersRespondTimeoutEnable Respond enable timeout.
D (17810) MB_MASTER_SERIAL: MB_TX_buffer sent: (9) bytes.
D (17820) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_FRAME_SENT
D (17820) POLL sent buffer: 03 00 45 00 02 
D (17830) MB_MASTER_SERIAL: MB_uart[1] event:
D (17830) MB_MASTER_SERIAL: Data event, len: 9.
D (17840) MB_MASTER_SERIAL: Received data: 10(bytes in buffer)

D (17840) MB_MASTER_SERIAL: Timeout occured, processed: 10 bytes
D (17850) MB_PORT_COMMON: eMBMasterRTUReceive: Port enter critical.
D (17860) MB_PORT_COMMON: eMBMasterRTUReceive: Port exit critical
D (17860) MB_PORT_COMMON: eMBMasterPoll: Packet data received successfully (0).
D (17870) POLL receive buffer: 03 04 43 55 cf 5c 
D (17870) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_EXECUTE
D (17880) MB_PORT_COMMON: eMBMasterPoll: set event EV_ERROR_OK
D (17890) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_ERROR_PROCESS
D (17890) MB_PORT_COMMON: vMBMasterCBRequestSuccess: Callback request success.
D (17900) MB_PORT_COMMON: vMBMasterRunResRelease: Release resource (80).
D (17910) MB_PORT_COMMON: eMBMasterWaitRequestFinish: returned event = 0x40
D (17910) MB_CONTROLLER_MASTER: mbc_serial_master_get_parameter: Good response for get cid(8) = ESP_OK
I (18020) app_modbus: Characteristic #8 Volts_phase_3 (V) value = -3695400192.000000 (0xcf5c4355) read successful.
D (18120) MB_PORT_COMMON: xMBMasterRunResTake:Take resource (80) (21 ticks).
D (18120) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_FRAME_TRANSMIT
D (18120) POLL transmit buffer: 03 00 1b 00 02 
D (18120) MB_PORT_COMMON: eMBMasterRTUSend: Port enter critical.
D (18130) MB_PORT_COMMON: eMBMasterRTUSend: Port exit critical
D (18130) MB_PORT_COMMON: vMBMasterPortTimersRespondTimeoutEnable Respond enable timeout.
D (18140) MB_MASTER_SERIAL: MB_TX_buffer sent: (9) bytes.
D (18150) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_FRAME_SENT
D (18150) POLL sent buffer: 03 00 1b 00 02 
D (18160) MB_MASTER_SERIAL: MB_uart[1] event:
D (18160) MB_MASTER_SERIAL: Data event, len: 9.
D (18170) MB_MASTER_SERIAL: Received data: 10(bytes in buffer)

D (18170) MB_MASTER_SERIAL: Timeout occured, processed: 10 bytes
D (18180) MB_PORT_COMMON: eMBMasterRTUReceive: Port enter critical.
D (18190) MB_PORT_COMMON: eMBMasterRTUReceive: Port exit critical
D (18190) MB_PORT_COMMON: eMBMasterPoll: Packet data received successfully (0).
D (18200) POLL receive buffer: 03 04 3f 7f be 77 
D (18200) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_EXECUTE
D (18210) MB_PORT_COMMON: eMBMasterPoll: set event EV_ERROR_OK
D (18220) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_ERROR_PROCESS
D (18220) MB_PORT_COMMON: vMBMasterCBRequestSuccess: Callback request success.
D (18230) MB_PORT_COMMON: vMBMasterRunResRelease: Release resource (80).
D (18240) MB_PORT_COMMON: eMBMasterWaitRequestFinish: returned event = 0x40
D (18240) MB_CONTROLLER_MASTER: mbc_serial_master_get_parameter: Good response for get cid(9) = ESP_OK
I (18350) app_modbus: Characteristic #9 PF () value = -0.241453 (0xbe773f7f) read successful.
D (18450) MB_PORT_COMMON: xMBMasterRunResTake:Take resource (80) (21 ticks).
D (18450) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_FRAME_TRANSMIT
D (18450) POLL transmit buffer: 03 00 1d 00 02 
D (18450) MB_PORT_COMMON: eMBMasterRTUSend: Port enter critical.
D (18460) MB_PORT_COMMON: eMBMasterRTUSend: Port exit critical
D (18460) MB_PORT_COMMON: vMBMasterPortTimersRespondTimeoutEnable Respond enable timeout.
D (18470) MB_MASTER_SERIAL: MB_TX_buffer sent: (9) bytes.
D (18480) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_FRAME_SENT
D (18480) POLL sent buffer: 03 00 1d 00 02 
D (18490) MB_MASTER_SERIAL: MB_uart[1] event:
D (18490) MB_MASTER_SERIAL: Data event, len: 9.
D (18500) MB_MASTER_SERIAL: Received data: 10(bytes in buffer)

D (18500) MB_MASTER_SERIAL: Timeout occured, processed: 10 bytes
D (18510) MB_PORT_COMMON: eMBMasterRTUReceive: Port enter critical.
D (18520) MB_PORT_COMMON: eMBMasterRTUReceive: Port exit critical
D (18520) MB_PORT_COMMON: eMBMasterPoll: Packet data received successfully (0).
D (18530) POLL receive buffer: 03 04 42 48 00 00 
D (18530) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_EXECUTE
D (18540) MB_PORT_COMMON: eMBMasterPoll: set event EV_ERROR_OK
D (18550) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_ERROR_PROCESS
D (18550) MB_PORT_COMMON: vMBMasterCBRequestSuccess: Callback request success.
D (18560) MB_PORT_COMMON: vMBMasterRunResRelease: Release resource (80).
D (18570) MB_PORT_COMMON: eMBMasterWaitRequestFinish: returned event = 0x40
D (18570) MB_CONTROLLER_MASTER: mbc_serial_master_get_parameter: Good response for get cid(10) = ESP_OK
I (18680) app_modbus: Characteristic #10 Hz (Hz) value = 0.000000 (0x4248) read successful.
D (18780) MB_PORT_COMMON: xMBMasterRunResTake:Take resource (80) (21 ticks).
D (18780) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_FRAME_TRANSMIT
D (18780) POLL transmit buffer: 03 00 1f 00 02 
D (18780) MB_PORT_COMMON: eMBMasterRTUSend: Port enter critical.
D (18790) MB_PORT_COMMON: eMBMasterRTUSend: Port exit critical
D (18790) MB_PORT_COMMON: vMBMasterPortTimersRespondTimeoutEnable Respond enable timeout.
D (18800) MB_MASTER_SERIAL: MB_TX_buffer sent: (9) bytes.
D (18810) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_FRAME_SENT
D (18810) POLL sent buffer: 03 00 1f 00 02 
D (18820) MB_MASTER_SERIAL: MB_uart[1] event:
D (18820) MB_MASTER_SERIAL: Data event, len: 9.
D (18830) MB_MASTER_SERIAL: Received data: 10(bytes in buffer)

D (18830) MB_MASTER_SERIAL: Timeout occured, processed: 10 bytes
D (18840) MB_PORT_COMMON: eMBMasterRTUReceive: Port enter critical.
D (18850) MB_PORT_COMMON: eMBMasterRTUReceive: Port exit critical
D (18850) MB_PORT_COMMON: eMBMasterPoll: Packet data received successfully (0).
D (18860) POLL receive buffer: 03 04 3d 8f 5c 29 
D (18860) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_EXECUTE
D (18870) MB_PORT_COMMON: eMBMasterPoll: set event EV_ERROR_OK
D (18880) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_ERROR_PROCESS
D (18880) MB_PORT_COMMON: vMBMasterCBRequestSuccess: Callback request success.
D (18890) MB_PORT_COMMON: vMBMasterRunResRelease: Release resource (80).
D (18900) MB_PORT_COMMON: eMBMasterWaitRequestFinish: returned event = 0x40
D (18900) MB_CONTROLLER_MASTER: mbc_serial_master_get_parameter: Good response for get cid(11) = ESP_OK
I (19010) app_modbus: Characteristic #11 uh (Wh) value = 190547821814874112.000000 (0x5c293d8f) read successful.
D (19110) MB_PORT_COMMON: xMBMasterRunResTake:Take resource (80) (21 ticks).
D (19110) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_FRAME_TRANSMIT
D (19110) POLL transmit buffer: 03 00 21 00 02 
D (19110) MB_PORT_COMMON: eMBMasterRTUSend: Port enter critical.
D (19120) MB_PORT_COMMON: eMBMasterRTUSend: Port exit critical
D (19120) MB_PORT_COMMON: vMBMasterPortTimersRespondTimeoutEnable Respond enable timeout.
D (19130) MB_MASTER_SERIAL: MB_TX_buffer sent: (9) bytes.
D (19140) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_FRAME_SENT
D (19140) POLL sent buffer: 03 00 21 00 02 
D (19150) MB_MASTER_SERIAL: MB_uart[1] event:
D (19150) MB_MASTER_SERIAL: Data event, len: 9.
D (19160) MB_MASTER_SERIAL: Received data: 10(bytes in buffer)

D (19160) MB_MASTER_SERIAL: Timeout occured, processed: 10 bytes
D (19170) MB_PORT_COMMON: eMBMasterRTUReceive: Port enter critical.
D (19180) MB_PORT_COMMON: eMBMasterRTUReceive: Port exit critical
D (19180) MB_PORT_COMMON: eMBMasterPoll: Packet data received successfully (0).
D (19190) POLL receive buffer: 03 04 41 a0 7a e1 
D (19190) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_EXECUTE
D (19200) MB_PORT_COMMON: eMBMasterPoll: set event EV_ERROR_OK
D (19210) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_ERROR_PROCESS
D (19210) MB_PORT_COMMON: vMBMasterCBRequestSuccess: Callback request success.
D (19220) MB_PORT_COMMON: vMBMasterRunResRelease: Release resource (80).
D (19230) MB_PORT_COMMON: eMBMasterWaitRequestFinish: returned event = 0x40
D (19230) MB_CONTROLLER_MASTER: mbc_serial_master_get_parameter: Good response for get cid(12) = ESP_OK
I (19340) app_modbus: Characteristic #12 -uh (Wh) value = 584798913150287928645466606220083200.000000 (0x7ae141a0) read successful.
D (19440) MB_PORT_COMMON: xMBMasterRunResTake:Take resource (80) (21 ticks).
D (19440) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_FRAME_TRANSMIT
D (19440) POLL transmit buffer: 03 00 23 00 02 
D (19440) MB_PORT_COMMON: eMBMasterRTUSend: Port enter critical.
D (19450) MB_PORT_COMMON: eMBMasterRTUSend: Port exit critical
D (19450) MB_PORT_COMMON: vMBMasterPortTimersRespondTimeoutEnable Respond enable timeout.
D (19460) MB_MASTER_SERIAL: MB_TX_buffer sent: (9) bytes.
D (19470) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_FRAME_SENT
D (19470) POLL sent buffer: 03 00 23 00 02 
D (19480) MB_MASTER_SERIAL: MB_uart[1] event:
D (19480) MB_MASTER_SERIAL: Data event, len: 9.
D (19490) MB_MASTER_SERIAL: Received data: 10(bytes in buffer)

D (19490) MB_MASTER_SERIAL: Timeout occured, processed: 10 bytes
D (19500) MB_PORT_COMMON: eMBMasterRTUReceive: Port enter critical.
D (19510) MB_PORT_COMMON: eMBMasterRTUReceive: Port exit critical
D (19510) MB_PORT_COMMON: eMBMasterPoll: Packet data received successfully (0).
D (19520) POLL receive buffer: 03 04 3d 75 c2 8f 
D (19520) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_EXECUTE
D (19530) MB_PORT_COMMON: eMBMasterPoll: set event EV_ERROR_OK
D (19540) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_ERROR_PROCESS
D (19540) MB_PORT_COMMON: vMBMasterCBRequestSuccess: Callback request success.
D (19550) MB_PORT_COMMON: vMBMasterRunResRelease: Release resource (80).
D (19560) MB_PORT_COMMON: eMBMasterWaitRequestFinish: returned event = 0x40
D (19560) MB_CONTROLLER_MASTER: mbc_serial_master_get_parameter: Good response for get cid(13) = ESP_OK
I (19670) app_modbus: Characteristic #13 uAh (Wh) value = -71.620033 (0xc28f3d75) read successful.
D (19770) MB_PORT_COMMON: xMBMasterRunResTake:Take resource (80) (21 ticks).
D (19770) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_FRAME_TRANSMIT
D (19770) POLL transmit buffer: 03 00 25 00 02 
D (19770) MB_PORT_COMMON: eMBMasterRTUSend: Port enter critical.
D (19780) MB_PORT_COMMON: eMBMasterRTUSend: Port exit critical
D (19780) MB_PORT_COMMON: vMBMasterPortTimersRespondTimeoutEnable Respond enable timeout.
D (19790) MB_MASTER_SERIAL: MB_TX_buffer sent: (9) bytes.
D (19800) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_FRAME_SENT
D (19800) POLL sent buffer: 03 00 25 00 02 
D (19810) MB_MASTER_SERIAL: MB_uart[1] event:
D (19810) MB_MASTER_SERIAL: Data event, len: 9.
D (19820) MB_MASTER_SERIAL: Received data: 10(bytes in buffer)

D (19820) MB_MASTER_SERIAL: Timeout occured, processed: 10 bytes
D (19830) MB_PORT_COMMON: eMBMasterRTUReceive: Port enter critical.
D (19840) MB_PORT_COMMON: eMBMasterRTUReceive: Port exit critical
D (19840) MB_PORT_COMMON: eMBMasterPoll: Packet data received successfully (0).
D (19850) POLL receive buffer: 03 04 40 9a 8f 5c 
D (19850) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_EXECUTE
D (19860) MB_PORT_COMMON: eMBMasterPoll: set event EV_ERROR_OK
D (19870) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_ERROR_PROCESS
D (19870) MB_PORT_COMMON: vMBMasterCBRequestSuccess: Callback request success.
D (19880) MB_PORT_COMMON: vMBMasterRunResRelease: Release resource (80).
D (19890) MB_PORT_COMMON: eMBMasterWaitRequestFinish: returned event = 0x40
D (19890) MB_CONTROLLER_MASTER: mbc_serial_master_get_parameter: Good response for get cid(14) = ESP_OK
I (20000) app_modbus: Characteristic #14 -uAh (Wh) value = -0.000000 (0x8f5c409a) read successful.
I (20000) app_modbus: Destroy master...
D (20000) MB_PORT_COMMON: eMBMasterRTUStop: Port enter critical.
D (20000) MB_PORT_COMMON: eMBMasterRTUStop: Port exit critical
D (20010) MB_PORT_COMMON: vMBPortSetMode: Port enter critical.

brainstorm
Posts: 27
Joined: Mon Dec 12, 2016 12:22 pm

Re: Modbus power meter working with eModbus (Arduino), need insight(s) for FreeModbus (ESP-IDF)

Postby brainstorm » Sat Mar 26, 2022 11:57 pm

Trimming the Modbus CID table code further (see https://github.com/brainstorm/yigedianq ... f2eaf30429).

This change is meant to focus on just one attribute (instantaneous Watts) getting requested on the bus. Unfortunately still fails yielding "0.000"(Watts) when the display of the device shows ~"1.8"(Watts)... then, shortly after a few iterations, it goes to 271829599374318099234816.000000 (Watts) :-!!

Code: Select all

--- Available filters and text transformations: colorize, debug, default, direct, esp32_exception_decoder, hexlify, log2file, nocontrol, printable, send_on_enter, time
--- More details at https://bit.ly/pio-monitor-filters
--- Miniterm on /dev/cu.usbserial-110  115200,8,N,1 ---
--- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
 information:
I (441) cpu_start: Project name:     yigedianqi-modbus
I (447) cpu_start: App version:      219738e-dirty
I (452) cpu_start: Compile time:     Mar 26 2022 23:45:26
I (458) cpu_start: ELF file SHA256:  a0e9e881f94a741e...
I (464) cpu_start: ESP-IDF:          4.4.0
D (469) memory_layout: Checking 4 reserved memory ranges:
D (474) memory_layout: Reserved memory range 0x3ff9e000 - 0x3ff9e000
D (481) memory_layout: Reserved memory range 0x3ffb2000 - 0x3ffcacbc
D (487) memory_layout: Reserved memory range 0x3ffcacc0 - 0x3ffd4610
D (494) memory_layout: Reserved memory range 0x3ffffa10 - 0x40000000
D (500) memory_layout: Building list of available memory regions:
D (506) memory_layout: Available memory region 0x3ffd4610 - 0x3ffd8000
D (513) memory_layout: Available memory region 0x3ffd8000 - 0x3ffdc000
D (519) memory_layout: Available memory region 0x3ffdc000 - 0x3ffe0000
D (526) memory_layout: Available memory region 0x3ffe0000 - 0x3ffe4000
D (533) memory_layout: Available memory region 0x3ffe4000 - 0x3ffe8000
D (539) memory_layout: Available memory region 0x3ffe8000 - 0x3ffec000
D (546) memory_layout: Available memory region 0x3ffec000 - 0x3fff0000
D (552) memory_layout: Available memory region 0x3fff0000 - 0x3fff4000
D (559) memory_layout: Available memory region 0x3fff4000 - 0x3fff8000
D (566) memory_layout: Available memory region 0x3fff8000 - 0x3fffc000
D (572) memory_layout: Available memory region 0x3fffc000 - 0x3ffffa10
D (579) memory_layout: Available memory region 0x3ff9e000 - 0x3ffa0000
I (585) heap_init: Initializing. RAM available for dynamic allocation:
D (593) heap_init: New heap initialised at 0x3ffd4610
I (598) heap_init: At 3FFD4610 len 000279F0 (158 KiB): DRAM
I (604) heap_init: At 3FFFC000 len 00003A10 (14 KiB): DRAM
D (610) heap_init: New heap initialised at 0x3ff9e000
I (615) heap_init: At 3FF9E000 len 00002000 (8 KiB): RTCRAM
D (622) FLASH_HAL: extra_dummy: 0
D (625) spi_flash: trying chip: issi
D (629) spi_flash: trying chip: gd
D (632) spi_flash: trying chip: mxic
D (636) spi_flash: trying chip: winbond
D (640) spi_flash: trying chip: boya
D (643) spi_flash: trying chip: th
D (647) spi_flash: trying chip: generic
I (651) spi_flash: detected chip: generic
I (655) spi_flash: flash io: dio
D (659) cpu_start: calling init function: 0x40128000
D (664) cpu_start: calling init function: 0x40121dac
D (669) efuse: In EFUSE_BLK2__DATA4_REG is used 3 bits starting with 4 bit
D (676) ADC: Calibration eFuse is not configured, use self-calibration for ICode
D (688) cpu_start: calling init function: 0x40103ca8
D (689) cpu_start: calling init function: 0x401038b0
D (694) cpu_start: calling init function: 0x4010376c
D (699) cpu_start: calling init function: 0x40103538
D (704) cpu_start: calling init function: 0x4009b3d4
D (709) cpu_start: calling init function: 0x4009a2fc
D (714) cpu_start: calling init function: 0x4008eda4
D (719) intr_alloc: Connected src 73 to int 10 (cpu 0)
I (724) esp_core_dump_flash: Init core dump to flash
D (730) partition: Loading the partition table
D (735) partition: Partition table MD5 verified
I (739) esp_core_dump_flash: Found partition 'coredump' @ 346000 65536 bytes
D (758) esp_core_dump_checksum: Total length of hashed data: 8384
I (758) esp_core_dump_flash: Core dump data checksum is correct
I (762) esp_core_dump_flash: Found core dump 8388 bytes in flash @ 0x346000
D (769) cpu_start: Setting C++ exception workarounds.
D (775) intr_alloc: Connected src 28 to int 2 (cpu 0)
I (779) cpu_start: Starting scheduler on PRO CPU.
D (785) heap_init: New heap initialised at 0x3fffc000
D (785) intr_alloc: Connected src 17 to int 3 (cpu 0)
D (795) rmt: rmt_source_clk_hz: 80000000

D (795) rmt: Rmt Tx Channel 0|Gpio 18|Sclk_Hz 80000000|Div 2|Carrier_Hz 38000|Duty 33
D (805) intr_alloc: Connected src 50 to int 9 (cpu 0)
D (805) rmt: RMT translator init done
D (815) MB_PORT_COMMON: vMBPortSetMode: Port enter critical.
D (815) MB_PORT_COMMON: vMBPortSetMode: Port exit critical
D (825) MB_PORT_COMMON: eMBMasterRTUInit: Port enter critical.
I (825) uart: queue free spaces: 20
D (835) intr_alloc: Connected src 38 to int 12 (cpu 0)
D (835) MB_PORT_COMMON: xMBMasterPortSerialInit Init serial.
D (845) intr_alloc: Connected src 15 to int 13 (cpu 0)
D (845) MB_PORT_COMMON: eMBMasterRTUInit: Port exit critical
D (855) MB_PORT_COMMON: eMBMasterRTUStart: Port enter critical.
D (865) MB_PORT_COMMON: eMBMasterRTUStart: Port exit critical
I (915) app_modbus: Modbus master stack initialized...
I (915) app_modbus: Reading modbus holding registers from power meter...
D (915) MB_PORT_COMMON: xMBMasterRunResTake:Take resource (80) (21 ticks).
D (915) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_FRAME_TRANSMIT
D (925) POLL transmit buffer: 03 00 17 00 02 
D (925) MB_PORT_COMMON: eMBMasterRTUSend: Port enter critical.
D (935) MB_PORT_COMMON: eMBMasterRTUSend: Port exit critical
D (945) MB_PORT_COMMON: vMBMasterPortTimersRespondTimeoutEnable Respond enable timeout.
D (945) MB_MASTER_SERIAL: MB_TX_buffer sent: (9) bytes.
D (955) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_FRAME_SENT
D (965) POLL sent buffer: 03 00 17 00 02 
D (965) MB_MASTER_SERIAL: MB_uart[1] event:
D (965) MB_MASTER_SERIAL: Data event, len: 9.
D (975) MB_MASTER_SERIAL: Received data: 10(bytes in buffer)

D (975) MB_MASTER_SERIAL: Timeout occured, processed: 10 bytes
D (985) MB_PORT_COMMON: eMBMasterRTUReceive: Port enter critical.
D (995) MB_PORT_COMMON: eMBMasterRTUReceive: Port exit critical
D (995) MB_PORT_COMMON: eMBMasterPoll: Packet data received successfully (0).
D (1005) POLL receive buffer: 03 04 3f b3 33 33 
D (1005) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_EXECUTE
D (1015) MB_PORT_COMMON: eMBMasterPoll: set event EV_ERROR_OK
D (1025) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_ERROR_PROCESS
D (1025) MB_PORT_COMMON: vMBMasterCBRequestSuccess: Callback request success.
D (1035) MB_PORT_COMMON: vMBMasterRunResRelease: Release resource (80).
D (1035) MB_PORT_COMMON: eMBMasterWaitRequestFinish: returned event = 0x40
D (1045) MB_CONTROLLER_MASTER: mbc_serial_master_get_parameter: Good response for get cid(0) = ESP_OK
I (2055) app_modbus: Characteristic #0 Watts (W) value = 0.000000 (0x33333fb3) read successful.
I (2055) app_modbus: Destroy master...
D (2055) MB_PORT_COMMON: eMBMasterRTUStop: Port enter critical.
D (2055) MB_PORT_COMMON: eMBMasterRTUStop: Port exit critical
D (2065) MB_PORT_COMMON: vMBPortSetMode: Port enter critical.
D (2075) MB_PORT_COMMON: vMBPortSetMode: Port exit critical
D (4075) MB_PORT_COMMON: vMBPortSetMode: Port enter critical.
D (4075) MB_PORT_COMMON: vMBPortSetMode: Port exit critical
D (4075) MB_PORT_COMMON: eMBMasterRTUInit: Port enter critical.
I (4075) uart: queue free spaces: 20
D (4085) intr_alloc: Connected src 38 to int 12 (cpu 0)
D (4085) MB_PORT_COMMON: xMBMasterPortSerialInit Init serial.
D (4095) intr_alloc: Connected src 15 to int 13 (cpu 0)
D (4095) MB_PORT_COMMON: eMBMasterRTUInit: Port exit critical
D (4105) MB_PORT_COMMON: eMBMasterRTUStart: Port enter critical.
D (4105) MB_PORT_COMMON: eMBMasterRTUStart: Port exit critical
I (4165) app_modbus: Modbus master stack initialized...
I (4165) app_modbus: Reading modbus holding registers from power meter...
D (4165) MB_PORT_COMMON: xMBMasterRunResTake:Take resource (80) (21 ticks).
D (4165) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_FRAME_TRANSMIT
D (4175) POLL transmit buffer: 03 00 17 00 02 
D (4185) MB_PORT_COMMON: eMBMasterRTUSend: Port enter critical.
D (4185) MB_PORT_COMMON: eMBMasterRTUSend: Port exit critical
D (4195) MB_PORT_COMMON: vMBMasterPortTimersRespondTimeoutEnable Respond enable timeout.
D (4205) MB_MASTER_SERIAL: MB_TX_buffer sent: (9) bytes.
D (4205) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_FRAME_SENT
D (4215) POLL sent buffer: 03 00 17 00 02 
D (4215) MB_MASTER_SERIAL: MB_uart[1] event:
D (4215) MB_MASTER_SERIAL: Data event, len: 9.
D (4225) MB_MASTER_SERIAL: Received data: 10(bytes in buffer)

D (4235) MB_MASTER_SERIAL: Timeout occured, processed: 10 bytes
D (4235) MB_PORT_COMMON: eMBMasterRTUReceive: Port enter critical.
D (4245) MB_PORT_COMMON: eMBMasterRTUReceive: Port exit critical
D (4245) MB_PORT_COMMON: eMBMasterPoll: Packet data received successfully (0).
D (4255) POLL receive buffer: 03 04 3f b3 33 33 
D (4265) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_EXECUTE
D (4265) MB_PORT_COMMON: eMBMasterPoll: set event EV_ERROR_OK
D (4275) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_ERROR_PROCESS
D (4275) MB_PORT_COMMON: vMBMasterCBRequestSuccess: Callback request success.
D (4285) MB_PORT_COMMON: vMBMasterRunResRelease: Release resource (80).
D (4295) MB_PORT_COMMON: eMBMasterWaitRequestFinish: returned event = 0x40
D (4295) MB_CONTROLLER_MASTER: mbc_serial_master_get_parameter: Good response for get cid(0) = ESP_OK
I (5305) app_modbus: Characteristic #0 Watts (W) value = 0.000000 (0x33333fb3) read successful.
I (5305) app_modbus: Destroy master...
D (5305) MB_PORT_COMMON: eMBMasterRTUStop: Port enter critical.
D (5305) MB_PORT_COMMON: eMBMasterRTUStop: Port exit critical
D (5315) MB_PORT_COMMON: vMBPortSetMode: Port enter critical.
D (5325) MB_PORT_COMMON: vMBPortSetMode: Port exit critical
D (7325) MB_PORT_COMMON: vMBPortSetMode: Port enter critical.
D (7325) MB_PORT_COMMON: vMBPortSetMode: Port exit critical
D (7325) MB_PORT_COMMON: eMBMasterRTUInit: Port enter critical.
I (7325) uart: queue free spaces: 20
D (7335) intr_alloc: Connected src 38 to int 12 (cpu 0)
D (7335) MB_PORT_COMMON: xMBMasterPortSerialInit Init serial.
D (7345) intr_alloc: Connected src 15 to int 13 (cpu 0)
D (7345) MB_PORT_COMMON: eMBMasterRTUInit: Port exit critical
D (7355) MB_PORT_COMMON: eMBMasterRTUStart: Port enter critical.
D (7355) MB_PORT_COMMON: eMBMasterRTUStart: Port exit critical
I (7415) app_modbus: Modbus master stack initialized...
I (7415) app_modbus: Reading modbus holding registers from power meter...
D (7415) MB_PORT_COMMON: xMBMasterRunResTake:Take resource (80) (21 ticks).
D (7415) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_FRAME_TRANSMIT
D (7425) POLL transmit buffer: 03 00 17 00 02 
D (7435) MB_PORT_COMMON: eMBMasterRTUSend: Port enter critical.
D (7435) MB_PORT_COMMON: eMBMasterRTUSend: Port exit critical
D (7445) MB_PORT_COMMON: vMBMasterPortTimersRespondTimeoutEnable Respond enable timeout.
D (7455) MB_MASTER_SERIAL: MB_TX_buffer sent: (9) bytes.
D (7455) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_FRAME_SENT
D (7465) POLL sent buffer: 03 00 17 00 02 
D (7465) MB_MASTER_SERIAL: MB_uart[1] event:
D (7465) MB_MASTER_SERIAL: Data event, len: 9.
D (7475) MB_MASTER_SERIAL: Received data: 10(bytes in buffer)

D (7485) MB_MASTER_SERIAL: Timeout occured, processed: 10 bytes
D (7485) MB_PORT_COMMON: eMBMasterRTUReceive: Port enter critical.
D (7495) MB_PORT_COMMON: eMBMasterRTUReceive: Port exit critical
D (7495) MB_PORT_COMMON: eMBMasterPoll: Packet data received successfully (0).
D (7505) POLL receive buffer: 03 04 3f b3 33 33 
D (7515) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_EXECUTE
D (7515) MB_PORT_COMMON: eMBMasterPoll: set event EV_ERROR_OK
D (7525) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_ERROR_PROCESS
D (7525) MB_PORT_COMMON: vMBMasterCBRequestSuccess: Callback request success.
D (7535) MB_PORT_COMMON: vMBMasterRunResRelease: Release resource (80).
D (7545) MB_PORT_COMMON: eMBMasterWaitRequestFinish: returned event = 0x40
D (7545) MB_CONTROLLER_MASTER: mbc_serial_master_get_parameter: Good response for get cid(0) = ESP_OK
I (8555) app_modbus: Characteristic #0 Watts (W) value = 0.000000 (0x33333fb3) read successful.
I (8555) app_modbus: Destroy master...
D (8555) MB_PORT_COMMON: eMBMasterRTUStop: Port enter critical.
D (8555) MB_PORT_COMMON: eMBMasterRTUStop: Port exit critical
D (8565) MB_PORT_COMMON: vMBPortSetMode: Port enter critical.
D (8575) MB_PORT_COMMON: vMBPortSetMode: Port exit critical
D (10575) MB_PORT_COMMON: vMBPortSetMode: Port enter critical.
D (10575) MB_PORT_COMMON: vMBPortSetMode: Port exit critical
D (10575) MB_PORT_COMMON: eMBMasterRTUInit: Port enter critical.
I (10575) uart: queue free spaces: 20
D (10585) intr_alloc: Connected src 38 to int 12 (cpu 0)
D (10585) MB_PORT_COMMON: xMBMasterPortSerialInit Init serial.
D (10595) intr_alloc: Connected src 15 to int 13 (cpu 0)
D (10595) MB_PORT_COMMON: eMBMasterRTUInit: Port exit critical
D (10605) MB_PORT_COMMON: eMBMasterRTUStart: Port enter critical.
D (10605) MB_PORT_COMMON: eMBMasterRTUStart: Port exit critical
I (10665) app_modbus: Modbus master stack initialized...
I (10665) app_modbus: Reading modbus holding registers from power meter...
D (10665) MB_PORT_COMMON: xMBMasterRunResTake:Take resource (80) (21 ticks).
D (10665) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_FRAME_TRANSMIT
D (10675) POLL transmit buffer: 03 00 17 00 02 
D (10685) MB_PORT_COMMON: eMBMasterRTUSend: Port enter critical.
D (10685) MB_PORT_COMMON: eMBMasterRTUSend: Port exit critical
D (10695) MB_PORT_COMMON: vMBMasterPortTimersRespondTimeoutEnable Respond enable timeout.
D (10705) MB_MASTER_SERIAL: MB_TX_buffer sent: (9) bytes.
D (10705) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_FRAME_SENT
D (10715) POLL sent buffer: 03 00 17 00 02 
D (10725) MB_MASTER_SERIAL: MB_uart[1] event:
D (10725) MB_MASTER_SERIAL: Data event, len: 9.
D (10725) MB_MASTER_SERIAL: Received data: 10(bytes in buffer)

D (10735) MB_MASTER_SERIAL: Timeout occured, processed: 10 bytes
D (10735) MB_PORT_COMMON: eMBMasterRTUReceive: Port enter critical.
D (10745) MB_PORT_COMMON: eMBMasterRTUReceive: Port exit critical
D (10745) MB_PORT_COMMON: eMBMasterPoll: Packet data received successfully (0).
D (10755) POLL receive buffer: 03 04 3f a6 66 66 
D (10765) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_EXECUTE
D (10765) MB_PORT_COMMON: eMBMasterPoll: set event EV_ERROR_OK
D (10775) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_ERROR_PROCESS
D (10775) MB_PORT_COMMON: vMBMasterCBRequestSuccess: Callback request success.
D (10785) MB_PORT_COMMON: vMBMasterRunResRelease: Release resource (80).
D (10795) MB_PORT_COMMON: eMBMasterWaitRequestFinish: returned event = 0x40
D (10805) MB_CONTROLLER_MASTER: mbc_serial_master_get_parameter: Good response for get cid(0) = ESP_OK
I (11805) app_modbus: Characteristic #0 Watts (W) value = 271829599374318099234816.000000 (0x66663fa6) read successful.
I (11805) app_modbus: Destroy master...
D (11805) MB_PORT_COMMON: eMBMasterRTUStop: Port enter critical.
D (11815) MB_PORT_COMMON: eMBMasterRTUStop: Port exit critical
D (11815) MB_PORT_COMMON: vMBPortSetMode: Port enter critical.
D (11825) MB_PORT_COMMON: vMBPortSetMode: Port exit critical
D (13825) MB_PORT_COMMON: vMBPortSetMode: Port enter critical.
D (13825) MB_PORT_COMMON: vMBPortSetMode: Port exit critical
D (13825) MB_PORT_COMMON: eMBMasterRTUInit: Port enter critical.
I (13825) uart: queue free spaces: 20
D (13835) intr_alloc: Connected src 38 to int 12 (cpu 0)
D (13835) MB_PORT_COMMON: xMBMasterPortSerialInit Init serial.
D (13845) intr_alloc: Connected src 15 to int 13 (cpu 0)
D (13845) MB_PORT_COMMON: eMBMasterRTUInit: Port exit critical
D (13855) MB_PORT_COMMON: eMBMasterRTUStart: Port enter critical.
D (13855) MB_PORT_COMMON: eMBMasterRTUStart: Port exit critical
I (13915) app_modbus: Modbus master stack initialized...
I (13915) app_modbus: Reading modbus holding registers from power meter...
D (13915) MB_PORT_COMMON: xMBMasterRunResTake:Take resource (80) (21 ticks).
D (13915) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_FRAME_TRANSMIT
D (13925) POLL transmit buffer: 03 00 17 00 02 
D (13935) MB_PORT_COMMON: eMBMasterRTUSend: Port enter critical.
D (13935) MB_PORT_COMMON: eMBMasterRTUSend: Port exit critical
D (13945) MB_PORT_COMMON: vMBMasterPortTimersRespondTimeoutEnable Respond enable timeout.
D (13955) MB_MASTER_SERIAL: MB_TX_buffer sent: (9) bytes.
D (13955) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_FRAME_SENT
D (13965) POLL sent buffer: 03 00 17 00 02 
D (13975) MB_MASTER_SERIAL: MB_uart[1] event:
D (13975) MB_MASTER_SERIAL: Data event, len: 9.
D (13975) MB_MASTER_SERIAL: Received data: 10(bytes in buffer)

D (13985) MB_MASTER_SERIAL: Timeout occured, processed: 10 bytes
D (13985) MB_PORT_COMMON: eMBMasterRTUReceive: Port enter critical.
D (13995) MB_PORT_COMMON: eMBMasterRTUReceive: Port exit critical
D (13995) MB_PORT_COMMON: eMBMasterPoll: Packet data received successfully (0).
D (14005) POLL receive buffer: 03 04 3f a6 66 66 
D (14015) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_EXECUTE
D (14015) MB_PORT_COMMON: eMBMasterPoll: set event EV_ERROR_OK
D (14025) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_ERROR_PROCESS
D (14025) MB_PORT_COMMON: vMBMasterCBRequestSuccess: Callback request success.
D (14035) MB_PORT_COMMON: vMBMasterRunResRelease: Release resource (80).
D (14045) MB_PORT_COMMON: eMBMasterWaitRequestFinish: returned event = 0x40
D (14055) MB_CONTROLLER_MASTER: mbc_serial_master_get_parameter: Good response for get cid(0) = ESP_OK
I (15055) app_modbus: Characteristic #0 Watts (W) value = 271829599374318099234816.000000 (0x66663fa6) read successful.
I (15055) app_modbus: Destroy master...
D (15055) MB_PORT_COMMON: eMBMasterRTUStop: Port enter critical.
D (15065) MB_PORT_COMMON: eMBMasterRTUStop: Port exit critical
D (15065) MB_PORT_COMMON: vMBPortSetMode: Port enter critical.
D (15075) MB_PORT_COMMON: vMBPortSetMode: Port exit critical
D (17075) MB_PORT_COMMON: vMBPortSetMode: Port enter critical.
D (17075) MB_PORT_COMMON: vMBPortSetMode: Port exit critical
D (17075) MB_PORT_COMMON: eMBMasterRTUInit: Port enter critical.
I (17075) uart: queue free spaces: 20
D (17085) intr_alloc: Connected src 38 to int 12 (cpu 0)
D (17085) MB_PORT_COMMON: xMBMasterPortSerialInit Init serial.
D (17095) intr_alloc: Connected src 15 to int 13 (cpu 0)
D (17095) MB_PORT_COMMON: eMBMasterRTUInit: Port exit critical
D (17105) MB_PORT_COMMON: eMBMasterRTUStart: Port enter critical.
D (17105) MB_PORT_COMMON: eMBMasterRTUStart: Port exit critical
I (17165) app_modbus: Modbus master stack initialized...
I (17165) app_modbus: Reading modbus holding registers from power meter...
D (17165) MB_PORT_COMMON: xMBMasterRunResTake:Take resource (80) (21 ticks).
D (17165) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_FRAME_TRANSMIT
D (17175) POLL transmit buffer: 03 00 17 00 02 
D (17185) MB_PORT_COMMON: eMBMasterRTUSend: Port enter critical.
D (17185) MB_PORT_COMMON: eMBMasterRTUSend: Port exit critical
D (17195) MB_PORT_COMMON: vMBMasterPortTimersRespondTimeoutEnable Respond enable timeout.
D (17205) MB_MASTER_SERIAL: MB_TX_buffer sent: (9) bytes.
D (17205) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_FRAME_SENT
D (17215) POLL sent buffer: 03 00 17 00 02 
D (17225) MB_MASTER_SERIAL: MB_uart[1] event:
D (17225) MB_MASTER_SERIAL: Data event, len: 9.
D (17225) MB_MASTER_SERIAL: Received data: 10(bytes in buffer)

D (17235) MB_MASTER_SERIAL: Timeout occured, processed: 10 bytes
D (17235) MB_PORT_COMMON: eMBMasterRTUReceive: Port enter critical.
D (17245) MB_PORT_COMMON: eMBMasterRTUReceive: Port exit critical
D (17245) MB_PORT_COMMON: eMBMasterPoll: Packet data received successfully (0).
D (17255) POLL receive buffer: 03 04 3f a6 66 66 
D (17265) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_EXECUTE
D (17265) MB_PORT_COMMON: eMBMasterPoll: set event EV_ERROR_OK
D (17275) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_ERROR_PROCESS
D (17275) MB_PORT_COMMON: vMBMasterCBRequestSuccess: Callback request success.
D (17285) MB_PORT_COMMON: vMBMasterRunResRelease: Release resource (80).
D (17295) MB_PORT_COMMON: eMBMasterWaitRequestFinish: returned event = 0x40
D (17305) MB_CONTROLLER_MASTER: mbc_serial_master_get_parameter: Good response for get cid(0) = ESP_OK
I (18305) app_modbus: Characteristic #0 Watts (W) value = 271829599374318099234816.000000 (0x66663fa6) read successful.
I (18305) app_modbus: Destroy master...
D (18305) MB_PORT_COMMON: eMBMasterRTUStop: Port enter critical.
D (18315) MB_PORT_COMMON: eMBMasterRTUStop: Port exit critical
D (18315) MB_PORT_COMMON: vMBPortSetMode: Port enter critical.
D (18325) MB_PORT_COMMON: vMBPortSetMode: Port exit critical
D (20325) MB_PORT_COMMON: vMBPortSetMode: Port enter critical.
D (20325) MB_PORT_COMMON: vMBPortSetMode: Port exit critical
D (20325) MB_PORT_COMMON: eMBMasterRTUInit: Port enter critical.
I (20325) uart: queue free spaces: 20
D (20335) intr_alloc: Connected src 38 to int 12 (cpu 0)
D (20335) MB_PORT_COMMON: xMBMasterPortSerialInit Init serial.
D (20345) intr_alloc: Connected src 15 to int 13 (cpu 0)
D (20345) MB_PORT_COMMON: eMBMasterRTUInit: Port exit critical
D (20355) MB_PORT_COMMON: eMBMasterRTUStart: Port enter critical.
D (20355) MB_PORT_COMMON: eMBMasterRTUStart: Port exit critical
I (20415) app_modbus: Modbus master stack initialized...
I (20415) app_modbus: Reading modbus holding registers from power meter...
D (20415) MB_PORT_COMMON: xMBMasterRunResTake:Take resource (80) (21 ticks).
D (20415) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_FRAME_TRANSMIT
D (20425) POLL transmit buffer: 03 00 17 00 02 
D (20435) MB_PORT_COMMON: eMBMasterRTUSend: Port enter critical.
D (20435) MB_PORT_COMMON: eMBMasterRTUSend: Port exit critical
D (20445) MB_PORT_COMMON: vMBMasterPortTimersRespondTimeoutEnable Respond enable timeout.
D (20455) MB_MASTER_SERIAL: MB_TX_buffer sent: (9) bytes.
D (20455) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_FRAME_SENT
D (20465) POLL sent buffer: 03 00 17 00 02 
D (20475) MB_MASTER_SERIAL: MB_uart[1] event:
D (20475) MB_MASTER_SERIAL: Data event, len: 9.
D (20475) MB_MASTER_SERIAL: Received data: 10(bytes in buffer)

D (20485) MB_MASTER_SERIAL: Timeout occured, processed: 10 bytes
D (20485) MB_PORT_COMMON: eMBMasterRTUReceive: Port enter critical.
D (20495) MB_PORT_COMMON: eMBMasterRTUReceive: Port exit critical
D (20495) MB_PORT_COMMON: eMBMasterPoll: Packet data received successfully (0).
D (20505) POLL receive buffer: 03 04 3f a6 66 66 
D (20515) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_EXECUTE
D (20515) MB_PORT_COMMON: eMBMasterPoll: set event EV_ERROR_OK
D (20525) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_ERROR_PROCESS
D (20525) MB_PORT_COMMON: vMBMasterCBRequestSuccess: Callback request success.
D (20535) MB_PORT_COMMON: vMBMasterRunResRelease: Release resource (80).
D (20545) MB_PORT_COMMON: eMBMasterWaitRequestFinish: returned event = 0x40
D (20555) MB_CONTROLLER_MASTER: mbc_serial_master_get_parameter: Good response for get cid(0) = ESP_OK
I (21555) app_modbus: Characteristic #0 Watts (W) value = 271829599374318099234816.000000 (0x66663fa6) read successful.
I (21555) app_modbus: Destroy master...
D (21555) MB_PORT_COMMON: eMBMasterRTUStop: Port enter critical.
D (21565) MB_PORT_COMMON: eMBMasterRTUStop: Port exit critical
D (21565) MB_PORT_COMMON: vMBPortSetMode: Port enter critical.
D (21575) MB_PORT_COMMON: vMBPortSetMode: Port exit critical
D (23575) MB_PORT_COMMON: vMBPortSetMode: Port enter critical.
D (23575) MB_PORT_COMMON: vMBPortSetMode: Port exit critical
D (23575) MB_PORT_COMMON: eMBMasterRTUInit: Port enter critical.
I (23575) uart: queue free spaces: 20
D (23585) intr_alloc: Connected src 38 to int 12 (cpu 0)
D (23585) MB_PORT_COMMON: xMBMasterPortSerialInit Init serial.
D (23595) intr_alloc: Connected src 15 to int 13 (cpu 0)
D (23595) MB_PORT_COMMON: eMBMasterRTUInit: Port exit critical
D (23605) MB_PORT_COMMON: eMBMasterRTUStart: Port enter critical.
D (23605) MB_PORT_COMMON: eMBMasterRTUStart: Port exit critical
I (23665) app_modbus: Modbus master stack initialized...
I (23665) app_modbus: Reading modbus holding registers from power meter...
D (23665) MB_PORT_COMMON: xMBMasterRunResTake:Take resource (80) (21 ticks).
D (23665) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_FRAME_TRANSMIT
D (23675) POLL transmit buffer: 03 00 17 00 02 
D (23685) MB_PORT_COMMON: eMBMasterRTUSend: Port enter critical.
D (23685) MB_PORT_COMMON: eMBMasterRTUSend: Port exit critical
D (23695) MB_PORT_COMMON: vMBMasterPortTimersRespondTimeoutEnable Respond enable timeout.
D (23705) MB_MASTER_SERIAL: MB_TX_buffer sent: (9) bytes.
D (23705) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_FRAME_SENT
D (23715) POLL sent buffer: 03 00 17 00 02 
D (23725) MB_MASTER_SERIAL: MB_uart[1] event:
D (23725) MB_MASTER_SERIAL: Data event, len: 9.
D (23725) MB_MASTER_SERIAL: Received data: 10(bytes in buffer)

D (23735) MB_MASTER_SERIAL: Timeout occured, processed: 10 bytes
D (23735) MB_PORT_COMMON: eMBMasterRTUReceive: Port enter critical.
D (23745) MB_PORT_COMMON: eMBMasterRTUReceive: Port exit critical
D (23745) MB_PORT_COMMON: eMBMasterPoll: Packet data received successfully (0).
D (23755) POLL receive buffer: 03 04 3f a6 66 66 
D (23765) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_EXECUTE
D (23765) MB_PORT_COMMON: eMBMasterPoll: set event EV_ERROR_OK
D (23775) MB_PORT_COMMON: eMBMasterPoll:EV_MASTER_ERROR_PROCESS
D (23775) MB_PORT_COMMON: vMBMasterCBRequestSuccess: Callback request success.
D (23785) MB_PORT_COMMON: vMBMasterRunResRelease: Release resource (80).
D (23795) MB_PORT_COMMON: eMBMasterWaitRequestFinish: returned event = 0x40
D (23805) MB_CONTROLLER_MASTER: mbc_serial_master_get_parameter: Good response for get cid(0) = ESP_OK
I (24805) app_modbus: Characteristic #0 Watts (W) value = 271829599374318099234816.000000 (0x66663fa6) read successful.
I (24805) app_modbus: Destroy master...
D (24805) MB_PORT_COMMON: eMBMasterRTUStop: Port enter critical.
D (24815) MB_PORT_COMMON: eMBMasterRTUStop: Port exit critical
D (24815) MB_PORT_COMMON: vMBPortSetMode: Port enter critical.
D (24825) MB_PORT_COMMON: vMBPortSetMode: Port exit critical
(...)

brainstorm
Posts: 27
Joined: Mon Dec 12, 2016 12:22 pm

Re: Modbus power meter working with eModbus (Arduino), need insight(s) for FreeModbus (ESP-IDF)

Postby brainstorm » Sun Mar 27, 2022 6:55 pm

Nevermind, I managed to solve it by adding some offsets to the modbus attribute IDs on the CID table (different from those that worked on eModbus Arduino): https://github.com/brainstorm/yigedianq ... fR125-R155

I.e for some reason, in eModbus/Arduino:

Code: Select all

  //  0011:    0.193   <--- Amps panel 1
  //  0013:    0.258   <--- Amps panel 2
  //  0015:    0.210   <--- Amps panel 3
Whereas in esp-idf/FreeModbus:

Code: Select all

    { CID_HOLD_DATA_0, STR("Amps_phase_1"), STR("A"), MB_DEVICE_ADDR1, MB_PARAM_HOLDING, 0x12, 2,
            HOLD_OFFSET(holding_data0), PARAM_TYPE_FLOAT, PARAM_SIZE_FLOAT, OPTS( 0, 5000, .001 ), PAR_PERMS_READ },
    { CID_HOLD_DATA_1, STR("Amps_phase_2"), STR("A"), MB_DEVICE_ADDR1, MB_PARAM_HOLDING, 0x14, 2,
            HOLD_OFFSET(holding_data1), PARAM_TYPE_FLOAT, PARAM_SIZE_FLOAT, OPTS( 0, 5000, .001 ), PAR_PERMS_READ },
    { CID_HOLD_DATA_2, STR("Amps_phase_3"), STR("A"), MB_DEVICE_ADDR1, MB_PARAM_HOLDING, 0x10, 2,

ESP_alisitsyn
Posts: 211
Joined: Fri Feb 01, 2019 4:02 pm
Contact:

Re: Modbus power meter working with eModbus (Arduino), need insight(s) for FreeModbus (ESP-IDF)

Postby ESP_alisitsyn » Wed Mar 30, 2022 9:34 am

Hi @brainstorm,
Also, the message "MB_MASTER_SERIAL: Timeout occurred, processed: 10 bytes" concerns me too, I don't know if timeouts are supposed to occur, I'll check the esp-idf FreeModbus code to figure more things out of this.
Timeout means the UART T3.5 timeout here.
The message in the log as below displays just ADU (Application Data Unit) of the Modbus Frame, so the length is 9 bytes is correct.
`D (9932) POLL receive buffer: 03 04 3f ba 51 1a`
The FreeModbus raw buffer responses look a bit shorter than those from eModbus
I read your post and code you shared. What I need is actually your power meter Modbus mapping table. It seems that your device has a different float format for data stored in the registers. It could be not just endianess/swap but it seems that it uses double type (8 bytes) instead of 4 bytes float IEEE754 format https://www.h-schmidt.net/FloatConverter/IEEE754.html
used in Modbus stack code. Your workaround is just a temporary solution in this case. However, the code of the stack can be fixed to convert data to the format of your device. I need the mapping table from you to help.

Thanks.

brainstorm
Posts: 27
Joined: Mon Dec 12, 2016 12:22 pm

Re: Modbus power meter working with eModbus (Arduino), need insight(s) for FreeModbus (ESP-IDF)

Postby brainstorm » Sat Apr 02, 2022 9:05 pm

As promised elsewhere, here's my scanned manual @ESP_alisitsyn:

https://github.com/brainstorm/yigedianq ... manual.pdf

brainstorm
Posts: 27
Joined: Mon Dec 12, 2016 12:22 pm

Re: Modbus power meter working with eModbus (Arduino), need insight(s) for FreeModbus (ESP-IDF)

Postby brainstorm » Tue Apr 05, 2022 12:22 am

TL;DR, the interesting parts start on page 10 of that manual.
Attachments
Screen Shot 2022-04-05 at 10.21.03 am.png
Screen Shot 2022-04-05 at 10.21.03 am.png (813.88 KiB) Viewed 7051 times
Screen Shot 2022-04-05 at 10.21.13 am.png
Screen Shot 2022-04-05 at 10.21.13 am.png (929.81 KiB) Viewed 7051 times
Screen Shot 2022-04-05 at 10.21.30 am.png
Screen Shot 2022-04-05 at 10.21.30 am.png (861.88 KiB) Viewed 7051 times

brainstorm
Posts: 27
Joined: Mon Dec 12, 2016 12:22 pm

Re: Modbus power meter working with eModbus (Arduino), need insight(s) for FreeModbus (ESP-IDF)

Postby brainstorm » Fri Apr 08, 2022 4:26 am

I've found out that the manual I just scanned and posted here is for the meter with model number YG899E-9SY, which does not correspond with my yigedianqi-modbus CID table because tha CID table I've written in my code is for model YG194E-9SY.

Both model's parameters seem to be laid out (correctly?) on those two YAML definitions I've found in another project:

https://github.com/GuillermoElectrico/e ... 9E-9SY.yml
https://github.com/GuillermoElectrico/e ... 4E-9SY.yml

Hope that helps solving the float encoding issues you mentioned earlier in FreeModBus while you are rearranging the code in esp-modbus on https://github.com/espressif/esp-modbus.

ESP_alisitsyn
Posts: 211
Joined: Fri Feb 01, 2019 4:02 pm
Contact:

Re: Modbus power meter working with eModbus (Arduino), need insight(s) for FreeModbus (ESP-IDF)

Postby ESP_alisitsyn » Wed Apr 13, 2022 5:12 pm

@brainstorm ,

Thank you for the information. Unfortunately, I can not read Chinese but most of the information included there is clear. As I mentioned before and as the manual confirms the float format representation in Modbus is not the same. The YG899E-9SY float format is IEEE754 4 bytes but it is not swapped. The ESP-Modbus uses IEEE754 Little-endian byte swap format which is common for most of devices.
For Example ESP-Modbus the read of 218.799 float value from holding registers:

Code: Select all

Request: 01 03 00 06 00 02 24 0A
Response: 01 03 04 CC 9D 43 5A E5 86
The YG899E-9SY will respond as:

Code: Select all

Response: 01 03 04 43 5A CC 9D 5B 0D
This is not an issue in the Modbus stack it is a customized version of Modbus protocol used in your device. The Modbus spec does not prevent this. There is a plan to add the support of a customized format for 32bit values in the stack but it is not supported for now.

In order to add support for this format you need to implement byte swapping of the float value in the code:
https://github.com/espressif/esp-idf/bl ... ter.c#L388

The better way is to fix the code of the library as below:

Code: Select all

static esp_err_t mbc_serial_master_get_parameter(uint16_t cid, char* name,
                                                    uint8_t* value_ptr, uint8_t *type)
{
    MB_MASTER_CHECK((name != NULL),
                        ESP_ERR_INVALID_ARG, "mb incorrect descriptor.");
    MB_MASTER_CHECK((type != NULL),
                        ESP_ERR_INVALID_ARG, "type pointer is incorrect.");
    esp_err_t error = ESP_ERR_INVALID_RESPONSE;
    mb_param_request_t request ;
    mb_parameter_descriptor_t reg_info = { 0 };

    error = mbc_serial_master_set_request(name, MB_PARAM_READ, &request, &reg_info);
    if ((error == ESP_OK) && (cid == reg_info.cid)) {
        // Send request to read characteristic data
        error = mbc_serial_master_send_request(&request, value_ptr);
        if (error == ESP_OK) {
            ESP_LOGD(MB_MASTER_TAG, "%s: Good response for get cid(%u) = %s",
                                    __FUNCTION__, (int)reg_info.cid, (char*)esp_err_to_name(error));
        } else {
            ESP_LOGD(MB_MASTER_TAG, "%s: Bad response to get cid(%u) = %s",
                                            __FUNCTION__, reg_info.cid, (char*)esp_err_to_name(error));
        }
        // Set the type of parameter found in the table
        *type = reg_info.param_type;
        if (((reg_info.param_type == PARAM_TYPE_FLOAT) || (reg_info.param_type == PARAM_TYPE_U32)) 
                && (reg_info.param_size == 4)) {
            	// Fix endianess for FLOAT and U32 parameter here <<<<<<<<<<<<<<<<<<<
            	*(uint32_t*)value_ptr = __beswap_32(*(uint32_t*)value_ptr);
        }
    } else {
        ESP_LOGE(MB_MASTER_TAG, "%s: The cid(%u) not found in the data dictionary.",
                                                    __FUNCTION__, reg_info.cid);
        error = ESP_ERR_INVALID_ARG;
    }
    return error;
}
I was discussing about this here: viewtopic.php?f=2&t=23040&hilit=modbus+floating .
I will implement the change in the esp-modbus component soon. Please verify this with your device.


Who is online

Users browsing this forum: Google [Bot] and 88 guests