Refactor UART handling and enhance user data structures
This commit is contained in:
Vendored
+3
-1
@@ -2,6 +2,8 @@
|
||||
"files.associations": {
|
||||
"users.h": "c",
|
||||
"ncurses.h": "c",
|
||||
"stdlib.h": "c"
|
||||
"stdlib.h": "c",
|
||||
"errno.h": "c",
|
||||
"rfid_handler.h": "c"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
#ifndef __RFID_HANDLER_H__
|
||||
#define __RFIT_HANDLER_H__
|
||||
|
||||
#endif
|
||||
|
||||
// UART handler thread
|
||||
void *uartListener(void *arg);
|
||||
+12
-2
@@ -12,9 +12,9 @@ typedef struct person
|
||||
|
||||
char *name;
|
||||
char *surname;
|
||||
uint8_t department;
|
||||
uint32_t department;
|
||||
|
||||
time_t last_timestamp;
|
||||
time_t last_time_event;
|
||||
uint32_t total;
|
||||
|
||||
pthread_mutex_t lock;
|
||||
@@ -26,4 +26,14 @@ typedef struct node
|
||||
struct node *next;
|
||||
} 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
|
||||
BIN
Binary file not shown.
+1
-14
@@ -10,20 +10,7 @@
|
||||
|
||||
#include "users.h"
|
||||
#include "tui.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;
|
||||
}
|
||||
#include "rfid_handler.h"
|
||||
|
||||
int main(int argc, char const **argv)
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user