muCom  1.0
The reliable, fast and easy way to exchange binary data via UART
Public Member Functions | List of all members
muComBase Class Referenceabstract

Base muCom class. More...

#include <muComBase.h>

Inheritance diagram for muComBase:
muCom

Public Member Functions

 muComBase (uint8_t num_var, uint8_t num_func)
 Constructor of the base class. More...
 
 ~muComBase (void)
 Destructor of the base class.
 
int16_t getLastCommTime (void)
 Get timestamp of last successful communication. More...
 
void setTimeout (int16_t timeout)
 Set timeout for read requests. More...
 
uint8_t handle (void)
 Handle the muCom interface. More...
 
int8_t linkFunction (uint8_t index, muComFunc function)
 Link function to the muCom interface. More...
 
int8_t linkVariable (uint8_t index, uint8_t *var, uint8_t size)
 Link a variable or a buffer to the muCom interface. More...
 
void linkVariable (uint8_t index, uint8_t *var)
 
void linkVariable (uint8_t index, int8_t *var)
 
void linkVariable (uint8_t index, uint16_t *var)
 
void linkVariable (uint8_t index, int16_t *var)
 
void linkVariable (uint8_t index, uint32_t *var)
 
void linkVariable (uint8_t index, int32_t *var)
 
void linkVariable (uint8_t index, uint64_t *var)
 
void linkVariable (uint8_t index, int64_t *var)
 
void linkVariable (uint8_t index, float *var)
 
void invokeFunction (uint8_t index, uint8_t *data, uint8_t cnt)
 Invoke a function at the communication partner. More...
 
void invokeFunction (uint8_t index)
 Invoke a function at the communication partner. More...
 
void write (uint8_t index, uint8_t *data, uint8_t cnt)
 Write a data array to a remote variable. More...
 
void writeByte (uint8_t index, uint8_t data)
 Write a byte (8 bit) to the communication partner. More...
 
void writeShort (uint8_t index, uint16_t data)
 Write a short (16 bit) to the communication partner. More...
 
void writeLong (uint8_t index, uint32_t data)
 Write a long (32 bit) to the communication partner. More...
 
void writeLongLong (uint8_t index, uint64_t data)
 Write a long long (64 bit) to the communication partner. More...
 
void writeFloat (uint8_t index, float data)
 Write a float to the communication partner. More...
 
int8_t read (uint8_t index, uint8_t *data, uint8_t cnt)
 Read data from the communication partner. More...
 
int8_t readByte (uint8_t index, uint8_t *data)
 Read a byte from the communication partner. More...
 
int8_t readByte (uint8_t index, int8_t *data)
 
int8_t readShort (uint8_t index, uint16_t *data)
 Read a short from the communication partner. More...
 
int8_t readShort (uint8_t index, int16_t *data)
 
int8_t readLong (uint8_t index, uint32_t *data)
 Read a long from the communication partner. More...
 
int8_t readLong (uint8_t index, int32_t *data)
 
int8_t readLongLong (uint8_t index, uint64_t *data)
 Read a long long from the communication partner. More...
 
int8_t readLongLong (uint8_t index, int64_t *data)
 
int8_t readFloat (uint8_t index, float *data)
 Read a float from the communication partner. More...
 
uint8_t readByte (uint8_t index)
 Read a byte from the communication partner. More...
 
uint16_t readShort (uint8_t index)
 Read a short from the communication partner. More...
 
uint32_t readLong (uint8_t index)
 Read a long from the communication partner. More...
 
uint64_t readLongLong (uint8_t index)
 Read a long long from the communication partner. More...
 
float readFloat (uint8_t index)
 Read a float from the communication partner. More...
 

Detailed Description

Base muCom class.

This class implements the muCom protocol itself and relies on being inherited in order to implement the actual serial interface.

Constructor & Destructor Documentation

◆ muComBase()

muComBase::muComBase ( uint8_t  num_var,
uint8_t  num_func 
)

Constructor of the base class.

Parameters
[in]num_varMax. number of variables to be linked
[in]num_funcMax. number of functions to be linked

Member Function Documentation

◆ getLastCommTime()

int16_t muComBase::getLastCommTime ( void  )
inline

Get timestamp of last successful communication.

Returns
Timestamp in ms

◆ handle()

uint8_t muComBase::handle ( void  )

Handle the muCom interface.

This function handles the muCom interface and decodes the received data. It should be executed as often as possible and will handle writing to and reading from linked variables as well as executing requested functions. This function is also used during reading data from the communication partner.

Returns
1 = answer from a read request was received, else 0

◆ invokeFunction() [1/2]

void muComBase::invokeFunction ( uint8_t  index)
inline

Invoke a function at the communication partner.

The target function will be invoked with one byte of random data.

Parameters
[in]indexIndex of the function to be invoked

◆ invokeFunction() [2/2]

void muComBase::invokeFunction ( uint8_t  index,
uint8_t *  data,
uint8_t  cnt 
)
inline

Invoke a function at the communication partner.

Parameters
[in]indexIndex of the function to be invoked
[in]dataPointer to a buffer as a parameter for the function being invoked
[in]cntNumber of data bytes in the buffer that will be sent to the function being invoked

◆ linkFunction()

int8_t muComBase::linkFunction ( uint8_t  index,
muComFunc  function 
)

Link function to the muCom interface.

Parameters
[in]indexIndex used to invoke this functions
[in]functionFunction to be linked to the interface

◆ linkVariable()

int8_t muComBase::linkVariable ( uint8_t  index,
uint8_t *  var,
uint8_t  size 
)

Link a variable or a buffer to the muCom interface.

Parameters
[in]indexIndex used to access the variable/buffer
[in]varPointer to the variable or buffer to be linked to the interface
[in]sizeSize of the variable/buffer in bytes (only neccessary when linking buffers)

◆ read()

int8_t muComBase::read ( uint8_t  index,
uint8_t *  data,
uint8_t  cnt 
)

Read data from the communication partner.

Parameters
[in]indexIndex of the remote variable to be read
[in]dataArray to store the contents of the remote variable
[in]cntNumber of data bytes to read

◆ readByte() [1/2]

uint8_t muComBase::readByte ( uint8_t  index)

Read a byte from the communication partner.

Parameters
[in]indexIndex of the remote variable to be read
Returns
Byte read from the communication partner.
-1 in case of errors

◆ readByte() [2/2]

int8_t muComBase::readByte ( uint8_t  index,
uint8_t *  data 
)
inline

Read a byte from the communication partner.

Parameters
[in]indexIndex of the remote variable to be read
[in]dataPointer to the variable where the read data should be stored
Returns
See muCom error codes (0 = OK, <0 = Error)

◆ readFloat() [1/2]

float muComBase::readFloat ( uint8_t  index)

Read a float from the communication partner.

Parameters
[in]indexIndex of the remote variable to be read
Returns
Float read from the communication partner.
-1 in case of errors

◆ readFloat() [2/2]

int8_t muComBase::readFloat ( uint8_t  index,
float *  data 
)
inline

Read a float from the communication partner.

Parameters
[in]indexIndex of the remote variable to be read
[in]dataPointer to the variable where the read data should be stored
Returns
See muCom error codes (0 = OK, <0 = Error)

◆ readLong() [1/2]

uint32_t muComBase::readLong ( uint8_t  index)

Read a long from the communication partner.

Parameters
[in]indexIndex of the remote variable to be read
Returns
Long read from the communication partner.
-1 in case of errors

◆ readLong() [2/2]

int8_t muComBase::readLong ( uint8_t  index,
uint32_t *  data 
)
inline

Read a long from the communication partner.

Parameters
[in]indexIndex of the remote variable to be read
[in]dataPointer to the variable where the read data should be stored
Returns
See muCom error codes (0 = OK, <0 = Error)

◆ readLongLong() [1/2]

uint64_t muComBase::readLongLong ( uint8_t  index)

Read a long long from the communication partner.

Parameters
[in]indexIndex of the remote variable to be read
Returns
Long long read from the communication partner.
-1 in case of errors

◆ readLongLong() [2/2]

int8_t muComBase::readLongLong ( uint8_t  index,
uint64_t *  data 
)
inline

Read a long long from the communication partner.

Parameters
[in]indexIndex of the remote variable to be read
[in]dataPointer to the variable where the read data should be stored
Returns
See muCom error codes (0 = OK, <0 = Error)

◆ readShort() [1/2]

uint16_t muComBase::readShort ( uint8_t  index)

Read a short from the communication partner.

Parameters
[in]indexIndex of the remote variable to be read
Returns
Short read from the communication partner.
-1 in case of errors

◆ readShort() [2/2]

int8_t muComBase::readShort ( uint8_t  index,
uint16_t *  data 
)
inline

Read a short from the communication partner.

Parameters
[in]indexIndex of the remote variable to be read
[in]dataPointer to the variable where the read data should be stored
Returns
See muCom error codes (0 = OK, <0 = Error)

◆ setTimeout()

void muComBase::setTimeout ( int16_t  timeout)

Set timeout for read requests.

Parameters
[in]timeoutTimeout in milliseconds

◆ write()

void muComBase::write ( uint8_t  index,
uint8_t *  data,
uint8_t  cnt 
)
inline

Write a data array to a remote variable.

Parameters
[in]indexIndex of the remote buffer to be written to
[in]dataData array to be written to the remote buffer
[in]cntSize of the data array in bytes

◆ writeByte()

void muComBase::writeByte ( uint8_t  index,
uint8_t  data 
)
inline

Write a byte (8 bit) to the communication partner.

Parameters
[in]indexIndex of the remote variable to be written to
[in]dataByte to be written to the communication partner

◆ writeFloat()

void muComBase::writeFloat ( uint8_t  index,
float  data 
)
inline

Write a float to the communication partner.

Parameters
[in]indexIndex of the remote variable to be written to
[in]dataFloat to be written to the communication partner

◆ writeLong()

void muComBase::writeLong ( uint8_t  index,
uint32_t  data 
)
inline

Write a long (32 bit) to the communication partner.

Parameters
[in]indexIndex of the remote variable to be written to
[in]dataLong to be written to the communication partner

◆ writeLongLong()

void muComBase::writeLongLong ( uint8_t  index,
uint64_t  data 
)
inline

Write a long long (64 bit) to the communication partner.

Parameters
[in]indexIndex of the remote variable to be written to
[in]dataLong long to be written to the communication partner

◆ writeShort()

void muComBase::writeShort ( uint8_t  index,
uint16_t  data 
)
inline

Write a short (16 bit) to the communication partner.

Parameters
[in]indexIndex of the remote variable to be written to
[in]dataShort to be written to the communication partner

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