#include <Controller.h>

Inheritance diagram for IO::RS485::Controller:
Collaboration diagram for IO::RS485::Controller:

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)>
 
- Public Types inherited from IO::Controller
using List = LinkedObjectListTemplate< Controller >
 
- Public Types inherited from LinkedObjectTemplate< 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 FlashStringclassname () 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...
 
SerialgetSerial ()
 
void handleEvent (Request *request, Event event) override
 
void onRequest (OnRequestDelegate callback)
 
void setSegment (uint8_t segment)
 
void send (const void *data, size_t size)
 
- Public Member Functions inherited from IO::Controller
 Controller (uint8_t instance)
 Construct a controller instance. More...
 
virtual ~Controller ()
 
uint8_t getInstance () const
 Get the controller instance number. More...
 
Device::OwnedListgetDevices ()
 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...
 
DevicefindDevice (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 CStringgetId () const
 Get the fully-qualified unique controller identifier. More...
 
bool operator== (const String &id) const
 
- Public Member Functions inherited from LinkedObjectTemplate< Controller >
Controller * getNext () const
 
bool insertAfter (Controller *object)
 
Iterator begin () const
 
Iterator end () const
 
Iterator cbegin () const
 
Iterator cend () const
 
- Public Member Functions inherited from LinkedObject
virtual ~LinkedObject ()
 
virtual LinkedObjectnext () const
 
bool insertAfter (LinkedObject *object)
 
bool operator== (const LinkedObject &other) const
 
bool operator!= (const LinkedObject &other) const
 

Protected Member Functions

virtual void handleIncomingRequest ()
 
- Protected Member Functions inherited from IO::Controller
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 Public Member Functions inherited from IO::Controller
static void registerDeviceClass (const Device::Factory &factory)
 Register a device factory. More...
 

Member Typedef Documentation

◆ OnRequestDelegate

◆ 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
segmentIdentifies physical connection for shared/multiplexed port
direction

Constructor & Destructor Documentation

◆ Controller()

IO::RS485::Controller::Controller ( Serial serial,
uint8_t  instance 
)
inline

Member Function Documentation

◆ classname()

const FlashString& IO::RS485::Controller::classname ( ) const
inlineoverridevirtual

Get the class name for this Controller.

Implements IO::Controller.

◆ getSerial()

Serial& IO::RS485::Controller::getSerial ( )
inline

◆ handleEvent()

void IO::RS485::Controller::handleEvent ( Request request,
Event  event 
)
override

◆ handleIncomingRequest()

virtual void IO::RS485::Controller::handleIncomingRequest ( )
inlineprotectedvirtual

◆ onRequest()

void IO::RS485::Controller::onRequest ( OnRequestDelegate  callback)
inline

◆ onSetDirection()

void IO::RS485::Controller::onSetDirection ( SetDirectionCallback  callback)
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()

void IO::RS485::Controller::setDirection ( IO::Direction  direction)
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()

void IO::RS485::Controller::setSegment ( uint8_t  segment)
inline

◆ start()

void IO::RS485::Controller::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()

void IO::RS485::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: