Woman, Life, Freedom


OBD-II Emulator
Linux ODB-II Emulator public and protected interfaces documentation
can_frame.h
1#ifndef CAN_FRAME_H
2#define CAN_FRAME_H
3
4#include <stdint.h>
5#include <array>
6#include <vector>
7#include <cstddef>
8
9namespace ObdEmulator
10{
13 {
14 public:
16 static const size_t cDataLengthMax{8};
17
18 private:
19 static const uint32_t cStandardIdMax{0x7ff};
20 static const uint32_t cEXtendedIdMax{0x1fffffff};
21
22 uint32_t mId;
23 bool mExtended;
24 bool mRemote;
25 size_t mDataLength;
26 std::array<uint8_t, cDataLengthMax> mData;
27
28 public:
29 CanFrame() = delete;
30
38 uint32_t id,
39 bool extended,
40 bool remote,
41 const std::vector<uint8_t> &data);
42
46 uint32_t GetId() const noexcept;
47
50 bool IsExtended() const noexcept;
51
54 bool IsRemote() const noexcept;
55
58 size_t GetDataLength() const noexcept;
59
62 const std::array<uint8_t, cDataLengthMax> &GetData() const noexcept;
63 };
64}
65
66#endif
CAN transmission packet frame.
Definition: can_frame.h:13
bool IsExtended() const noexcept
Indicate whether the frame is extended or standard.
static const size_t cDataLengthMax
Maximum CAN frame data length.
Definition: can_frame.h:16
CanFrame(uint32_t id, bool extended, bool remote, const std::vector< uint8_t > &data)
Constructor.
size_t GetDataLength() const noexcept
Get frame data length (DLC)
uint32_t GetId() const noexcept
Get frame CAN ID.
bool IsRemote() const noexcept
Indicate whether the frame is remote transmission request (RTR) or data.
const std::array< uint8_t, cDataLengthMax > & GetData() const noexcept
Get frame data.