diff --git a/project/Core/Src/modbus_tcp.c b/project/Core/Src/modbus_tcp.c index 019fbc8..b19938d 100644 --- a/project/Core/Src/modbus_tcp.c +++ b/project/Core/Src/modbus_tcp.c @@ -100,37 +100,38 @@ static err_t modbus_incoming_data(void* arg, struct tcp_pcb* pcb, struct pbuf* p // Processing 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 + 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 - 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(); - 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(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("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 - } + 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 {