From a6a1a58bcfaf90d403fa4e32f673ee259c7d6b78 Mon Sep 17 00:00:00 2001 From: drath Date: Sun, 24 May 2026 12:29:59 +0200 Subject: [PATCH] flock implemented --- README.md | 1 - src/main.c | 13 +++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index ceff360..586480a 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,6 @@ Alphanumeric LCD controller software for Linux (kind of LCDSmartie for Windows b Same as plugins. Just write in more features scrub, learn some C, damn ## TODOs -- implement flock - GPU power is jumpy, average? Use accumulator instead? - Extra screens support perhaps? just halt sensors monitoring thread and print another struct on display if needed, have a semaphore or sth - Maybe not even screens, keep the 1st line and change lines 2-4 diff --git a/src/main.c b/src/main.c index 0b4aa25..33463e5 100644 --- a/src/main.c +++ b/src/main.c @@ -171,15 +171,19 @@ static void *display_thread(void *arg) { } int main(void) { - control.g_running = true; - applog(LOG_START, "linuxSmartie started"); + applog(LOG_START, "linuxSmartie starting"); applog(LOG_DBG, "Compiled on %s %s with %s", __DATE__, __TIME__, C_STD); - struct sensors_t *sensors = malloc(sizeof(*sensors)); // no actual point in mallocing and it is ever so sligtly slower to access heap vs stack, but its cool + /* see if another instance is up, quit if it is */ + if (get_instance_lock() < 0) + return 1; + + /* malloc memory for the struct */ + struct sensors_t *sensors = malloc(sizeof(*sensors)); // no actual point in mallocing and it is ever so sligtly slower to access heap vs stack, but its cool if (sensors == NULL) { applog(LOG_ERR, "can't allocate mem for the sensor struct. You don't got %lu bytes bro?", sizeof(struct sensors_t)); free(sensors); - return -1; + return 2; } applog(LOG_INF, "sensor struct allocated, size is %lu bytes", sizeof(struct sensors_t)); @@ -196,6 +200,7 @@ int main(void) { /* control vars setup */ pthread_mutex_init(&control.sensors_mtx, NULL); pthread_cond_init(&control.sensors_ready, NULL); + control.g_running = true; /* thread setup */ pthread_t sensors_pthread;