Update CSV data, refactor UART packet handling, and adjust TUI layout: modify person entries in CSV, change UART packet synchronization bytes, and update max_rows calculation in person listing.

This commit is contained in:
2025-05-18 14:51:10 +02:00
parent 1650a741b2
commit 9e6dfc7d0e
4 changed files with 34 additions and 10 deletions
+3 -5
View File
@@ -26,9 +26,7 @@
28,Alena,Matouskova,3037,1,0,0 28,Alena,Matouskova,3037,1,0,0
29,Josef,Suchy,3038,1,0,0 29,Josef,Suchy,3038,1,0,0
30,Marketa,Rezacova,3039,1,0,0 30,Marketa,Rezacova,3039,1,0,0
31,Libor,Hanak,3040,1,0,0 31,Libor,Hanak,3040,1747561377,0,1
32,Libor,Hanak,3040,1,0,0 32,Libor,Hanak,3040,1,0,0
17267,Kamil,Novacek,2502,0,0,0 17767,Grzegorz,Brzeczyszczykiewicz,2502,0,0,0
17747,Kamil,Franta,2502,0,0,0 9158,Zima,Tomas,2440,1747561372,0,1
17767,Kamil,Filip,2502,0,0,0
9158,Jindrich,Sidlo,2440,0,0,0
1 1 Klara Novotna 3010 1 0 0
26 28 Alena Matouskova 3037 1 0 0
27 29 Josef Suchy 3038 1 0 0
28 30 Marketa Rezacova 3039 1 0 0
29 31 Libor Hanak 3040 1 1747561377 0 0 1
30 32 Libor Hanak 3040 1 0 0
31 17267 17767 Kamil Grzegorz Novacek Brzeczyszczykiewicz 2502 0 0 0
32 17747 9158 Kamil Zima Franta Tomas 2502 2440 0 1747561372 0 0 1
17767 Kamil Filip 2502 0 0 0
9158 Jindrich Sidlo 2440 0 0 0
+1 -1
View File
@@ -24,6 +24,6 @@ void *uartListener(void *arg);
uint16_t parseIncommingPacket(BYTE *_packet); uint16_t parseIncommingPacket(BYTE *_packet);
void sendPacketToDevice(BYTE *_packet); void sendPacketToDevice(int _uart, node_t *_person);
#endif #endif
+29 -3
View File
@@ -96,7 +96,7 @@ void *uartListener(void *arg)
switch (state) switch (state)
{ {
case SYNC0: case SYNC0:
if (byte == 0x55) if (byte == 0xFF)
{ {
packet[0] = byte; packet[0] = byte;
packet_index = 1; packet_index = 1;
@@ -105,7 +105,7 @@ void *uartListener(void *arg)
break; break;
case SYNC1: case SYNC1:
if (byte == 0xFF) if (byte == 0x55)
{ {
packet[1] = byte; packet[1] = byte;
packet_index = 2; packet_index = 2;
@@ -130,7 +130,9 @@ void *uartListener(void *arg)
if (crc == packet[5]) if (crc == packet[5])
{ {
uint16_t r_uuid = parseIncommingPacket(packet); uint16_t r_uuid = parseIncommingPacket(packet);
addTimeEvent(searchPersonByUUID(person_list, r_uuid), person_list); node_t *selected = searchPersonByUUID(person_list, r_uuid);
addTimeEvent(selected, person_list);
//sendPacketToDevice(uart, selected);
} }
else else
{ {
@@ -155,3 +157,27 @@ uint16_t parseIncommingPacket(BYTE *_packet)
return r_id; return r_id;
} }
void sendPacketToDevice(int _uart, node_t *_person)
{
BYTE packet[72];
int offset = 0;
packet[0] = 0xFF;
packet[1] = 0X55;
offset += 2;
memcpy(packet + offset, _person->user.name, 32);
offset += 32;
memcpy(packet + offset, _person->user.surname, 32);
offset += 32;
time_t current_time = time(NULL);
memcpy(packet + offset, &current_time, sizeof(time_t));
offset += time(NULL);
BYTE crc = 0;
for (int i = 0; i < offset; i++)
{
crc ^= packet[i];
}
packet[offset] = crc;
offset += 1;
write(_uart, packet, 72);
}
+1 -1
View File
@@ -260,7 +260,7 @@ void personListing(list_t *person_list, int terminal_x, int terminal_y)
WINDOW *personlisting = newwin(win_height, win_width, start_y, start_x); WINDOW *personlisting = newwin(win_height, win_width, start_y, start_x);
int max_rows = win_height - 2; int max_rows = win_height - 3;
int total_count = 0; int total_count = 0;
node_t *current = person_list->head; node_t *current = person_list->head;
while (current) while (current)