#include <Controller.h>
Public Types | |
using | SetDirectionCallback = void(*)(uint8_t segment, Direction direction) |
Callback to handle hardware transmit/receive selection Typically called from interrupt context so implementation MUST be marked IRAM_ATTR. More... | |
using | OnRequestDelegate = Delegate< void(Controller &controller)> |
![]() | |
using | List = LinkedObjectListTemplate< Controller > |
![]() | |
using | Iterator = IteratorTemplate< Controller, Controller *, Controller & > |
using | ConstIterator = IteratorTemplate< const Controller, const Controller *, const Controller & > |
Public Member Functions | |
Controller (Serial &serial, uint8_t instance) | |
const FlashString & | classname () const override |
Get the class name for this Controller. More... | |
void | start () override |
Start the controller. More... | |
void | stop () override |
Stop all controllers. More... | |
void | onSetDirection (SetDirectionCallback callback) |
Set the transmit callback handler. More... | |
void | setDirection (IO::Direction direction) |
Whilst a port is acquired, call this method to being or end transmission. More... | |
Serial & | getSerial () |
void | handleEvent (Request *request, Event event) override |
void | onRequest (OnRequestDelegate callback) |
void | setSegment (uint8_t segment) |
void | send (const void *data, size_t size) |
![]() | |
Controller (uint8_t instance) | |
Construct a controller instance. More... | |
virtual | ~Controller () |
uint8_t | getInstance () const |
Get the controller instance number. More... | |
Device::OwnedList & | getDevices () |
Get list of devices for this controller. More... | |
void | freeDevices () |
Destroy all devices for this controller. More... | |
ErrorCode | createDevice (const char *id, JsonObjectConst config, Device *&device) |
Create a new devicce. More... | |
template<class DeviceClass > | |
ErrorCode | createDevice (const char *id, const typename DeviceClass::Config &config, DeviceClass *&device) |
Create a new device as a concrete type. More... | |
Device * | findDevice (const String &id) |
Locate a device from its identifier. More... | |
virtual bool | canStop () const |
Check if it's OK to stop this controller. More... | |
const CString & | getId () const |
Get the fully-qualified unique controller identifier. More... | |
bool | operator== (const String &id) const |
![]() | |
Controller * | getNext () const |
bool | insertAfter (Controller *object) |
Iterator | begin () const |
Iterator | end () const |
Iterator | cbegin () const |
Iterator | cend () const |
![]() | |
virtual | ~LinkedObject () |
virtual LinkedObject * | next () const |
bool | insertAfter (LinkedObject *object) |
bool | operator== (const LinkedObject &other) const |
bool | operator!= (const LinkedObject &other) const |
Protected Member Functions | |
virtual void | handleIncomingRequest () |
![]() | |
virtual void | handleEvent (Request *request, Event event) |
Implementations override this method to process events as they pass through the stack. More... | |
void | submit (Request *request) |
Queue a request. More... | |
void | checkDevices () |
void | resetTransactionTime () |
Additional Inherited Members | |
![]() | |
static void | registerDeviceClass (const Device::Factory &factory) |
Register a device factory. More... | |
Member Typedef Documentation
◆ OnRequestDelegate
using IO::RS485::Controller::OnRequestDelegate = Delegate<void(Controller& controller)> |
◆ SetDirectionCallback
using IO::RS485::Controller::SetDirectionCallback = void (*)(uint8_t segment, Direction direction) |
Callback to handle hardware transmit/receive selection Typically called from interrupt context so implementation MUST be marked IRAM_ATTR.
- Parameters
-
segment Identifies physical connection for shared/multiplexed port direction
Constructor & Destructor Documentation
◆ Controller()
Member Function Documentation
◆ classname()
|
inlineoverridevirtual |
Get the class name for this Controller.
Implements IO::Controller.
◆ getSerial()
|
inline |
◆ handleEvent()
◆ handleIncomingRequest()
|
inlineprotectedvirtual |
◆ onRequest()
|
inline |
◆ onSetDirection()
|
inline |
Set the transmit callback handler.
Typically with RS485 a GPIO is used to toggle between transmit/receive modes. Using a callback allows flexibility for your particular hardware implementation. You don't need to set this up if your hardware handles the switch automatically.
- Parameters
-
callback
◆ send()
void IO::RS485::Controller::send | ( | const void * | data, |
size_t | size | ||
) |
◆ setDirection()
|
inline |
Whilst a port is acquired, call this method to being or end transmission.
- Parameters
-
direction
- Note
- Port should normally be left in receive mode on request completion.
◆ setSegment()
|
inline |
◆ start()
|
overridevirtual |
Start the controller.
Controllers may now initiate communications with registered devices. Typically they'll query device status, etc.
Reimplemented from IO::Controller.
◆ stop()
|
overridevirtual |
Stop all controllers.
This method is called by the Device Manager, applications shouldn't need it.
- Note
- MUST call canStop() first to ensure it's safe to stop!
Reimplemented from IO::Controller.
The documentation for this class was generated from the following file: