ROBOTIS-GIT / Dynamixel2Arduino

DYNAMIXEL protocol library for Arduino
Apache License 2.0
88 stars 55 forks source link

Issue #115 - allow override of hard-coded delay #116

Closed johnauld closed 1 year ago

johnauld commented 1 year ago

This is a proposed fix for issue #115. The problem there is that SerialPortHandler::begin() calls delay() unconditionally, which causes a hang if interrupts are disabled at the time of the call (as is the case during FreeRTOS startup).

The solution here is to add a uint32_t delay parameter to Dynamixel2Arduino::begin() and SerialPortHandler::begin() to allow the caller to specify the amount of delay, or to disable the delay() call entirely by passing zero. For both functions, a default value of 300 is provided (equal to the previous hard-coded delay time), so existing code will be unaffected.