MCPcopy Create free account
hub / github.com/TactilityProject/Tactility / makeCASPacket

Function makeCASPacket

Tactility/Source/hal/gps/GpsInit.cpp:49–77  ·  view source on GitHub ↗

Function to create a CAS packet for editing in memory

Source from the content-addressed store, hash-verified

47
48// Function to create a CAS packet for editing in memory
49static uint8_t makeCASPacket(uint8_t* buffer, uint8_t class_id, uint8_t msg_id, uint8_t payload_size, const uint8_t *msg)
50{
51 // General CAS structure
52 // | H1 | H2 | payload_len | cls | msg | Payload ... | Checksum |
53 // Size: | 1 | 1 | 2 | 1 | 1 | payload_len | 4 |
54 // Pos: | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 ... | 6 + payload_len ... |
55 // |------|------|-------------|------|------|------|--------------|---------------------------|
56 // | 0xBA | 0xCE | 0xXX | 0xXX | 0xXX | 0xXX | 0xXX | 0xXX ... | 0xXX | 0xXX | 0xXX | 0xXX |
57
58 // Construct the CAS packet
59 buffer[0] = 0xBA; // header 1 (0xBA)
60 buffer[1] = 0xCE; // header 2 (0xCE)
61 buffer[2] = payload_size; // length 1
62 buffer[3] = 0; // length 2
63 buffer[4] = class_id; // class
64 buffer[5] = msg_id; // id
65
66 buffer[6 + payload_size] = 0x00; // Checksum
67 buffer[7 + payload_size] = 0x00;
68 buffer[8 + payload_size] = 0x00;
69 buffer[9 + payload_size] = 0x00;
70
71 for (int i = 0; i < payload_size; i++) {
72 buffer[6 + i] = msg[i];
73 }
74 CASChecksum(buffer, (payload_size + 10));
75
76 return (payload_size + 10);
77}
78
79GpsResponse getACKCas(::Device* uart, uint8_t class_id, uint8_t msg_id, uint32_t waitMillis)
80{

Callers 1

initAtgm336hFunction · 0.85

Calls 1

CASChecksumFunction · 0.85

Tested by

no test coverage detected