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
+29 -3
View File
@@ -96,7 +96,7 @@ void *uartListener(void *arg)
switch (state)
{
case SYNC0:
if (byte == 0x55)
if (byte == 0xFF)
{
packet[0] = byte;
packet_index = 1;
@@ -105,7 +105,7 @@ void *uartListener(void *arg)
break;
case SYNC1:
if (byte == 0xFF)
if (byte == 0x55)
{
packet[1] = byte;
packet_index = 2;
@@ -130,7 +130,9 @@ void *uartListener(void *arg)
if (crc == packet[5])
{
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
{
@@ -154,4 +156,28 @@ uint16_t parseIncommingPacket(BYTE *_packet)
memcpy(&r_event_type, &_packet[4], 1);
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);
int max_rows = win_height - 2;
int max_rows = win_height - 3;
int total_count = 0;
node_t *current = person_list->head;
while (current)