1#ifndef __ECU_CANBUFFER_H__
2#define __ECU_CANBUFFER_H__
7#include "TeensyThreads.h"
76 void dump(uint8_t *dest);
84 void set(
const uint8_t *src);
92 void Buffer::setDouble(
double val);
93 void Buffer::setULong(uint64_t val);
94 void Buffer::setLong(int64_t val);
95 void Buffer::setFloat(
float val,
size_t pos);
96 void Buffer::setUInt(uint32_t val,
size_t pos);
97 void Buffer::setInt(int32_t val,
size_t pos);
98 void Buffer::setUShort(uint16_t val,
size_t pos);
99 void Buffer::setShort(int16_t val,
size_t pos);
100 void Buffer::setUByte(uint8_t val,
size_t pos);
101 void Buffer::setByte(int8_t val,
size_t pos);
102 void Buffer::setBit(
bool val,
size_t pos);
104 double Buffer::getDouble();
106 float Buffer::getFloat(
size_t pos);
135 int32_t
getInt(
size_t pos);
Canbus functionality. Refer to Canbus.h for more info.
void(* canCallback)(uint32_t, volatile uint8_t *)
The function type to pass to addCallback.
An incoming canbus message, allows the message data to be interpreted through a simple wrapper class.
void set(const uint8_t *src)
Replace the current buffer.
const uint32_t address
Address this buffer represents.
void init()
Initialize a buffer if not done so already by constructor.
volatile canCallback callback
Optional callback function associated with this buffer.
bool modified
Whether this buffer has been set in anyway.
int8_t getByte(size_t pos)
Interpret the buffer as a Byte at byte position pos
uint64_t getULong()
Interpret the buffer as an unsigned 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
int16_t getShort(size_t pos)
Interpret the buffer as an Short at byte position pos
Buffer(const uint32_t address, volatile uint8_t *buffer, bool outgoing=false)
Construct a new internal Buffer.
int64_t getLong()
Interpret the buffer as a long.
bool getBit(size_t pos)
Get the bit at position pos of this buffer.
void clear(void)
Clear the buffer.
void dump(uint8_t *dest)
Dump the current buffer onto an external one.
const bool outgoing
Whether this buffer is meant to be an outgoing message.
Buffer(volatile uint8_t *buffer, bool outgoing=false)
Construct a new Buffer as a wrapper.
uint8_t getUByte(size_t pos)
Interpret the buffer as an unsigned Byte at byte position pos
void lock_wait()
locks this buffer to be used, waits indefinitely for it to unlock if it is locked
volatile uint8_t * buffer
The buffer.
bool lock()
Locks this buffer to be used, returns false if it was unable todo so.
uint16_t getUShort(size_t pos)
Interpret the buffer as an unsigned Short at byte position pos
void unlock()
Unlocks this buffer if it is locked.