diff --git a/project/Core/Inc/modbus_tcp.h b/project/Core/Inc/modbus_tcp.h index 88d9ea7..10c993f 100644 --- a/project/Core/Inc/modbus_tcp.h +++ b/project/Core/Inc/modbus_tcp.h @@ -2,8 +2,8 @@ * @file modbus_tcp.h * * @brief TCP Modbus handler - * Created on: Nov 6, 2023 - * Author: Obe + * @date Nov 6, 2023 + * @author Obe */ #ifndef INC_MODBUS_H_ @@ -17,7 +17,6 @@ #include #include "lcd_api.h" #include "llfs.h" -#include "log.h" /** diff --git a/project/Core/Src/modbus_tcp.c b/project/Core/Src/modbus_tcp.c index 4af89fc..d974226 100644 --- a/project/Core/Src/modbus_tcp.c +++ b/project/Core/Src/modbus_tcp.c @@ -2,8 +2,8 @@ * @file modbus_tcp.c * * @brief TCP Modbus handler - * Created on: Nov 6, 2023 - * Author: Obe + * @date Nov 6, 2023 + * @author Obe */ // Includes @@ -15,7 +15,15 @@ #define EXTENSION_LENGHT 4 #define TEXT_LENGHT 200 #define MULTIPLE_REG 0x10 - +#define REG_LENGTH 428 +#define START_DATA 28 +#define REG_01 14 +#define REG_02 16 +#define REG_03 18 +#define REG_04 20 +#define REG_05 22 +#define REG_06 24 +#define REG_07 26 // Global variables char registers[MAX_REG]; @@ -61,18 +69,18 @@ static err_t modbus_incomming_data(void *arg, struct tcp_pcb *pcb, struct pbuf * if(registers[7] == MULTIPLE_REG){ // Check if it's a Modbus Write Multiple Registers request (0x10) //LOG_INFO(TAG, "in writing multiple register mode\n"); - background_red = (uint8_t)(registers[14]); // 01 - background_green = (uint8_t)(registers[16]); // 02 - background_blue = (uint8_t)(registers[18]); // 03 - text_color_red = (uint8_t)(registers[20]); // 04 - text_color_green = (uint8_t)(registers[22]); // 05 - text_color_blue = (uint8_t)(registers[24]); // 06 - nr_img = (uint8_t)(registers[26]); // 07 + background_red = (uint8_t)(registers[REG_01]); // 01 + background_green = (uint8_t)(registers[REG_02]); // 02 + background_blue = (uint8_t)(registers[REG_03]); // 03 + text_color_red = (uint8_t)(registers[REG_04]); // 04 + text_color_green = (uint8_t)(registers[REG_05]); // 05 + text_color_blue = (uint8_t)(registers[REG_06]); // 06 + nr_img = (uint8_t)(registers[REG_07]); // 07 //LOG_INFO(TAG, "%d %d %d %d %d %d %d ",background_red,background_green,background_blue,text_color_red,text_color_green,text_color_blue,nr_img); counter = 0; - for(int i = 28; i < 428; i++){ + for(int i = START_DATA; i < REG_LENGTH; i++){ if(i % 2 == 0){ text[counter] = registers[i]; counter++;