finish modbus_tcp (without response)

This commit is contained in:
Obe Van Lierde
2023-11-13 16:05:04 +01:00
parent d730932235
commit 858e0aafb0
5 changed files with 175 additions and 88 deletions

View File

@@ -57,7 +57,7 @@ size_t llfs_file_list(llfs_file_t* file_list, size_t max_files, char* filter) {
}
// Iterate over all files in the filesystem
while (file != NULL && file_count < max_files) {
while (file != NULL && count < max_files) {
// Filter out files with a filename that does not match the filter
if (filter != NULL) {
if (!file_ext_cmp(file->name, filter)) {

View File

@@ -113,11 +113,9 @@ int main(void)
MX_LWIP_Init();
MX_QUADSPI_Init();
/* USER CODE BEGIN 2 */
modbus_init();
lcd_init(true);
llfs_init();
modbus_init();
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */

View File

@@ -1,7 +1,5 @@
#include "modbus-tcp.h"
#include <tcp.h>
char tcp_buffer[1024];
#define MAX_REG 250
@@ -19,10 +17,16 @@ static err_t modbus_incomming_data(void *arg, struct tcp_pcb *pcb, struct pbuf *
uint8_t txt_green = 0;
uint8_t txt_blue = 0;
uint8_t nr_img = 0;
uint32_t result_bg = 0;
uint32_t result_txt = 0;
uint32_t result = 0;
char text[200];
for(i = 0; i < 100;i++){
text[i] = 95; // _
}
text[199] = '\0';
if (p != NULL){
printf("data not null\n");
@@ -64,6 +68,34 @@ static err_t modbus_incomming_data(void *arg, struct tcp_pcb *pcb, struct pbuf *
}
printf("\n");
//processing the text data to screen
char *textstring = text;
result_bg = 0xff000000;
result_bg |= ((uint32_t)bg_red) << 16;
result_bg |= ((uint32_t)bg_green) << 8;
result_bg |= bg_blue;
result_txt = 0xff000000;
result_txt |= ((uint32_t)txt_red) << 16;
result_txt |= ((uint32_t)txt_green) << 8;
result_txt |= txt_blue;
lcd_display_text(textstring, 10, 50, result_txt, result_bg, LCD_FONT24);
//proccesing the image index
size_t number_of_files = llfs_file_count();//hoeveel files er zijn
llfs_file_t file_list[number_of_files];//geheugen vrijmaken voor files
number_of_files = llfs_file_list(file_list, number_of_files, NULL);//vrijgemaakt geheugen invullen met de lijst
lcd_display_text(file_list[nr_img - 1].name, 10, 75, LCD_COLOR_MAGENTA, LCD_COLOR_YELLOW, LCD_FONT24);//putting the file name on screen
//functie_voor_naam
} else if (err == ERR_OK){
tcp_close(pcb);//when everithing was ok close the tcpconnection
@@ -95,3 +127,6 @@ void modbus_init( void )
modbus_pcb = tcp_listen( modbus_pcb );//listen
tcp_accept(modbus_pcb, modbus_accept);//set callback function
}