Skip to content
Snippets Groups Projects
Commit d4413e6a authored by Leon Bohnwagner's avatar Leon Bohnwagner :crab:
Browse files

feat: add packet struct

parent 49a1bf00
No related branches found
No related tags found
No related merge requests found
......@@ -15,7 +15,7 @@ typedef s64 int64_t;
#include <stdint.h>
#endif
#define MAX_MESSAGE_DATA_SIZE 4096
#define MAX_MESSAGE_DATA_SIZE 8
enum message_data_type {
INT8,
......
......@@ -35,6 +35,11 @@ static atomic_t wake_counter = ATOMIC_INIT(0);
static int slot = 0;
typedef struct packet {
message_t data;
uint32_t crc;
} packet_t;
static int device_open(struct inode *inode, struct file *file)
{
return 0;
......@@ -110,10 +115,12 @@ static int timed_thread_fn(void *args) {
atomic_dec(&wake_counter);
if (slot == 0) {
uint32_t crc = calculate_crc32(&message, sizeof(message));
packet_t packet;
packet.data = *message;
packet.crc = calculate_crc32(&packet.data, sizeof(&packet.data));
send_data(&message, sizeof(message));
send_data(&crc, sizeof(uint32_t));
send_data(&packet, sizeof(packet));
}
slot = (slot + 1) % SLOTS;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment