General description of the request-schema used for most modules.
The TUC-Bot and its library knows many different modules. Each module usually handles a single feature of the robot. Using all features at once, will lead to communication with all modules. This will slow down the internal communication and important information might be delayed. Therefore, all modules are automatically deactivated on startup.
If a certain module is needed, then the internal communication needs to be activated. That is why, all respective modules have a request function, e.g. sharps_request().
All request functions have a parameter called request. This parameter is of type eRequestType and can be one of the following values:
kRequestClear | Clears all ongoing requests and returns immediately. |
kRequestSingle | Requests one update and returns immediately. |
kRequestWait | Requests one update and waits until it is received. |
kRequestContinuous | Requests continuous updates and returns immediately. |
If a certain request is set, the communication with the respective module will be started. Since, all communication is done sequentially, the precise timing when it is done, can not be estimated beforehand. Therefore, certain flags are set automatically by the library: One flag indicates wether the requested data was received and an other flag indicates if the new data differs from the old data.
Some modules are not just offering data, but also need an input. For example the motor power level can be set via motors_set(). In a similar matter to the reception, there exists a flag if the transmission was succesfully.
The state of the above mentioned flags can be checked with the following functions:
received function | e.g. line_received() | Returns if data was received. |
changed function | e.g. buttons_changed() | Returns if received data differs from old data. |
transmitted function | e.g. motors_transmitted() | Returns if data block was transmitted successfully. |
Some modules allow for requesting and sending data. For both the same data blocks are used. To avoid unintended data corruption, sending data is always dominant.
Therefore, setting data and triggering a send-transmission, will automatically block all ongoing requests to this data block. If a request has already started, its result is ignored and it will be restarted after the send-transmission is done.
Modules which need to be requested:
Modules which can also transmit data: