7void Buffer::setDouble(
double val) {
11void Buffer::setULong(uint64_t val) {
15void Buffer::setLong(int64_t val) {
19void Buffer::setFloat(
float val,
size_t pos) {
20 *(
float *)(
buffer + pos) = val;
23void Buffer::setUInt(uint32_t val,
size_t pos) {
24 *(uint32_t *)(
buffer + pos) = val;
27void Buffer::setInt(int32_t val,
size_t pos) {
28 *(int32_t *)(
buffer + pos) = val;
31void Buffer::setUShort(uint16_t val,
size_t pos) {
32 *(uint16_t *)(
buffer + pos) = val;
35void Buffer::setShort(int16_t val,
size_t pos) {
36 *(int16_t *)(
buffer + pos) = val;
39void Buffer::setUByte(uint8_t val,
size_t pos) {
43void Buffer::setByte(int8_t val,
size_t pos) {
44 *(int8_t *)(
buffer + pos) = val;
47void Buffer::setBit(
bool val,
size_t pos) {
48 buffer[pos / 8] &= val << (pos % 8);
49 buffer[pos / 8] |= val << (pos % 8);
54double Buffer::getDouble() {
58 return *(uint64_t *)
buffer;
63float Buffer::getFloat(
size_t pos) {
64 return *(
float *)(
buffer + pos);
67 return *(uint32_t *)(
buffer + pos);
70 return *(int32_t *)(
buffer + pos);
73 return *(uint16_t *)(
buffer + pos);
76 return *(int16_t *)(
buffer + pos);
82 return *(int8_t *)(
buffer + pos);
85 return (
buffer[pos / 8] >> (pos % 8)) & 1;
121 return mux.try_lock();
Canbus functionality. Refer to Canbus.h for more info.
void set(const uint8_t *src)
Replace the current 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
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.
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.