diff Small_CPU/Src/uartProtocol_Co2.c @ 1063:a3f42192da0f Icon_Integration

Always use polling mode for CO2 operation: In the previous version the CO2 sensor was operated in streaming mode (2 measurements a second) in case it was used stand alone (without multiplexer). This added some complexity to the implementation (setup, error handling etc). To reduce this the sensor will now always be operated in polling mode like it is done for multiplexer operation. To make sure that the correct mode is set a command has been added to the configuration steps.
author Ideenmodellierer
date Wed, 11 Feb 2026 18:35:44 +0100
parents 0b81ac558e89
children 1f2067cad41b
line wrap: on
line diff
--- a/Small_CPU/Src/uartProtocol_Co2.c	Tue Feb 10 19:36:05 2026 +0100
+++ b/Small_CPU/Src/uartProtocol_Co2.c	Wed Feb 11 18:35:44 2026 +0100
@@ -71,9 +71,6 @@
 	uint8_t activeSensor = externalInterface_GetActiveUartSensor();
 	uartCO2Status_t localComState = externalInterface_GetSensorState(activeSensor + EXT_INTERFACE_MUX_OFFSET);
 
-	uint8_t *pmap = externalInterface_GetSensorMapPointer(0);
-
-
 	if(localComState == UART_CO2_ERROR)
 	{
 		localComState = lastComState;
@@ -95,9 +92,13 @@
 		}
 		else
 		{
-			localComState = UART_CO2_IDLE;
+			localComState = UART_CO2_MODE;
 		}
 	}
+	else if(localComState == UART_CO2_MODE)
+	{
+		uartCo2_SendCmd(CO2CMD_MODE_POLL, cmdString, &cmdLength);
+	}
 	else
 	{
 		if(localComState == UART_CO2_CALIBRATE)
@@ -105,9 +106,8 @@
 			uartCo2_SendCmd(CO2CMD_CALIBRATE, cmdString, &cmdLength);
 			localComState = UART_CO2_IDLE;
 		}
-		else if(pmap[EXT_INTERFACE_SENSOR_CNT-1] == SENSOR_MUX)		/* sensor is working in polling mode if mux is connected to avoid interference with other sensors */
+		else 
 		{
-			//if(cmdLength == 0)							/* poll data */
 			if(localComState == UART_CO2_IDLE)
 			{
 				if(externalInterface_GetCO2Scale() == 0.0)
@@ -127,11 +127,6 @@
 				cmdLength = 0;
 			}
 		}
-		else
-		{
-			localComState = UART_CO2_OPERATING;					/* sensor in streaming mode if not connected to mux => operating */
-			UART_StartDMA_Receiption(&Uart1Ctrl);
-		}
 	}
 	lastComState = localComState;
 	externalInterface_SetSensorState(activeSensor + EXT_INTERFACE_MUX_OFFSET,localComState);
@@ -150,6 +145,7 @@
 		switch(data)
 		{
 			case 'G':
+			case 'K':
 			case 'l':
 			case 'D':
 			case 'Z':
@@ -187,17 +183,22 @@
 		if(rxState == CO2RX_DataComplete)
 		{
 			CO2Connected = 1;
-			if(localComState == UART_CO2_SETUP)
+			switch(localComState)
 			{
-				if(dataType == '.')
-				{
-					localComState = UART_CO2_IDLE;
-				}
+				case UART_CO2_SETUP:	if(dataType == '.')
+										{
+											localComState = UART_CO2_IDLE;
+										}
+					break;
+				case UART_CO2_MODE:		if((dataType == 'K') && (dataValue == 2))
+										{
+											localComState = UART_CO2_IDLE;
+										}
+					break;
+				default: localComState = UART_CO2_IDLE;
+					break;
 			}
-			else
-			{
-				localComState = UART_CO2_IDLE;
-			}
+
 			if(externalInterface_GetCO2State() == 0)
 			{
 				externalInterface_SetCO2State(EXT_INTERFACE_33V_ON);