From 5942274e6a4cc4637c4ea0bdbe79c59b995f4cb3 Mon Sep 17 00:00:00 2001 From: joran2738 <101818067+joran2738@users.noreply.github.com> Date: Mon, 6 Nov 2023 20:15:00 +0100 Subject: [PATCH] edit and testing code edited some functions and testing code in main --- project/Core/Inc/UDP_broadcast.h | 1 + project/Core/Src/UDP_broadcast.c | 36 ++++++++++++++++++++++++++++++++ project/Core/Src/main.c | 17 +++++++++++++++ 3 files changed, 54 insertions(+) diff --git a/project/Core/Inc/UDP_broadcast.h b/project/Core/Inc/UDP_broadcast.h index f4e062d..74deda5 100644 --- a/project/Core/Inc/UDP_broadcast.h +++ b/project/Core/Inc/UDP_broadcast.h @@ -21,6 +21,7 @@ uint8_t set_owner_details(owner_details_t*, char* , char*); char* get_owner_details_name(owner_details_t); char* get_owner_details_surname(owner_details_t); +char* get_owner_details_reply(owner_details_t); #endif /* INC_UDP_BROADCAST_H_ */ diff --git a/project/Core/Src/UDP_broadcast.c b/project/Core/Src/UDP_broadcast.c index 64a9b46..3d45bc8 100644 --- a/project/Core/Src/UDP_broadcast.c +++ b/project/Core/Src/UDP_broadcast.c @@ -150,17 +150,53 @@ uint8_t set_owner_details(owner_details_t* owner, char* name, char* surname){ } } +/** + * @fn char get_owner_details_name*(owner_details_t) + * @brief + * + * @param owner + * @return + */ + char* get_owner_details_name(owner_details_t owner){ char *err_reply = "no name yet"; if(owner == NULL || owner->name == NULL){ owner->name = (char*)malloc(strlen(err_reply)); + strcpy(owner->name,err_reply); } return owner->name; } + +/** + * @fn char get_owner_details_surname*(owner_details_t) + * @brief + * + * @param owner + * @return + */ + char* get_owner_details_surname(owner_details_t owner){ char *err_reply = "no surname yet"; if(owner == NULL || owner->surname == NULL){ owner->surname = (char*)malloc(strlen(err_reply)); + strcpy(owner->name,err_reply); + } + return owner->name; +} + +/** + * @fn char get_owner_details_reply*(owner_details_t) + * @brief + * + * @param + * @return + */ + +char* get_owner_details_reply(owner_details_t){ + char *err_reply = "no reply yet"; + if(owner == NULL || owner->reply == NULL){ + owner->reply = (char*)malloc(strlen(err_reply)); + strcpy(owner->name,err_reply); } return owner->name; } diff --git a/project/Core/Src/main.c b/project/Core/Src/main.c index 691c4fe..ac808b3 100644 --- a/project/Core/Src/main.c +++ b/project/Core/Src/main.c @@ -23,6 +23,7 @@ /* Private includes ----------------------------------------------------------*/ /* USER CODE BEGIN Includes */ #include "log.h" +#include "UDP_broadcast.h" /* USER CODE END Includes */ /* Private typedef -----------------------------------------------------------*/ @@ -70,7 +71,17 @@ static void MX_QUADSPI_Init(void); /* Private user code ---------------------------------------------------------*/ /* USER CODE BEGIN 0 */ +int _write(int file, char *ptr, int len) { + for (int x = 0;x