lpcmanager

5ccb381c307c
Parents 967430460440
Children 83d83e28f6d9
LPCBus: Device bus init was not repeatable across stop/start.

In case init happens multiple time, explicit POSIX initialization calls has to be used instead of static initializers.
--- a/LPCBus/SOM_Devices_decl.c Wed Aug 30 12:04:45 2023 +0200
+++ b/LPCBus/SOM_Devices_decl.c Thu Sep 07 11:25:03 2023 +0200
@@ -124,11 +124,11 @@
static commTimer uartPortTim[MAX_UART_DEVICES];
static pthread_t UART_task;
-static pthread_mutex_t UART_WriteMutex = PTHREAD_MUTEX_INITIALIZER;
-static pthread_mutex_t UART_ReadMutex = PTHREAD_MUTEX_INITIALIZER;
-static pthread_mutex_t UART_WakeCondLock = PTHREAD_MUTEX_INITIALIZER;
-static pthread_cond_t UART_WakeCond = PTHREAD_COND_INITIALIZER;
-static int UART_WakeCondValue = 0;
+static pthread_mutex_t UART_WriteMutex;
+static pthread_mutex_t UART_ReadMutex;
+static pthread_mutex_t UART_WakeCondLock;
+static pthread_cond_t UART_WakeCond;
+static int UART_WakeCondValue;
static int UART_task_active;
void* UART_task_proc(void *arg)
--- a/LPCBus/SOM_Devices_init.c Wed Aug 30 12:04:45 2023 +0200
+++ b/LPCBus/SOM_Devices_init.c Thu Sep 07 11:25:03 2023 +0200
@@ -7,6 +7,7 @@
uartDevWriteBuf_plc_state = EMPTY;
uartDevReadBuf_plc_state = EMPTY;
bzero(&uartDev, sizeof(uartDev));
+uartDevNum = MAX_UART_DEVICES;
bzero(&uartDevReadBufA, sizeof(uartDevReadBuf_t));
bzero(&uartDevReadBufB, sizeof(uartDevReadBuf_t));
@@ -20,6 +21,14 @@
bzero(&uartCommStatusBuf, sizeof(uartCommStatusBuf));
bzero(&uartCommErrCntBuf, sizeof(uartCommErrCntBuf));
+bzero(&uartPortTim, sizeof(commTimer));
+
+pthread_mutex_init(&UART_WriteMutex, NULL);
+pthread_mutex_init(&UART_ReadMutex, NULL);
+pthread_mutex_init(&UART_WakeCondLock, NULL);
+pthread_cond_init(&UART_WakeCond, NULL);
+UART_WakeCondValue = 0;
+UART_task_active = 1;
%(init_code)s
@@ -61,9 +70,6 @@
return err;
}
-UART_WakeCondValue = 0;
-UART_task_active = 1;
-
if(err = pthread_create(&UART_task, &attr, &UART_task_proc, NULL));
return err;