SAE Teensy ECU
IIT SAE Microcontroller programming
|
An incoming canbus message, allows the message data to be interpreted through a simple wrapper class. More...
#include <CanBuffer.h>
Public Member Functions | |
Buffer (volatile uint8_t *buffer, bool outgoing=false) | |
Construct a new Buffer as a wrapper. | |
Buffer (const uint32_t address, volatile uint8_t *buffer, bool outgoing=false) | |
Construct a new internal Buffer. | |
void | init () |
Initialize a buffer if not done so already by constructor. | |
void | dump (uint8_t *dest) |
Dump the current buffer onto an external one. | |
void | set (const uint8_t *src) |
Replace the current buffer. | |
void | clear (void) |
Clear the buffer. | |
void | Buffer::setDouble (double val) |
void | Buffer::setULong (uint64_t val) |
void | Buffer::setLong (int64_t val) |
void | Buffer::setFloat (float val, size_t pos) |
void | Buffer::setUInt (uint32_t val, size_t pos) |
void | Buffer::setInt (int32_t val, size_t pos) |
void | Buffer::setUShort (uint16_t val, size_t pos) |
void | Buffer::setShort (int16_t val, size_t pos) |
void | Buffer::setUByte (uint8_t val, size_t pos) |
void | Buffer::setByte (int8_t val, size_t pos) |
void | Buffer::setBit (bool val, size_t pos) |
double | Buffer::getDouble () |
float | Buffer::getFloat (size_t pos) |
uint64_t | getULong () |
Interpret the buffer as an unsigned long. | |
int64_t | getLong () |
Interpret the buffer as a long. | |
uint32_t | getUInt (size_t pos) |
Interpret the buffer as an unsigned Integer at byte position pos | |
int32_t | getInt (size_t pos) |
Interpret the buffer as an Integer at byte position pos | |
uint16_t | getUShort (size_t pos) |
Interpret the buffer as an unsigned Short at byte position pos | |
int16_t | getShort (size_t pos) |
Interpret the buffer as an Short at byte position pos | |
uint8_t | getUByte (size_t pos) |
Interpret the buffer as an unsigned Byte at byte position pos | |
int8_t | getByte (size_t pos) |
Interpret the buffer as a Byte at byte position pos | |
bool | getBit (size_t pos) |
Get the bit at position pos of this buffer. | |
bool | lock () |
Locks this buffer to be used, returns false if it was unable todo so. | |
void | lock_wait () |
locks this buffer to be used, waits indefinitely for it to unlock if it is locked | |
void | unlock () |
Unlocks this buffer if it is locked. | |
Public Attributes | |
const uint32_t | address |
Address this buffer represents. | |
volatile uint8_t * | buffer |
The buffer. | |
volatile canCallback | callback |
Optional callback function associated with this buffer. | |
const bool | outgoing |
Whether this buffer is meant to be an outgoing message. | |
bool | modified = false |
Whether this buffer has been set in anyway. | |
An incoming canbus message, allows the message data to be interpreted through a simple wrapper class.
Definition at line 23 of file CanBuffer.h.
Construct a new Buffer as a wrapper.
buffer | the array to wrap around |
Definition at line 57 of file CanBuffer.h.
|
inline |
Construct a new internal Buffer.
address | the address this buffer should represent |
buffer | beginning of the array of 8 byte buffers to select from |
Definition at line 64 of file CanBuffer.h.
Clear the buffer.
Definition at line 109 of file CanBuffer.cpp.
Dump the current buffer onto an external one.
dest | the array to dump to |
Definition at line 87 of file CanBuffer.cpp.
Get the bit at position pos
of this buffer.
pos | the bit to check on the buffer |
Definition at line 84 of file CanBuffer.cpp.
Interpret the buffer as a Byte at byte position pos
pos | the byte to start interpreting at |
Definition at line 81 of file CanBuffer.cpp.
Interpret the buffer as an Integer at byte position pos
pos | the byte to start interpreting at |
Definition at line 69 of file CanBuffer.cpp.
int64_t CAN::Buffer::getLong | ( | ) |
Interpret the buffer as a long.
pos | the byte to start interpreting at |
Definition at line 60 of file CanBuffer.cpp.
Interpret the buffer as an Short at byte position pos
pos | the byte to start interpreting at |
Definition at line 75 of file CanBuffer.cpp.
Interpret the buffer as an unsigned Byte at byte position pos
pos | the byte to start interpreting at |
Definition at line 78 of file CanBuffer.cpp.
Interpret the buffer as an unsigned Integer at byte position pos
pos | the byte to start interpreting at |
Definition at line 66 of file CanBuffer.cpp.
uint64_t CAN::Buffer::getULong | ( | ) |
Interpret the buffer as an unsigned long.
pos | the byte to start interpreting at |
Definition at line 57 of file CanBuffer.cpp.
Interpret the buffer as an unsigned Short at byte position pos
pos | the byte to start interpreting at |
Definition at line 72 of file CanBuffer.cpp.
bool CAN::Buffer::lock | ( | ) |
Locks this buffer to be used, returns false if it was unable todo so.
Definition at line 120 of file CanBuffer.cpp.
void CAN::Buffer::lock_wait | ( | ) |
locks this buffer to be used, waits indefinitely for it to unlock if it is locked
Definition at line 124 of file CanBuffer.cpp.
void CAN::Buffer::set | ( | const uint8_t * | src | ) |
Replace the current buffer.
src | the array to be used |
Definition at line 98 of file CanBuffer.cpp.
void CAN::Buffer::unlock | ( | ) |
Unlocks this buffer if it is locked.
Definition at line 128 of file CanBuffer.cpp.
Address this buffer represents.
Definition at line 27 of file CanBuffer.h.
volatile canCallback CAN::Buffer::callback |
Optional callback function associated with this buffer.
Definition at line 39 of file CanBuffer.h.
Whether this buffer has been set in anyway.
Definition at line 50 of file CanBuffer.h.
Whether this buffer is meant to be an outgoing message.
Definition at line 44 of file CanBuffer.h.