diff --git a/project/Core/Src/modbus_tcp.c b/project/Core/Src/modbus_tcp.c index 7e2410b..a5dc0d1 100644 --- a/project/Core/Src/modbus_tcp.c +++ b/project/Core/Src/modbus_tcp.c @@ -11,7 +11,7 @@ #include "log.h" // Defines -#define MAX_REG 250 +#define MAX_REG 250 #define EXTENSION_LENGHT 4 #define TEXT_LENGHT 200 #define MULTIPLE_REG 0x10 @@ -99,43 +99,39 @@ static err_t modbus_incoming_data(void* arg, struct tcp_pcb* pcb, struct pbuf* p text_foreground_color |= ((uint32_t)text_color_red) << 16; text_foreground_color |= ((uint32_t)text_color_green) << 8; text_foreground_color |= text_color_blue; - // proccesing the image index - size_t number_of_files = llfs_file_count(); // How many files that there are - - - llfs_file_t file_list[number_of_files]; // Reserving memory for the list - - number_of_files = llfs_file_list(file_list, number_of_files, NULL); // Freed memory filled with the list - - if (number_of_files < nr_img) { - lcd_clear_text(); - lcd_clear_images(); - lcd_stop_all_gifs(); - - lcd_display_text(text, 10, 10, text_foreground_color, result_background, LCD_FONT24); //When no image - - lcd_display_text("FILE NOT IN FILESYSTEM", 10, 75, LCD_RED, LCD_BLACK, LCD_FONT24); - } else { - const char* ext = strrchr(file_list[nr_img - 1].name, '.'); - if (ext == NULL) { - // No valid extension found - } - if (strcmp(ext, ".gif") == 0) { + // proccesing the image index + size_t number_of_files = llfs_file_count(); // How many files that there are + if(number_of_files > 0){ + llfs_file_t file_list[number_of_files]; // Reserving memory for the list + number_of_files = llfs_file_list(file_list, number_of_files, NULL); // Freed memory filled with the list + if (number_of_files < nr_img) { lcd_clear_text(); lcd_clear_images(); lcd_stop_all_gifs(); - - lcd_display_text(text, 10, 10, text_foreground_color, result_background, LCD_FONT24); - lcd_gif_t* gif = lcd_draw_gif_from_fs(file_list[nr_img - 1].name, 0, 75); //GIF on screen - } else if (strcmp(ext,".bmp") == 0) { - lcd_clear_text(); - lcd_clear_images(); - lcd_stop_all_gifs(); - lcd_display_text(text, 10, 10, text_foreground_color, result_background, LCD_FONT24); - lcd_draw_img_from_fs(file_list[nr_img - 1].name, 0, 75); //BMP on screen - + lcd_display_text(text, 10, 10, text_foreground_color, result_background, LCD_FONT24); //When no image + lcd_display_text("FILE NOT IN FILESYSTEM", 10, 75, LCD_RED, LCD_BLACK, LCD_FONT24); + } else { + const char* ext = strrchr(file_list[nr_img - 1].name, '.'); + if (ext == NULL) { + // No valid extension found + } + if (strcmp(ext, ".gif") == 0) { + lcd_clear_text(); + lcd_clear_images(); + lcd_stop_all_gifs(); + lcd_display_text(text, 10, 10, text_foreground_color, result_background, LCD_FONT24); + lcd_gif_t* gif = lcd_draw_gif_from_fs(file_list[nr_img - 1].name, 0, 75); //GIF on screen + } else if (strcmp(ext,".bmp") == 0) { + lcd_clear_text(); + lcd_clear_images(); + lcd_stop_all_gifs(); + lcd_display_text(text, 10, 10, text_foreground_color, result_background, LCD_FONT24); + lcd_draw_img_from_fs(file_list[nr_img - 1].name, 0, 75); //BMP on screen + } } } + + } else { // LOG_INFO(TAG, "not in writing multiple register mode!!!\n"); }