comparison Small_CPU/Src/externalInterface.c @ 742:e23fe82cbf8c

Update Sentinel protocol: The Sentinel protocol is now supported by autodetection. Added Autodetection indicator: In the previous version no indicator showed that an auto detection is running. A new pseudo sensor type has been introduced which now causes the auto detection string to be displayed while the detection is running in the background.
author Ideenmodellierer
date Sun, 19 Feb 2023 21:43:24 +0100
parents 30717de00f3a
children 7e84ae1513b6
comparison
equal deleted inserted replaced
741:6a35e2e97bfb 742:e23fe82cbf8c
311 switch(protocol) 311 switch(protocol)
312 { 312 {
313 case 0: 313 case 0:
314 case (EXT_INTERFACE_UART_CO2 >> 8): 314 case (EXT_INTERFACE_UART_CO2 >> 8):
315 case (EXT_INTERFACE_UART_O2 >> 8): 315 case (EXT_INTERFACE_UART_O2 >> 8):
316 case (EXT_INTERFACE_UART_SENTINEL >> 8):
316 if((externalAutoDetect <= DETECTION_START) || ((protocol == EXT_INTERFACE_UART_CO2 >> 8) && (externalAutoDetect == DETECTION_CO2)) 317 if((externalAutoDetect <= DETECTION_START) || ((protocol == EXT_INTERFACE_UART_CO2 >> 8) && (externalAutoDetect == DETECTION_CO2))
317 || ((protocol == EXT_INTERFACE_UART_O2 >> 8) && (externalAutoDetect == DETECTION_DIGO2))) 318 || ((protocol == EXT_INTERFACE_UART_O2 >> 8) && (externalAutoDetect == DETECTION_DIGO2))
319 || ((protocol == EXT_INTERFACE_UART_SENTINEL >> 8) && (externalAutoDetect == DETECTION_SENTINEL)))
318 { 320 {
319 sensorDataId = 0; 321 sensorDataId = 0;
320 externalUART_Protocol = protocol; 322 externalUART_Protocol = protocol;
321 MX_USART1_UART_DeInit(); 323 MX_USART1_UART_DeInit();
322 if( protocol != 0) 324 if( protocol != 0)
484 } 486 }
485 487
486 UART_setTargetChannel(index); 488 UART_setTargetChannel(index);
487 /* tmpSensorMap[sensorIndex++] = SENSOR_DIGO2; */ 489 /* tmpSensorMap[sensorIndex++] = SENSOR_DIGO2; */
488 } 490 }
489 externalAutoDetect = DETECTION_CO2; 491 externalAutoDetect++;
492 #ifdef ENABLE_CO2_SUPPORT
490 externalInterface_SwitchUART(EXT_INTERFACE_UART_CO2 >> 8); 493 externalInterface_SwitchUART(EXT_INTERFACE_UART_CO2 >> 8);
491 break; 494 break;
492 case DETECTION_CO2: if(UART_isCO2Connected()) 495 case DETECTION_CO2: if(UART_isCO2Connected())
493 { 496 {
494 for(index = 0; index < 3; index++) /* lookup a channel which may be used by CO2*/ 497 for(index = 0; index < 3; index++) /* lookup a channel which may be used by CO2*/
506 { 509 {
507 tmpSensorMap[index] = SENSOR_CO2; 510 tmpSensorMap[index] = SENSOR_CO2;
508 } 511 }
509 512
510 } 513 }
511 externalAutoDetect = DETECTION_DONE; 514 externalAutoDetect++;
515 #endif
516 #ifdef ENABLE_SENTINEL_MODE
517 externalInterface_SwitchUART(EXT_INTERFACE_UART_SENTINEL >> 8);
518 UART_StartDMA_Receiption();
519 break;
520
521 case DETECTION_SENTINEL:
522 case DETECTION_SENTINEL2:
523 if(UART_isSentinelConnected())
524 {
525 for(index = 0; index < 3; index++) /* Sentinel is occupiing all sensor slots */
526 {
527 tmpSensorMap[index] = SENSOR_SENTINEL;
528 }
529 sensorIndex = 3;
530 }
531 externalAutoDetect++;
532 #endif
512 break; 533 break;
513 case DETECTION_DONE: for(index = 0; index < EXT_INTERFACE_SENSOR_CNT; index++) 534 case DETECTION_DONE: for(index = 0; index < EXT_INTERFACE_SENSOR_CNT; index++)
514 { 535 {
515 if(tmpSensorMap[index] != SENSOR_NONE) 536 if(tmpSensorMap[index] != SENSOR_NONE)
516 { 537 {
548 uint8_t index; 569 uint8_t index;
549 570
550 switch(Cmd & 0x00FF) /* lower byte is reserved for commands */ 571 switch(Cmd & 0x00FF) /* lower byte is reserved for commands */
551 { 572 {
552 case EXT_INTERFACE_AUTODETECT: externalAutoDetect = DETECTION_INIT; 573 case EXT_INTERFACE_AUTODETECT: externalAutoDetect = DETECTION_INIT;
574 for(index = 0; index < 3; index++)
575 {
576 SensorMap[index] = SENSOR_SEARCH;
577 }
553 break; 578 break;
554 case EXT_INTERFACE_CO2_CALIB: cmdLength = snprintf(cmdString, 10, "G\r\n"); 579 case EXT_INTERFACE_CO2_CALIB: cmdLength = snprintf(cmdString, 10, "G\r\n");
555 break; 580 break;
556 case EXT_INTERFACE_COPY_SENSORMAP: if(externalAutoDetect == DETECTION_OFF) 581 case EXT_INTERFACE_COPY_SENSORMAP: if(externalAutoDetect == DETECTION_OFF)
557 { 582 {