22 lines
413 B
C++
22 lines
413 B
C++
#include "CanStructs.h"
|
|
|
|
uint32_t CanId::serialize() const
|
|
{
|
|
uint32_t id = 0;
|
|
id |= source;
|
|
id |= destination << 8;
|
|
id |= command << 16;
|
|
id |= device << 22;
|
|
id |= error << 26;
|
|
return id;
|
|
}
|
|
|
|
void CanId::deserialize(uint32_t id)
|
|
{
|
|
source = id & 0xFF;
|
|
destination = (id >> 8) & 0xFF;
|
|
command = (id >> 16) & 0x3F;
|
|
device = (id >> 22) & 0xF;
|
|
error = (id >> 26) & 0x3;
|
|
}
|