Mercurial > public > ostc4
comparison Small_CPU/Src/externalInterface.c @ 975:142f3d0363b3 Evo_2_23
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 | 3420e3ba698d |
| children | 0b81ac558e89 |
comparison
equal
deleted
inserted
replaced
| 974:53900dfe335b | 975:142f3d0363b3 |
|---|---|
| 686 | 686 |
| 687 if(externalAutoDetect != DETECTION_OFF) | 687 if(externalAutoDetect != DETECTION_OFF) |
| 688 { | 688 { |
| 689 switch(externalAutoDetect) | 689 switch(externalAutoDetect) |
| 690 { | 690 { |
| 691 case DETECTION_INIT: externalInterfaceMuxReqIntervall = 0; | 691 case DETECTION_INIT: externalInterfaceMuxReqIntervall = 0xffff; |
| 692 sensorIndex = 0; | 692 sensorIndex = 0; |
| 693 uartMuxChannel = 0; | 693 uartMuxChannel = 0; |
| 694 tmpSensorMap[0] = SENSOR_OPTIC; | 694 tmpSensorMap[0] = SENSOR_OPTIC; |
| 695 tmpSensorMap[1] = SENSOR_OPTIC; | 695 tmpSensorMap[1] = SENSOR_OPTIC; |
| 696 tmpSensorMap[2] = SENSOR_OPTIC; | 696 tmpSensorMap[2] = SENSOR_OPTIC; |
| 1175 | 1175 |
| 1176 TriggerTick = tick; | 1176 TriggerTick = tick; |
| 1177 timeToTrigger = COMMAND_TX_DELAY; | 1177 timeToTrigger = COMMAND_TX_DELAY; |
| 1178 retryRequest = 1; | 1178 retryRequest = 1; |
| 1179 } | 1179 } |
| 1180 | |
| 1181 else if(time_elapsed_ms(lastRequestTick,tick) > externalInterfaceMuxReqIntervall) /* switch sensor and / or trigger next request */ | 1180 else if(time_elapsed_ms(lastRequestTick,tick) > externalInterfaceMuxReqIntervall) /* switch sensor and / or trigger next request */ |
| 1182 { | 1181 { |
| 1183 lastRequestTick = tick; | 1182 if(timeToTrigger == 0) /* no pending action */ |
| 1184 TriggerTick = tick; | 1183 { |
| 1185 retryRequest = 0; | 1184 TriggerTick = tick; |
| 1186 timeToTrigger = 1; | 1185 retryRequest = 0; |
| 1187 | 1186 timeToTrigger = 1; |
| 1188 if((externalInterface_SensorState[activeSensorId] == UART_O2_REQ_O2) /* timeout */ | 1187 |
| 1189 || (externalInterface_SensorState[activeSensorId] == UART_O2_REQ_RAW) | 1188 if((externalInterface_SensorState[activeSensorId] == UART_O2_REQ_O2) /* timeout */ |
| 1190 || (externalInterface_SensorState[activeSensorId] == UART_CO2_OPERATING) | 1189 || (externalInterface_SensorState[activeSensorId] == UART_O2_REQ_RAW) |
| 1191 || (externalInterface_SensorState[activeSensorId] == UART_GNSS_GET_PVT) | 1190 || (externalInterface_SensorState[activeSensorId] == UART_CO2_OPERATING) |
| 1192 || (externalInterface_SensorState[activeSensorId] == UART_GNSS_GET_SAT)) | 1191 || (externalInterface_SensorState[activeSensorId] == UART_GNSS_GET_PVT) |
| 1193 { | 1192 || (externalInterface_SensorState[activeSensorId] == UART_GNSS_GET_SAT)) |
| 1194 forceMuxChannel = 1; | |
| 1195 externalInterface_SensorState[activeSensorId] = UART_O2_IDLE; | |
| 1196 switch(pmap[activeSensorId]) | |
| 1197 { | 1193 { |
| 1198 case SENSOR_DIGO2: setExternalInterfaceChannel(activeSensorId,0.0); | 1194 forceMuxChannel = 1; |
| 1199 break; | 1195 externalInterface_SensorState[activeSensorId] = UART_O2_IDLE; |
| 1200 case SENSOR_CO2: externalInterface_SetCO2Value(0.0); | 1196 switch(pmap[activeSensorId]) |
| 1201 externalInterface_SetCO2State(0); | 1197 { |
| 1202 break; | 1198 case SENSOR_DIGO2: setExternalInterfaceChannel(activeSensorId,0.0); |
| 1203 default: | 1199 break; |
| 1204 break; | 1200 case SENSOR_CO2: externalInterface_SetCO2Value(0.0); |
| 1201 externalInterface_SetCO2State(0); | |
| 1202 break; | |
| 1203 default: | |
| 1204 break; | |
| 1205 } | |
| 1205 } | 1206 } |
| 1206 } | 1207 if((externalInterface_SensorState[activeSensorId] == UART_CO2_SETUP) /* timeout while setting up sensors */ |
| 1207 if((externalInterface_SensorState[activeSensorId] == UART_CO2_SETUP) /* timeout while setting up sensors */ | 1208 || (externalInterface_SensorState[activeSensorId] == UART_O2_CHECK)) |
| 1208 || (externalInterface_SensorState[activeSensorId] == UART_O2_CHECK)) | |
| 1209 { | |
| 1210 forceMuxChannel = 1; | |
| 1211 } | |
| 1212 | |
| 1213 | |
| 1214 if(pmap[EXT_INTERFACE_SENSOR_CNT-1] == SENSOR_MUX) /* select next sensor if mux is connected */ | |
| 1215 { | |
| 1216 if(activeUartChannel < MAX_MUX_CHANNEL) | |
| 1217 { | 1209 { |
| 1218 index = ExternalInterface_SelectUsedMuxChannel(activeUartChannel); | 1210 forceMuxChannel = 1; |
| 1219 if((index != activeUartChannel) || (forceMuxChannel)) | 1211 } |
| 1212 | |
| 1213 | |
| 1214 if(pmap[EXT_INTERFACE_SENSOR_CNT-1] == SENSOR_MUX) /* select next sensor if mux is connected */ | |
| 1215 { | |
| 1216 if(activeUartChannel < MAX_MUX_CHANNEL) | |
| 1220 { | 1217 { |
| 1221 forceMuxChannel = 0; | 1218 index = ExternalInterface_SelectUsedMuxChannel(activeUartChannel); |
| 1222 timeToTrigger = 100; | 1219 if((index != activeUartChannel) || (forceMuxChannel)) |
| 1223 activeUartChannel = index; | |
| 1224 switch(pmap[index + EXT_INTERFACE_MUX_OFFSET]) | |
| 1225 { | 1220 { |
| 1226 case SENSOR_DIGO2: uartO2_SetChannel(activeUartChannel); | 1221 forceMuxChannel = 0; |
| 1227 /* no break */ | 1222 timeToTrigger = 100; |
| 1228 case SENSOR_CO2: | 1223 activeUartChannel = index; |
| 1229 case SENSOR_GNSS: externalInterface_CheckBaudrate(SENSOR_MUX); | 1224 switch(pmap[index + EXT_INTERFACE_MUX_OFFSET]) |
| 1230 UART_MUX_SelectAddress(activeUartChannel); | 1225 { |
| 1231 externalInterface_CheckBaudrate(pmap[activeUartChannel + EXT_INTERFACE_MUX_OFFSET]); | 1226 case SENSOR_DIGO2: uartO2_SetChannel(activeUartChannel); |
| 1232 break; | 1227 /* no break */ |
| 1233 default: | 1228 case SENSOR_CO2: |
| 1234 break; | 1229 case SENSOR_GNSS: externalInterface_CheckBaudrate(SENSOR_MUX); |
| 1230 UART_MUX_SelectAddress(activeUartChannel); | |
| 1231 externalInterface_CheckBaudrate(pmap[activeUartChannel + EXT_INTERFACE_MUX_OFFSET]); | |
| 1232 break; | |
| 1233 default: | |
| 1234 break; | |
| 1235 } | |
| 1235 } | 1236 } |
| 1236 } | 1237 } |
| 1237 } | 1238 } |
| 1238 } | 1239 } |
| 1239 else | |
| 1240 { | |
| 1241 timeToTrigger = 1; | |
| 1242 } | |
| 1243 } | 1240 } |
| 1244 if((timeToTrigger != 0) && (time_elapsed_ms(TriggerTick,tick) > timeToTrigger)) | 1241 if((timeToTrigger != 0) && (time_elapsed_ms(TriggerTick,tick) > timeToTrigger)) |
| 1245 { | 1242 { |
| 1243 lastRequestTick = tick; | |
| 1246 timeToTrigger = 0; | 1244 timeToTrigger = 0; |
| 1247 switch (pmap[activeSensorId]) | 1245 switch (pmap[activeSensorId]) |
| 1248 { | 1246 { |
| 1249 case SENSOR_MUX: | 1247 case SENSOR_MUX: |
| 1250 case SENSOR_DIGO2: uartO2_Control(); | 1248 case SENSOR_DIGO2: uartO2_Control(); |
