diff Small_CPU/Src/uart.c @ 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 045ff7800501
children 621265ec3d23
line wrap: on
line diff
--- 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;