Most of the work is performed within the main polling loop. Internally it works by waiting for an event posted to a queue (See footnote ). Such a event for example is the reception of a MODBUS frame. Events are posted to the event queue by the interrupt driven receiver and transmitter state machines. After a frame is received the FRAME_RECEIVED event is posted and the main loop is executed. Following the receive event an EXECUTION event is created internally which allows updating the registers values prior to sending the response. The end of transmission is signaled by the FRAME_SENT event.
Registers values for the MODBUS stack are provided within the respective callbacks. Whenever the stack requires the value of a register or a register is written the callback functions are executed. In the scope of this example input register values are provided by the function