Mercurial > public > ostc4
changeset 975:142f3d0363b3 Evo_2_23 tip
Workaround single DiveO2 startup:
If a DiveO2 sensor is used without Mux then the sensor is not recognized by the Autodetection. It seems to be a timing issue. A delay between first command send and receive function seems to fix (or hide) the problem.
author | Ideenmodellierer |
---|---|
date | Tue, 28 Jan 2025 22:31:17 +0100 |
parents | 53900dfe335b |
children | |
files | Small_CPU/Src/externalInterface.c Small_CPU/Src/uartProtocol_O2.c |
diffstat | 2 files changed, 49 insertions(+), 50 deletions(-) [+] |
line wrap: on
line diff
--- a/Small_CPU/Src/externalInterface.c Tue Jan 28 16:15:31 2025 +0100 +++ b/Small_CPU/Src/externalInterface.c Tue Jan 28 22:31:17 2025 +0100 @@ -688,7 +688,7 @@ { switch(externalAutoDetect) { - case DETECTION_INIT: externalInterfaceMuxReqIntervall = 0; + case DETECTION_INIT: externalInterfaceMuxReqIntervall = 0xffff; sensorIndex = 0; uartMuxChannel = 0; tmpSensorMap[0] = SENSOR_OPTIC; @@ -1177,72 +1177,70 @@ timeToTrigger = COMMAND_TX_DELAY; retryRequest = 1; } - else if(time_elapsed_ms(lastRequestTick,tick) > externalInterfaceMuxReqIntervall) /* switch sensor and / or trigger next request */ { - lastRequestTick = tick; - TriggerTick = tick; - retryRequest = 0; - timeToTrigger = 1; + if(timeToTrigger == 0) /* no pending action */ + { + TriggerTick = tick; + retryRequest = 0; + timeToTrigger = 1; - if((externalInterface_SensorState[activeSensorId] == UART_O2_REQ_O2) /* timeout */ - || (externalInterface_SensorState[activeSensorId] == UART_O2_REQ_RAW) - || (externalInterface_SensorState[activeSensorId] == UART_CO2_OPERATING) - || (externalInterface_SensorState[activeSensorId] == UART_GNSS_GET_PVT) - || (externalInterface_SensorState[activeSensorId] == UART_GNSS_GET_SAT)) - { - forceMuxChannel = 1; - externalInterface_SensorState[activeSensorId] = UART_O2_IDLE; - switch(pmap[activeSensorId]) + if((externalInterface_SensorState[activeSensorId] == UART_O2_REQ_O2) /* timeout */ + || (externalInterface_SensorState[activeSensorId] == UART_O2_REQ_RAW) + || (externalInterface_SensorState[activeSensorId] == UART_CO2_OPERATING) + || (externalInterface_SensorState[activeSensorId] == UART_GNSS_GET_PVT) + || (externalInterface_SensorState[activeSensorId] == UART_GNSS_GET_SAT)) { - case SENSOR_DIGO2: setExternalInterfaceChannel(activeSensorId,0.0); - break; - case SENSOR_CO2: externalInterface_SetCO2Value(0.0); - externalInterface_SetCO2State(0); - break; - default: - break; + forceMuxChannel = 1; + externalInterface_SensorState[activeSensorId] = UART_O2_IDLE; + switch(pmap[activeSensorId]) + { + case SENSOR_DIGO2: setExternalInterfaceChannel(activeSensorId,0.0); + break; + case SENSOR_CO2: externalInterface_SetCO2Value(0.0); + externalInterface_SetCO2State(0); + break; + default: + break; + } } - } - if((externalInterface_SensorState[activeSensorId] == UART_CO2_SETUP) /* timeout while setting up sensors */ - || (externalInterface_SensorState[activeSensorId] == UART_O2_CHECK)) - { - forceMuxChannel = 1; - } + if((externalInterface_SensorState[activeSensorId] == UART_CO2_SETUP) /* timeout while setting up sensors */ + || (externalInterface_SensorState[activeSensorId] == UART_O2_CHECK)) + { + forceMuxChannel = 1; + } - if(pmap[EXT_INTERFACE_SENSOR_CNT-1] == SENSOR_MUX) /* select next sensor if mux is connected */ - { - if(activeUartChannel < MAX_MUX_CHANNEL) + if(pmap[EXT_INTERFACE_SENSOR_CNT-1] == SENSOR_MUX) /* select next sensor if mux is connected */ { - index = ExternalInterface_SelectUsedMuxChannel(activeUartChannel); - if((index != activeUartChannel) || (forceMuxChannel)) + if(activeUartChannel < MAX_MUX_CHANNEL) { - forceMuxChannel = 0; - timeToTrigger = 100; - activeUartChannel = index; - switch(pmap[index + EXT_INTERFACE_MUX_OFFSET]) + index = ExternalInterface_SelectUsedMuxChannel(activeUartChannel); + if((index != activeUartChannel) || (forceMuxChannel)) { - case SENSOR_DIGO2: uartO2_SetChannel(activeUartChannel); - /* no break */ - case SENSOR_CO2: - case SENSOR_GNSS: externalInterface_CheckBaudrate(SENSOR_MUX); - UART_MUX_SelectAddress(activeUartChannel); - externalInterface_CheckBaudrate(pmap[activeUartChannel + EXT_INTERFACE_MUX_OFFSET]); - break; - default: - break; + forceMuxChannel = 0; + timeToTrigger = 100; + activeUartChannel = index; + switch(pmap[index + EXT_INTERFACE_MUX_OFFSET]) + { + case SENSOR_DIGO2: uartO2_SetChannel(activeUartChannel); + /* no break */ + case SENSOR_CO2: + case SENSOR_GNSS: externalInterface_CheckBaudrate(SENSOR_MUX); + UART_MUX_SelectAddress(activeUartChannel); + externalInterface_CheckBaudrate(pmap[activeUartChannel + EXT_INTERFACE_MUX_OFFSET]); + break; + default: + break; + } } } } } - else - { - timeToTrigger = 1; - } } if((timeToTrigger != 0) && (time_elapsed_ms(TriggerTick,tick) > timeToTrigger)) { + lastRequestTick = tick; timeToTrigger = 0; switch (pmap[activeSensorId]) {
--- a/Small_CPU/Src/uartProtocol_O2.c Tue Jan 28 16:15:31 2025 +0100 +++ b/Small_CPU/Src/uartProtocol_O2.c Tue Jan 28 22:31:17 2025 +0100 @@ -109,6 +109,7 @@ UART_clearRxBuffer(&Uart1Ctrl); uartO2_SetupCmd(localComState,cmdString,&cmdLength); UART_SendCmdString(cmdString); + HAL_Delay(80); rxState = O2RX_CONFIRM; respondErrorDetected = 0; digO2Connected = 0;