BusBricks: CommInterface< interface_type > Class Template Reference
BusBricks  0.1
Customize bus-communication
Loading...
Searching...
No Matches
CommInterface< interface_type > Class Template Referenceabstract

Template for generic communication-interface specifies a standardized interface to use for integrating any hardware-interface (e.g. SoftwareSerial, OneWire...) into a Service-Interface The template ensures the correct handling of send- and receive-buffers of the interface: More...

#include <CommInterface.h>

Inheritance diagram for CommInterface< interface_type >:
[legend]
Collaboration diagram for CommInterface< interface_type >:
[legend]

Public Member Functions

 CommInterface (interface_type *interface, uint32_t baudrate)
 Construct a new Comm-Interface object.
 
void sendNewFrame (CharArray *sendFrame)
 Specify the next frame to be sent by the interface, no overwrite, if the sendBuffer is already pointing to another frame.
 
bool finishedSending ()
 Check, if the Frame was sent and the CommInterface is ready to send the next Frame Interface is ready to send a new frame, if the sendBuffer is nullpointer.
 
void getReceivedFrame (CharArray *externalRecBuffer)
 Define the destination, the next received Frame should be stored at.
 
bool receivedNewFrame ()
 Check, if a new Frame was received and stored at the in getReceivedFrame specified location the interface is waiting waiting for getReceivedFrame-call to specify the location, the next received frame should be stored at.
 
virtual void receiveCycle ()
 Execution of receive-cycle, set the receiveBuffer to nullptr after a new frame was received.
 
virtual void sendCycle ()
 Execution of send-cycle, set the sendBuffer to nullptr, after the frame, sendBuffer was pointing at, was send.
 
- Public Member Functions inherited from CommInterfaceBase
virtual void setup_interface ()
 Setup the Interface has to be called in Setup-function.
 
 CommInterfaceBase ()
 Construct a new Comm Interface Base object.
 
 ~CommInterfaceBase ()
 Destroy the Comm-Interface Base object.
 
- Public Member Functions inherited from ErrorState
 ErrorState ()
 Default constructor for ErrorState.
 
 ~ErrorState ()
 Destroy the ErrorState object.
 
void raiseError (errorCodes code)
 raises a new error by setting the given error-code as errorState
 
errorCodes getErrorState ()
 Get the currently active error-code.
 
void clearErrorState ()
 sets the current error-state to "no Error"
 

Protected Member Functions

virtual bool send ()=0
 Send the frame, sendBuffer is pointing to (has to be done in the derived class)
 
virtual bool receive ()=0
 Receive a Frame (has to be done in the derived class)
 

Protected Attributes

interface_type * interface
 pointer to an instance of the native bus-interface (setup outside of BusBricks)
 
CharArraysendBuffer = nullptr
 pointer to the next frame to be send, set to nullptr if Frame was sent
 
CharArrayreceiveBuffer = nullptr
 pointer to CharArray-object, a received frame should be stored at, set to nullptr if Frame was copied to destination
 

Detailed Description

template<typename interface_type>
class CommInterface< interface_type >

Template for generic communication-interface specifies a standardized interface to use for integrating any hardware-interface (e.g. SoftwareSerial, OneWire...) into a Service-Interface The template ensures the correct handling of send- and receive-buffers of the interface:

sendBuffer set to nullptr: the Interface is ready to send another frame sendBuffer not set to nullptr: the frame, sendBuffer is pointing to, has to be send next

recBuffer set to nullptr: the frame received last was written to the destination successfully, no new receive-Buffer was defined recBuffer not set to nullptr: the interface is waiting to receive a new frame to write it to the destination, recBuffer is pointing to

Stores errors occurred during internal processing by using the ErrorState class. The errors can be picked-up by calling the public ErrorState functions after calling the send or receive cycles

Template Parameters
interface_typetype of native bus-interface to setup the Comm-interface for (e.g. SoftwareSerial)

Constructor & Destructor Documentation

◆ CommInterface()

template<typename interface_type >
CommInterface< interface_type >::CommInterface ( interface_type * interface,
uint32_t baudrate )
inline

Construct a new Comm-Interface object.

Parameters
interfacepointer to an instance of the native bus-interface (setup outside of BusBricks)
baudratebits per second

Member Function Documentation

◆ finishedSending()

template<typename interface_type >
bool CommInterface< interface_type >::finishedSending ( )
inlinevirtual

Check, if the Frame was sent and the CommInterface is ready to send the next Frame Interface is ready to send a new frame, if the sendBuffer is nullpointer.

Returns
true ready to accept a new frame to send next with sendNewFrame-function
false frame, sendBuffer is pointing to is not sent yet not ready to to accept a new frame in sendNewFrame-function

Reimplemented from CommInterfaceBase.

◆ getReceivedFrame()

template<typename interface_type >
void CommInterface< interface_type >::getReceivedFrame ( CharArray * externalRecBuffer)
inlinevirtual

Define the destination, the next received Frame should be stored at.

Parameters
externalRecBufferpointer to CharArray-object, the next received Frame should be stored at

Reimplemented from CommInterfaceBase.

◆ receive()

template<typename interface_type >
virtual bool CommInterface< interface_type >::receive ( )
protectedpure virtual

Receive a Frame (has to be done in the derived class)

Returns
true a new Frame was received and stored at the String-obj, receiveBuffer is pointing to
false no new frame was received receiveBuffer still empty

Implemented in CommInterface_modbusRTU.

Here is the caller graph for this function:

◆ receivedNewFrame()

template<typename interface_type >
bool CommInterface< interface_type >::receivedNewFrame ( )
inlinevirtual

Check, if a new Frame was received and stored at the in getReceivedFrame specified location the interface is waiting waiting for getReceivedFrame-call to specify the location, the next received frame should be stored at.

Returns
true a new frame was received and stored, waiting for getReceivedFrame-call to specify receiveBuffer
false receiveBuffer is specified, but still empty

Reimplemented from CommInterfaceBase.

◆ send()

template<typename interface_type >
virtual bool CommInterface< interface_type >::send ( )
protectedpure virtual

Send the frame, sendBuffer is pointing to (has to be done in the derived class)

Returns
true the frame, the sendBuffer was pointing to, was sent
false the frame, the sendBuffer was pointing to, was not sent or sendBuffer nullptr (no frame to be sent)

Implemented in CommInterface_modbusRTU.

Here is the caller graph for this function:

◆ sendNewFrame()

template<typename interface_type >
void CommInterface< interface_type >::sendNewFrame ( CharArray * sendFrame)
inlinevirtual

Specify the next frame to be sent by the interface, no overwrite, if the sendBuffer is already pointing to another frame.

Parameters
sendFramepointer to next Frame-object to be send

Reimplemented from CommInterfaceBase.


The documentation for this class was generated from the following file: