# HG changeset patch # User Ideenmodellierer # Date 1770831344 -3600 # Node ID a3f42192da0f13746ad5ebe3a2dc92c548d25b9c # Parent 785772303f9cc7b364075e22fe886d7567f895fa 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. diff -r 785772303f9c -r a3f42192da0f Small_CPU/Inc/uartProtocol_Co2.h --- a/Small_CPU/Inc/uartProtocol_Co2.h Tue Feb 10 19:36:05 2026 +0100 +++ b/Small_CPU/Inc/uartProtocol_Co2.h Wed Feb 11 18:35:44 2026 +0100 @@ -37,6 +37,7 @@ UART_CO2_IDLE, /* sensor detected and no communication pending */ UART_CO2_ERROR, UART_CO2_SETUP = 10, /* collecting data needed to be read out of the sensor once at startup */ + UART_CO2_MODE, /* set operation mode for sensor */ UART_CO2_OPERATING, /* normal operation */ UART_CO2_CALIBRATE /* request calibration */ } uartCO2Status_t; diff -r 785772303f9c -r a3f42192da0f Small_CPU/Src/externalInterface.c --- a/Small_CPU/Src/externalInterface.c Tue Feb 10 19:36:05 2026 +0100 +++ b/Small_CPU/Src/externalInterface.c Wed Feb 11 18:35:44 2026 +0100 @@ -836,14 +836,7 @@ tmpSensorMap[EXT_INTERFACE_MUX_OFFSET] = SENSOR_CO2; externalInterface_SensorState[EXT_INTERFACE_MUX_OFFSET] = UART_COMMON_INIT; externalInterface_CheckBaudrate(SENSOR_CO2); - if(foundSensorMap[EXT_INTERFACE_SENSOR_CNT-1] == SENSOR_MUX) /* switch sensor operation mode depending on HW config */ - { - uartCo2_SendCmd(CO2CMD_MODE_POLL, cmdString, &cmdLength); - } - else - { - uartCo2_SendCmd(CO2CMD_MODE_STREAM, cmdString, &cmdLength); - } + uartCo2_SendCmd(CO2CMD_MODE_POLL, cmdString, &cmdLength); } break; case DETECTION_CO2_0: diff -r 785772303f9c -r a3f42192da0f Small_CPU/Src/uartProtocol_Co2.c --- 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);