edit and testing code
edited some functions and testing code in main
This commit is contained in:
@@ -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_ */
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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<len;x++){
|
||||
if (ptr[x]=='\n'){
|
||||
HAL_UART_Transmit(&huart1, (uint8_t*)"\r", 1, HAL_MAX_DELAY);
|
||||
}
|
||||
HAL_UART_Transmit(&huart1, (uint8_t*)&ptr[x], 1, HAL_MAX_DELAY);
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
/* USER CODE END 0 */
|
||||
|
||||
/**
|
||||
@@ -80,6 +91,12 @@ static void MX_QUADSPI_Init(void);
|
||||
int main(void)
|
||||
{
|
||||
/* USER CODE BEGIN 1 */
|
||||
owner_details_t owner;
|
||||
printf("%s",get_owner_details_reply());
|
||||
set_owner_details(owner, "joran", "vn");
|
||||
printf("%s",get_owner_details_reply());
|
||||
set_owner_details(owner, "joran", "Van Nieuwenhoven");
|
||||
printf("%s",get_owner_details_reply());
|
||||
|
||||
/* USER CODE END 1 */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user