Mercurial > public > ostc4
changeset 721:fceae45b3a69
DigO2 added raw data request:
Beside ppO2 the Digo2 also offers raw data like humidity, pressure or signal intensity. These information may be of interest for diagnostic functions and have been added to the protocol support function.
author | Ideenmodellierer |
---|---|
date | Thu, 05 Jan 2023 18:22:21 +0100 |
parents | 4f70155362d2 |
children | 47a9ba771119 |
files | Small_CPU/Inc/uart.h Small_CPU/Src/uart.c |
diffstat | 2 files changed, 40 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/Small_CPU/Inc/uart.h Tue Jan 03 19:47:12 2023 +0100 +++ b/Small_CPU/Inc/uart.h Thu Jan 05 18:22:21 2023 +0100 @@ -54,6 +54,7 @@ UART_O2_REQ_ID, /* request ID of sensor */ UART_O2_IDLE, /* sensor detected and no communication pending */ UART_O2_REQ_O2, /* O2 value has been requested and is in receiption progress */ + UART_O2_REQ_RAW, /* Request O2 and extended raw data */ UART_O2_ERROR /* Error state which could not be resolved => only exit via de-/activation cycle */ } uartO2Status_t; @@ -69,7 +70,12 @@ O2RX_GETTYPE, /* extract the sensor type (should be 8) */ O2RX_GETCHANNEL, /* extract the number of sensor channels (should be 1) */ O2RX_GETVERSION, /* extract the sensor version */ - O2RX_GETSUBSENSORS /* extract the available measures (O2, temperature, humidity etc) */ + O2RX_GETSUBSENSORS, /* extract the available measures (O2, temperature, humidity etc) */ + O2RX_GETDPHI, /* extract phase shift */ + O2RX_INTENSITY, /* extract intensity of signal */ + O2RX_AMBIENTLIGHT, /* extract the intensity of the ambient light */ + O2RX_PRESSURE, /* extract pressor within the sensor housing */ + O2RX_HUMIDITY /* extract humidity within the sensor housing */ } uartO2RxState_t; void MX_USART1_UART_Init(void);
--- a/Small_CPU/Src/uart.c Tue Jan 03 19:47:12 2023 +0100 +++ b/Small_CPU/Src/uart.c Thu Jan 05 18:22:21 2023 +0100 @@ -26,8 +26,8 @@ /* Private variables ---------------------------------------------------------*/ -#define CHUNK_SIZE (20u) /* the DMA will handle chunk size transfers */ -#define CHUNKS_PER_BUFFER (3u) +#define CHUNK_SIZE (25u) /* the DMA will handle chunk size transfers */ +#define CHUNKS_PER_BUFFER (5u) UART_HandleTypeDef huart1; DMA_HandleTypeDef hdma_usart1_rx; @@ -389,7 +389,8 @@ break; case UART_O2_REQ_O2: *cmdLength = snprintf((char*)cmdString, 10, "#DOXY"); break; - + case UART_O2_REQ_RAW: *cmdLength = snprintf((char*)cmdString, 10, "#DRAW"); + break; default: *cmdLength = 0; break; } @@ -472,7 +473,7 @@ lastO2ReqTick = tick; if(Comstatus_O2 == UART_O2_IDLE) /* cyclic request of o2 value */ { - Comstatus_O2 = UART_O2_REQ_O2; + Comstatus_O2 = UART_O2_REQ_RAW; rxState = O2RX_CONFIRM; } DigitalO2_SetupCmd(Comstatus_O2,cmdString,&cmdLength); @@ -508,6 +509,7 @@ break; case UART_O2_REQ_INFO: rxState = O2RX_GETTYPE; break; + case UART_O2_REQ_RAW: case UART_O2_REQ_O2: rxState = O2RX_GETO2; break; default: Comstatus_O2 = UART_O2_IDLE; @@ -525,7 +527,13 @@ case O2RX_GETCHANNEL: case O2RX_GETSUBSENSORS: case O2RX_GETO2: - case O2RX_GETNR: if(rxBuffer[localRX] != 0x0D) + case O2RX_GETNR: + case O2RX_GETDPHI: + case O2RX_INTENSITY: + case O2RX_AMBIENTLIGHT: + case O2RX_PRESSURE: + case O2RX_HUMIDITY: + if(rxBuffer[localRX] != 0x0D) { if(rxBuffer[localRX] != ' ') { @@ -554,6 +562,21 @@ case O2RX_GETTEMP: StringToInt(tmpRxBuf,(uint32_t*)&sensorDataDiveO2.temperature); rxState = O2RX_GETSTATUS; break; + case O2RX_GETSTATUS: StringToInt(tmpRxBuf,&sensorDataDiveO2.status); /* raw data cycle */ + rxState = O2RX_GETDPHI; + break; + case O2RX_GETDPHI: /* ignored to save memory and most likly irrelevant for diver */ + rxState = O2RX_INTENSITY; + break; + case O2RX_INTENSITY: StringToInt(tmpRxBuf,(uint32_t*)&sensorDataDiveO2.intensity); /* raw data cycle */ + rxState = O2RX_AMBIENTLIGHT; + break; + case O2RX_AMBIENTLIGHT: StringToInt(tmpRxBuf,(uint32_t*)&sensorDataDiveO2.ambient); /* raw data cycle */ + rxState = O2RX_PRESSURE; + break; + case O2RX_PRESSURE: StringToInt(tmpRxBuf,(uint32_t*)&sensorDataDiveO2.pressure); /* raw data cycle */ + rxState = O2RX_HUMIDITY; + break; default: break; } @@ -575,6 +598,11 @@ Comstatus_O2 = UART_O2_IDLE; rxState = O2RX_IDLE; break; + case O2RX_HUMIDITY: StringToInt(tmpRxBuf,(uint32_t*)&sensorDataDiveO2.humidity); /* raw data cycle */ + externalInterface_SetSensorData(1,(uint8_t*)&sensorDataDiveO2); + Comstatus_O2 = UART_O2_IDLE; + rxState = O2RX_IDLE; + break; case O2RX_GETNR: StringToUInt64((char*)tmpRxBuf,&sensorDataDiveO2.sensorId); /* no break */ default: Comstatus_O2 = UART_O2_IDLE;