ModbusMaster: compatibility problem with ESP32?

ModbusMaster version

[Version of the project where you are encountering the issue]

Arduino IDE version

[Version of Arduino IDE in your environment]

Arduino Hardware

[Hardware information, including board and processor]

Platform Details

[Operating system distribution and release version]


Scenario:

[What you are trying to achieve and you can’t?]

Steps to Reproduce:

[If you are filing an issue what are the things we need to do in order to repro your problem? How are you using this project or any resources it includes?]

Expected Result:

[What are you expecting to happen as the consequence of above reproduction steps?]

Actual Result:

[What actually happens after the reproduction steps? Include the error output or a link to a gist if possible.]


Feature Request

Narrative:

As a [role]
I want [feature]
So that [benefit]

Acceptance Criteria:

Scenario 1: Title
Given [context]
  And [some more context]...
When  [event]
Then  [outcome]
  And [another outcome]...

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 40

Most upvoted comments

to avoid watchdog timeouts in ESP32 when waiting for a slave response (or when no slave connected), you can disable the watchdog as described above. However this is not ideal. Also when working with multi-thread freeRTOS, the operating system should have the chance to jump to another task when waiting for slave response.

This can be done by inserting a 1ms delay in the transmission loop, it also avoids watchdog timeouts: Since modbus send/receive is slow, I’m using the modbus communication is a seperate freeRTOS task.

in the modbusMaster.ccp file:

// loop until we run out of time or bytes, or an error occurs
  u32StartTime = millis();
  while (u8BytesLeft && !u8MBStatus)
  {
    delay(1);			//WKE to avoid ESP32 watchdog timeout and reset
	if (_serial->available())
    {
#if __MODBUSMASTER_DEBUG__
      digitalWrite(__MODBUSMASTER_DEBUG_PIN_A__, true);
#endif
      u8ModbusADU[u8ModbusADUSize++] = _serial->read();
      u8BytesLeft--;
#if __MODBUSMASTER_DEBUG__
      digitalWrite(__MODBUSMASTER_DEBUG_PIN_A__, false);