|
Lely core libraries
1.9.2
|
The I/O context. More...
#include <io_context.hpp>

Data Structures | |
| struct | Impl_ |
| The internal implementation of the I/O context. More... | |
Public Member Functions | |
| IoContext (aio::TimerBase &timer, aio::CanBusBase &bus, BasicLockable *mutex=nullptr) | |
| Creates a new I/O context. More... | |
| aio::ExecutorBase | GetExecutor () const noexcept |
| Returns the executor used to process I/O events on the CAN bus. | |
| template<class F > | |
| void | Post (F &&f) |
| Schedules the specified Callable object for execution. More... | |
Protected Member Functions | |
| CANNet * | net () const noexcept |
| Returns a pointer to the internal CAN network interface from <lely/can/net.hpp>. | |
| void | SetTime () |
| Update the CAN network time. More... | |
| virtual void | OnCanState (CanState new_state, CanState old_state) noexcept |
| The function invoked when a CAN bus state change is detected. More... | |
| virtual void | OnCanError (CanError error) noexcept |
| The function invoked when an error is detected on the CAN bus. More... | |
The I/O context.
This context manages all timer and I/O events on the CAN bus.
Definition at line 42 of file io_context.hpp.
| lely::canopen::IoContext::IoContext | ( | aio::TimerBase & | timer, |
| aio::CanBusBase & | bus, | ||
| BasicLockable * | mutex = nullptr |
||
| ) |
Creates a new I/O context.
| timer | the timer used for CANopen events. |
| bus | a handle to the CAN bus. |
| mutex | an (optional) pointer to the mutex to be locked while timer and I/O events are processed. The mutex MUST be unlocked when any public member function is invoked; it will be locked for the duration of any call to a virtual member function (OnCanState() or OnCanError()). |
Definition at line 74 of file io_context.cpp.
|
inline |
Schedules the specified Callable object for execution.
Definition at line 70 of file io_context.hpp.
|
protected |
Update the CAN network time.
If a mutex was passed to the constructor, it MUST be locked for the duration of this call.
Definition at line 91 of file io_context.cpp.
|
inlineprotectedvirtualnoexcept |
The function invoked when a CAN bus state change is detected.
The state is represented by one the CanState::ACTIVE, CanState::PASSIVE or CanState::BUSOFF values.
| new_state | the current state of the CAN bus. |
| old_state | the previous state of the CAN bus. |
Reimplemented in lely::canopen::AsyncMaster, lely::canopen::BasicMaster, and lely::canopen::Node.
Definition at line 104 of file io_context.hpp.
|
inlineprotectedvirtualnoexcept |
The function invoked when an error is detected on the CAN bus.
| error | a bitwise combination of CanError::BIT, CanError::STUFF, CanError::CRC, CanError::FORM, CanError::ACK and CanError::OTHER. |
Reimplemented in lely::canopen::AsyncMaster, and lely::canopen::BasicMaster.
Definition at line 117 of file io_context.hpp.