Jelajahi Sumber

MQTT buffer size changed

Bartosz Jakubski 1 bulan lalu
induk
melakukan
d869703402

+ 3 - 3
OZE_Main/Core/Src/mqtt_client.c

@@ -75,11 +75,11 @@ extern osTimerId_t relay3TimerHandle;
 extern osTimerId_t relay4TimerHandle;
 
 const osThreadAttr_t mqttClientSubTaskAttr =
-{ .name = "mqttClientSubTask", .stack_size = configMINIMAL_STACK_SIZE * 4,
+{ .name = "mqttClientSubTask", .stack_size = configMINIMAL_STACK_SIZE * 6,
 		.priority = (osPriority_t) osPriorityNormal, };
 
 const osThreadAttr_t mqttClientPubTaskAttr =
-{ .name = "mqttClientPsubTask", .stack_size = configMINIMAL_STACK_SIZE * 4,
+{ .name = "mqttClientPsubTask", .stack_size = configMINIMAL_STACK_SIZE * 6,
 		.priority = (osPriority_t) osPriorityNormal, };
 
 osThreadId mqttClientSubTaskHandle;  //mqtt client task handle
@@ -131,7 +131,7 @@ void MqttClientSubTask (void* argument) {
 }
 
 void MqttClientPubTask (void* argument) {
-    char messageBuffer[512]  = { 0x00 };
+    char messageBuffer[MQTT_BUFSIZE]  = { 0x00 };
     char topicTextBuffer[32] = { 0x00 };
     uint32_t bytesInBuffer   = 0;
     uint8_t boardNumber      = 0;

+ 7 - 7
OZE_Main/Core/Src/uart_tasks.c

@@ -58,17 +58,17 @@ UartTaskData uart2TaskData = { 0 }; // Board 4
 UartTaskData uart8TaskData = { 0 }; // Debug
 
 #ifdef USE_UART8_INSTEAD_UART1
-UartTaskData* uartTasks[] = { &uart8TaskData, &uart3TaskData, &uart6TaskData, &uart2TaskData, NULL, };
+UartTaskData* uartTasks[] __attribute__ ((aligned (32))) = { &uart8TaskData, &uart3TaskData, &uart6TaskData, &uart2TaskData, NULL, };
 #else
-UartTaskData* uartTasks[] = { &uart1TaskData, &uart3TaskData, &uart6TaskData, &uart2TaskData, NULL, };
+UartTaskData* uartTasks[] __attribute__ ((aligned (32))) = { &uart1TaskData, &uart3TaskData, &uart6TaskData, &uart2TaskData, NULL, };
 #endif
 
-uint8_t outputDataBuffer[OUTPUT_DATA_BUFF_SIZE];
-uint16_t outputDataBufferPos = 0;
+uint8_t outputDataBuffer[OUTPUT_DATA_BUFF_SIZE] __attribute__ ((aligned (32))) = { 0 };
+uint16_t outputDataBufferPos __attribute__ ((aligned (32))) = 0;
 
-RESMeasurements resMeasurements[SLAVES_COUNT] = { 0 };
-SesnorsInfo sensorsInfo[SLAVES_COUNT]         = { 0 };
-uint32_t slaveLastSeen[SLAVES_COUNT] = { 0 };
+RESMeasurements resMeasurements[SLAVES_COUNT] __attribute__ ((aligned (32))) = { 0 };
+SesnorsInfo sensorsInfo[SLAVES_COUNT] __attribute__ ((aligned (32))) = { 0 };
+uint32_t slaveLastSeen[SLAVES_COUNT] __attribute__ ((aligned (32))) = { 0 };
 osMutexId_t resMeasurementsMutex;
 osMutexId_t sensorsInfoMutex;
 

+ 2 - 2
OZE_Sensor/Core/Inc/node-red-config.h

@@ -24,8 +24,8 @@
 #define ANGLE_RANGE_FOR_MOTOR_SPEED_LIMIT 5 // percentage value for motor slow down/speed up boundary
 #define AXE_X_MIDDLE_VALUE 50 // percentage value of position for C limiter
 #define AXE_Y_MIDDLE_VALUE 50 // percentage value of position for C limiter
-#define TIME_MS_FOR_MOTOR_SPEED_LIMIT 50000
-#define NO_MOVE_TIMEOUT_MS 50000 // timeout for no movement detection
+#define TIME_MS_FOR_MOTOR_SPEED_LIMIT 5000
+#define NO_MOVE_TIMEOUT_MS 5000 // timeout for no movement detection
 
 #define WATCHDOG_ENABLED
 //#define USER_MOCKS

+ 20 - 16
OZE_Sensor/Core/Src/meas_tasks.c

@@ -294,52 +294,56 @@ void LimiterSwitchTask (void* arg) {
             sensorsInfo.limitXSwitchDown = HAL_GPIO_ReadPin (GPIOD, GPIO_PIN_12);
             pinStates                    = (limitXSwitchDownPrevState << 1) | sensorsInfo.limitXSwitchDown;
             if ((pinStates & 0x3) == 0x1) {
-                limiterXTriggered            = 1;
-                sensorsInfo.currentXPosition = 0;
-                sensorsInfo.positionXWeak    = 0;
+                limiterXTriggered           = 1;
+                sensorsInfo.positionXOffset = 0 - sensorsInfo.currentXPosition;
+                sensorsInfo.positionXWeak   = 0;
             }
             limitXSwitchDownPrevState = sensorsInfo.limitXSwitchDown;
 
             sensorsInfo.limitXSwitchUp = HAL_GPIO_ReadPin (GPIOD, GPIO_PIN_13);
             pinStates                  = (limitXSwitchUpPrevState << 1) | sensorsInfo.limitXSwitchUp;
             if ((pinStates & 0x3) == 0x1) {
-                limiterXTriggered            = 1;
-                sensorsInfo.currentXPosition = 100;
-                sensorsInfo.positionXWeak    = 0;
+                limiterXTriggered           = 1;
+                sensorsInfo.positionXOffset = 100 - sensorsInfo.currentXPosition;
+                sensorsInfo.positionXWeak   = 0;
             }
             limitXSwitchUpPrevState = sensorsInfo.limitXSwitchUp;
 
             sensorsInfo.limitXSwitchCenter = HAL_GPIO_ReadPin (GPIOD, GPIO_PIN_10);
             pinStates                      = (limitXSwitchCenterPrevState << 1) | sensorsInfo.limitXSwitchCenter;
             if ((pinStates & 0x3) == 0x1) {
-                sensorsInfo.currentXPosition = AXE_X_MIDDLE_VALUE;
-                sensorsInfo.positionXWeak    = 0;
+                sensorsInfo.positionXOffset = AXE_X_MIDDLE_VALUE - sensorsInfo.currentXPosition;
+                ;
+                sensorsInfo.positionXWeak = 0;
             }
             limitXSwitchCenterPrevState = sensorsInfo.limitXSwitchCenter;
 
             sensorsInfo.limitYSwitchDown = HAL_GPIO_ReadPin (GPIOD, GPIO_PIN_11);
             pinStates                    = (limitYSwitchDownPrevState << 1) | sensorsInfo.limitYSwitchDown;
             if ((pinStates & 0x3) == 0x1) {
-                limiterYTriggered            = 1;
-                sensorsInfo.currentYPosition = 0;
-                sensorsInfo.positionYWeak    = 0;
+                limiterYTriggered           = 1;
+                sensorsInfo.positionYOffset = 0 - sensorsInfo.currentYPosition;
+                ;
+                sensorsInfo.positionYWeak = 0;
             }
             limitYSwitchDownPrevState = sensorsInfo.limitYSwitchDown;
 
             sensorsInfo.limitYSwitchUp = HAL_GPIO_ReadPin (GPIOD, GPIO_PIN_9);
             pinStates                  = (limitYSwitchUpPrevState << 1) | sensorsInfo.limitYSwitchUp;
             if ((pinStates & 0x3) == 0x1) {
-                limiterYTriggered            = 1;
-                sensorsInfo.currentYPosition = 100;
-                sensorsInfo.positionYWeak    = 0;
+                limiterYTriggered           = 1;
+                sensorsInfo.positionYOffset = 100 - sensorsInfo.currentYPosition;
+                ;
+                sensorsInfo.positionYWeak = 0;
             }
             limitYSwitchUpPrevState = sensorsInfo.limitYSwitchUp;
 
             sensorsInfo.limitYSwitchCenter = HAL_GPIO_ReadPin (GPIOD, GPIO_PIN_8);
             pinStates                      = (limitYSwitchCenterPrevState << 1) | sensorsInfo.limitYSwitchCenter;
             if ((pinStates & 0x3) == 0x1) {
-                sensorsInfo.currentYPosition = AXE_Y_MIDDLE_VALUE;
-                sensorsInfo.positionYWeak    = 0;
+                sensorsInfo.currentYPosition = AXE_Y_MIDDLE_VALUE - sensorsInfo.currentYPosition;
+                ;
+                sensorsInfo.positionYWeak = 0;
             }
             limitYSwitchCenterPrevState = sensorsInfo.limitYSwitchCenter;
             if (((sensorsInfo.limitXSwitchDown == 1) || (sensorsInfo.limitXSwitchUp == 1)) && (limiterXTriggered == 1)) {