Refactor UART handling and enhance user data structures

This commit is contained in:
2025-04-22 20:34:19 +02:00
parent 4ff9a7f03d
commit d642cc92ab
6 changed files with 48 additions and 17 deletions
+3 -1
View File
@@ -2,6 +2,8 @@
"files.associations": { "files.associations": {
"users.h": "c", "users.h": "c",
"ncurses.h": "c", "ncurses.h": "c",
"stdlib.h": "c" "stdlib.h": "c",
"errno.h": "c",
"rfid_handler.h": "c"
} }
} }
+7
View File
@@ -0,0 +1,7 @@
#ifndef __RFID_HANDLER_H__
#define __RFIT_HANDLER_H__
#endif
// UART handler thread
void *uartListener(void *arg);
+12 -2
View File
@@ -12,9 +12,9 @@ typedef struct person
char *name; char *name;
char *surname; char *surname;
uint8_t department; uint32_t department;
time_t last_timestamp; time_t last_time_event;
uint32_t total; uint32_t total;
pthread_mutex_t lock; pthread_mutex_t lock;
@@ -26,4 +26,14 @@ typedef struct node
struct node *next; struct node *next;
} node_t; } node_t;
uint16_t generateUUID(node_t * _head);
uint16_t searchUUIDByName(node_t * _head);
node_t * searchPersonByUUID(node_t * _head);
void addPersonToList(node_t * _head, char * _name, char * _surname, uint32_t _department);
void addTimeEvent(node_t * _person);
#endif #endif
BIN
View File
Binary file not shown.
+1 -14
View File
@@ -10,20 +10,7 @@
#include "users.h" #include "users.h"
#include "tui.h" #include "tui.h"
#include "rfid_handler.h"
void *uartListener(void *arg)
{
char *uart_address = (char *)arg;
int uart = open(uart_address, O_RDWR | O_NOCTTY | O_NDELAY);
if (uart == -1)
{
perror("Failed to open UART");
return NULL;
}
close(uart);
return NULL;
}
int main(int argc, char const **argv) int main(int argc, char const **argv)
{ {
+25
View File
@@ -0,0 +1,25 @@
#include "rfid_handler.h"
#include "users.h"
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <termios.h>
#include <string.h>
void *uartListener(void *arg)
{
char *uart_address = (char *)arg;
int uart = open(uart_address, O_RDWR | O_NOCTTY | O_NDELAY);
if (uart == -1)
{
perror("Failed to open UART");
return NULL;
}
close(uart);
return NULL;
}