muCom
1.0
The reliable, fast and easy way to exchange binary data via UART
|
#include <muComBase.h>
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... | |
Base muCom class.
This class implements the muCom protocol itself and relies on being inherited in order to implement the actual serial interface.
muComBase::muComBase | ( | uint8_t | num_var, |
uint8_t | num_func | ||
) |
Constructor of the base class.
[in] | num_var | Max. number of variables to be linked |
[in] | num_func | Max. number of functions to be linked |
|
inline |
Get timestamp of last successful communication.
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.
|
inline |
Invoke a function at the communication partner.
The target function will be invoked with one byte of random data.
[in] | index | Index of the function to be invoked |
|
inline |
Invoke a function at the communication partner.
[in] | index | Index of the function to be invoked |
[in] | data | Pointer to a buffer as a parameter for the function being invoked |
[in] | cnt | Number of data bytes in the buffer that will be sent to the function being invoked |
int8_t muComBase::linkFunction | ( | uint8_t | index, |
muComFunc | function | ||
) |
Link function to the muCom interface.
[in] | index | Index used to invoke this functions |
[in] | function | Function to be linked to the interface |
int8_t muComBase::linkVariable | ( | uint8_t | index, |
uint8_t * | var, | ||
uint8_t | size | ||
) |
Link a variable or a buffer to the muCom interface.
[in] | index | Index used to access the variable/buffer |
[in] | var | Pointer to the variable or buffer to be linked to the interface |
[in] | size | Size of the variable/buffer in bytes (only neccessary when linking buffers) |
int8_t muComBase::read | ( | uint8_t | index, |
uint8_t * | data, | ||
uint8_t | cnt | ||
) |
Read data from the communication partner.
[in] | index | Index of the remote variable to be read |
[in] | data | Array to store the contents of the remote variable |
[in] | cnt | Number of data bytes to read |
uint8_t muComBase::readByte | ( | uint8_t | index | ) |
Read a byte from the communication partner.
[in] | index | Index of the remote variable to be read |
|
inline |
Read a byte from the communication partner.
[in] | index | Index of the remote variable to be read |
[in] | data | Pointer to the variable where the read data should be stored |
float muComBase::readFloat | ( | uint8_t | index | ) |
Read a float from the communication partner.
[in] | index | Index of the remote variable to be read |
|
inline |
Read a float from the communication partner.
[in] | index | Index of the remote variable to be read |
[in] | data | Pointer to the variable where the read data should be stored |
uint32_t muComBase::readLong | ( | uint8_t | index | ) |
Read a long from the communication partner.
[in] | index | Index of the remote variable to be read |
|
inline |
Read a long from the communication partner.
[in] | index | Index of the remote variable to be read |
[in] | data | Pointer to the variable where the read data should be stored |
uint64_t muComBase::readLongLong | ( | uint8_t | index | ) |
Read a long long from the communication partner.
[in] | index | Index of the remote variable to be read |
|
inline |
Read a long long from the communication partner.
[in] | index | Index of the remote variable to be read |
[in] | data | Pointer to the variable where the read data should be stored |
uint16_t muComBase::readShort | ( | uint8_t | index | ) |
Read a short from the communication partner.
[in] | index | Index of the remote variable to be read |
|
inline |
Read a short from the communication partner.
[in] | index | Index of the remote variable to be read |
[in] | data | Pointer to the variable where the read data should be stored |
void muComBase::setTimeout | ( | int16_t | timeout | ) |
Set timeout for read requests.
[in] | timeout | Timeout in milliseconds |
|
inline |
Write a data array to a remote variable.
[in] | index | Index of the remote buffer to be written to |
[in] | data | Data array to be written to the remote buffer |
[in] | cnt | Size of the data array in bytes |
|
inline |
Write a byte (8 bit) to the communication partner.
[in] | index | Index of the remote variable to be written to |
[in] | data | Byte to be written to the communication partner |
|
inline |
Write a float to the communication partner.
[in] | index | Index of the remote variable to be written to |
[in] | data | Float to be written to the communication partner |
|
inline |
Write a long (32 bit) to the communication partner.
[in] | index | Index of the remote variable to be written to |
[in] | data | Long to be written to the communication partner |
|
inline |
Write a long long (64 bit) to the communication partner.
[in] | index | Index of the remote variable to be written to |
[in] | data | Long long to be written to the communication partner |
|
inline |
Write a short (16 bit) to the communication partner.
[in] | index | Index of the remote variable to be written to |
[in] | data | Short to be written to the communication partner |