26 #ifndef _COMMCANUTIL_H
27 #define _COMMCANUTIL_H
32 #include <wx/datetime.h>
34 #if !defined(__WXMSW__) && !defined(__WXMAC__)
35 #include <linux/can.h>
36 #include <linux/can/raw.h>
40 #define CAN_MAX_DLEN 8
45 uint8_t data[CAN_MAX_DLEN];
49 #if defined (__WXMAC__)
50 #define CAN_MAX_DLEN 8
55 uint8_t data[CAN_MAX_DLEN];
59 unsigned long BuildCanID(
int priority,
int source,
int destination,
int pgn);
60 bool IsFastMessagePGN(
unsigned pgn);
73 unsigned char priority;
75 unsigned char destination;
100 std::vector<unsigned char>
data;
104 last_gc_run(wxDateTime::Now()) {}
106 Entry operator[](
int i)
const {
return entries[i]; }
125 std::vector<Entry> entries;
128 bool IsEntryExpired(
unsigned int i);
129 int GarbageCollector(
void);
133 wxDateTime last_gc_run;
134 wxDateTime dropped_frame_time;
CanHeader header
Can header, used to "map" the incoming fast message fragments.
unsigned int cursor
cursor into the current position in data.
unsigned int sid
Sequence identifier, used to check if a received message is the next message in the sequence.
unsigned int expected_length
total data length from first frame
wxDateTime time_arrived
time of last fragment.
std::vector< unsigned char > data
Received data.
Track fast message fragments eventually forming complete messages.
int AddNewEntry(void)
Allocate a new, fresh entry and return index to it.
void Remove(int pos)
Remove entry at pos.
Entry & operator[](int i)
Getter.
bool AppendEntry(const CanHeader hdr, const unsigned char *data, int index)
Append fragment to existing multipart message.
int FindMatchingEntry(const CanHeader header, const unsigned char sid)
Setter.
bool InsertEntry(const CanHeader header, const unsigned char *data, int index)
Insert a new entry, first part of a multipart message.