-
Notifications
You must be signed in to change notification settings - Fork 1
Differences from KLineKWP1281Lib
-
The ability to define a custom function to execute while waiting 200ms after each byte in the 5-baud initialization has been removed, because the blocking delay allows other tasks to run.
-
The
receiveFunction
has been changed, to allow for an event-based implementation, instead of polling.
- instead of the
receiveFunction
checking if there is a byte available and immediately returning otherwise, now it has to wait for data and only return false if the timeout period passes - it receives the timeout period through the additional
unsigned long timeout_ticks
parameter, where it is expressed in FreeRTOS ticks, which can be converted to milliseconds using thepdMS_TO_TICKS
macro - for this, the chosen Serial interface must be able to generate an event when a byte becomes available, to notify the other task which should block waiting for an event
- the hardware Serial ports are capable of this, by attaching a callback with
onReceive
, as demonstrated in the example sketches - in the examples, the
onReceive
callback sends a direct-to-task notification to the task managing the K-Line (which thereceiveFunction
is running on); you are free to implement this any other way, for example with an event group, semaphore or queue
If software Serial is required, and the chosen library cannot execute callbacks on events, it might still be possible to either poll inside receiveFunction
, or to create a polling task which notifies the receiveFunction
when there is data availble, although the hardware Serial ports are strongly recommended.
-
The external strings (text table, fault descriptions, units) do not have the
PROGMEM
attribute anymore, as it has no effect on the ESP32. -
Debugging is no longer controlled by providing a Stream pointer to the library constructor, instead it can be configured in the
Tools > Core Debug Level
menu in the Arduino IDE.