semf
|
Interface for using CAN. More...
#include <canhardware.h>
Public Types | |
enum class | ErrorCode : uint8_t { Write_IsBusy = 0 , Write_DataIsNullptr , Write_DataSizeIsZero , Read_DataIsNullptr , Read_DataSizeIsZero , Request_IsBusy } |
Error codes for this class. Error ID identify a unique error() / onError call (excluding transferring). More... | |
Public Types inherited from semf::CommunicationHardware | |
enum class | Type { SynchronousMaster = 1 , SynchronousSlave , Asynchronous } |
enum class | Frame : uint8_t { First = 0x01 , Next = 0x08 , Last = 0x10 , FirstAndLast = 0x11 } |
Public Member Functions | |
virtual | ~CanHardware ()=default |
void | write (const uint8_t data[], size_t dataSize) override |
For writing data, dataWritten signal will be emitted after successful write. More... | |
void | read (uint8_t buffer[], size_t bufferSize) override |
For setting the read buffer. This has be done for getting a dataAvailable signal for handling the data. More... | |
bool | isBusyReading () const override |
Communication hardware is busy reading at the moment. More... | |
bool | isBusyWriting () const override |
Communication hardware is busy writing at the moment. More... | |
void | request () override |
Public Member Functions inherited from semf::Can | |
virtual | ~Can ()=default |
virtual void | request ()=0 |
virtual uint32_t | messageId () const =0 |
Returns the message ID for reading data. Use this function after reading the data via read-function. More... | |
virtual void | setMessageId (uint32_t id)=0 |
Sets the message ID for writing data. Use this function before writing the data via write-function. More... | |
virtual void | setFrequency (uint32_t hz)=0 |
Sets the speed. More... | |
virtual void | setFilter (uint32_t filterBank, uint32_t messageId, uint32_t messageIdMask)=0 |
Sets a message hardware receive filter. More... | |
Public Member Functions inherited from semf::CommunicationHardwareAsynchronous | |
virtual | ~CommunicationHardwareAsynchronous ()=default |
Type | type () const override |
Returns the hardware type. More... | |
void | setFrame (Frame frame) final |
Sets the selected usage of start and stop condition. More... | |
Public Member Functions inherited from semf::CommunicationHardware | |
virtual | ~CommunicationHardware ()=default |
virtual void | init ()=0 |
virtual void | deinit ()=0 |
virtual Type | type () const =0 |
Returns the hardware type. More... | |
virtual void | setFrame (Frame frame)=0 |
Sets the selected usage of start and stop condition. More... | |
Public Member Functions inherited from semf::app::Communication | |
virtual | ~Communication ()=default |
virtual void | write (const uint8_t data[], size_t dataSize)=0 |
For writing data, dataWritten signal will be emitted after successful write. More... | |
virtual void | read (uint8_t buffer[], size_t bufferSize)=0 |
For reading data, dataAvailable signal will be emitted after successful read. More... | |
virtual void | stopRead ()=0 |
virtual void | stopWrite ()=0 |
virtual bool | isBusyReading () const =0 |
Communication hardware is busy reading at the moment. More... | |
virtual bool | isBusyWriting () const =0 |
Communication hardware is busy writing at the moment. More... | |
Protected Member Functions | |
void | setBusyWriting (bool isBusy) |
Sets the busy flag for writing. More... | |
virtual void | setReadBuffer (uint8_t buffer[], size_t bufferSize)=0 |
Sets the read buffer for having the possibility to handle the received data. More... | |
virtual void | writeHardware (const uint8_t data[], size_t dataSize)=0 |
Hardware will write data. More... | |
virtual void | requestHardware ()=0 |
void | onDataWritten () |
void | onDataAvailable () |
void | onError (Error thrown) |
Is called if an error occurred by hardware read or write access. Will emit error signal. More... | |
void | onDataRequested () |
Additional Inherited Members | |
Public Attributes inherited from semf::Can | |
Signal | dataRequested |
Public Attributes inherited from semf::app::Communication | |
Signal | dataWritten |
Signal | dataAvailable |
Signal | writeStopped |
Signal | readStopped |
Signal< Error > | error |
Interface for using CAN.
Can
read()
function will only register the receive buffer and allow handling the received data. Definition at line 23 of file canhardware.h.
|
strong |
Error codes for this class. Error ID identify a unique error() / onError call (excluding transferring).
Enumerator | |
---|---|
Write_IsBusy | |
Write_DataIsNullptr | |
Write_DataSizeIsZero | |
Read_DataIsNullptr | |
Read_DataSizeIsZero | |
Request_IsBusy |
Definition at line 29 of file canhardware.h.
|
virtualdefault |
|
overridevirtual |
Communication hardware is busy reading at the moment.
Implements semf::app::Communication.
Definition at line 58 of file canhardware.cpp.
|
overridevirtual |
Communication hardware is busy writing at the moment.
Implements semf::app::Communication.
Definition at line 63 of file canhardware.cpp.
|
protected |
Is called after data is available in the hardware. Will emit dataAvailable
signal.
Definition at line 93 of file canhardware.cpp.
|
protected |
Slot for hardware has finished request.
Definition at line 106 of file canhardware.cpp.
|
protected |
Is called after data are written by the hardware. Will emit dataWritten
signal.
Definition at line 86 of file canhardware.cpp.
|
protected |
Is called if an error occurred by hardware read or write access. Will emit error
signal.
thrown | A thrown error object. |
Definition at line 99 of file canhardware.cpp.
|
overridevirtual |
For setting the read buffer. This has be done for getting a dataAvailable
signal for handling the data.
buffer | Buffer to store received bytes in. |
bufferSize | Size of receive buffer. |
Read_DataIsNullptr | If data is nullptr. |
Read_DataSizeIsZero | If dataSize is zero. |
Implements semf::app::Communication.
Definition at line 41 of file canhardware.cpp.
|
overridevirtual |
Sends a CAN request. Message id has to be set first by calling setMessageId()
.
Request_IsBusy | If this is busy. |
Implements semf::Can.
Definition at line 68 of file canhardware.cpp.
|
protectedpure virtual |
Hardware will request data on specific id. Id can be set by calling setMessageId()
.
Implemented in semf::Stm32Can.
|
protected |
Sets the busy flag for writing.
write()
, read()
busy is set to true
. In onDataAvailable()
, onDataWritten()
and onError()
is busy reseted to false
. isBusy | true for busy, false for idle. |
Definition at line 81 of file canhardware.cpp.
|
protectedpure virtual |
Sets the read buffer for having the possibility to handle the received data.
buffer | Buffer to store received bytes in. |
bufferSize | Size of receive buffer. |
Implemented in semf::Stm32Can.
|
overridevirtual |
For writing data, dataWritten
signal will be emitted after successful write.
data | Array, containing data to write. |
dataSize | Size of write data. |
setMessageId()
. Write_IsBusy | If this is busy. |
Write_DataIsNullptr | If data is nullptr. |
Write_DataSizeIsZero | If dataSize is zero. |
Implements semf::app::Communication.
Definition at line 15 of file canhardware.cpp.
|
protectedpure virtual |
Hardware will write data.
data | data array |
dataSize | data array size |
Implemented in semf::Stm32Can.