Skip to content
Snippets Groups Projects
Commit 3bd0605d authored by Johannes Eder's avatar Johannes Eder
Browse files
parents f68c262e 69e3426e
No related branches found
No related tags found
No related merge requests found
......@@ -7,6 +7,7 @@
*
* Contributors:
* Florian Hoelzl - initial API and implementation
* Constantin Dresel - added struct receive_message_t
*******************************************************************************/
#ifndef INC_AF3_H_
#define INC_AF3_H_
......@@ -22,6 +23,15 @@ typedef int GEN_TYPE_int;
typedef double GEN_TYPE_double;
#endif
// new structure for receiveing message
typedef struct receive_message_t{
char modulename[30];
char variablename[30];
char value[30];
char time[30];
}receive_message_t;
/*
* Function for initializing the module and callbacks
*/
......
......@@ -20,6 +20,7 @@
/** Initialize the connection to the camera server. */
void camera_client_initialize(const char *hostname, const char *port);
/** Returns whether the client is connected to the camera. */
bool camera_client_is_connected();
/** Returns the left distance. */
......
/*******************************************************************************
* Copyright (c) 2018 fortiss GmbH.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v20.html
*
* Contributors:
* Constantin Dresel - initial API and implementation
*******************************************************************************/
#ifndef INC_CONTROL_CENTER_DOWNSTREAM_H_
#define INC_CONTROL_CENTER_DOWNSTREAM_H_
#include "af3.h"
#include <stdint.h>
#define INTBASE 10 //!< Base for conversion from string to int (10 for dec)
typedef struct rx_msg_container_t {
receive_message_t message;
uint8_t age_in_cycles;
}rx_msg_container_t;
/** listener for received messages**/
void af3_cc_listen(void (*listener_handler) (receive_message_t));
/**
* \brief Initialize the downstream communication for control center.
* Currently just initializes a mutex and starts a thread listening for incoming
* messages.
*/
void af3_cc_donwstream_init(void);
/**
* \brief Exit downstream communication for control center.
* Stops the thread used for receiving incoming downstream messages and frees
* used memory.
*/
void af3_cc_downstream_exit(void);
/**
* \brief Handler function for received control center downstream messages.
* Stores a given received message in a list of received messages for further
* processing.
* @param received_message The received message to be handled.
*/
void cc_downstream_message_handler(receive_message_t received_message);
/**
* \brief Get a received integer variable with the given name.
* Checks whether an integer variable with the given name was received. If so
* the value of the received variable is converted to integer an stored at the
* given destination. If no appropriate message was received the destination
* variable won't get modified.
* @param userfriendly_name The userfriendly name of the variable to search for.
* @param p_variable_to_write A pointer to the destination where the integer
* value will be stored if a message was received containing the desired
* variable.
* @param p_variable_to_write A pointer to the destination where to record
* whether the variable is valid or not.
* @return Positive if the destination variable was updated, negative otherwise.
*/
int af3_cc_get_int(char* userfriendly_name, GEN_TYPE_int* p_variable_to_write,
GEN_TYPE_boolean* p_variable_to_write_noval);
/**
* \brief Get a received boolean variable with the given name.
* Checks whether an boolean variable with the given name was received. If so
* the value of the received variable is converted to boolean an stored at the
* given destination. If no appropriate message was received the destination
* variable won't get modified.
* @param userfriendly_name The userfriendly name of the variable to search for.
* @param p_variable_to_write A pointer to the destination where the boolean
* value will be stored if a message was received containing the desired
* variable.
* @param p_variable_to_write A pointer to the destination where to record
* whether the variable is valid or not.
* @return Positive if the destination variable was updated, negative otherwise.
*/
int af3_cc_get_bool(char* userfriendly_name,
GEN_TYPE_boolean* p_variable_to_write,
GEN_TYPE_boolean* p_variable_to_write_noval);
/**
* \brief Get a received double variable with the given name.
* Checks whether an double variable with the given name was received. If so
* the value of the received variable is converted to double an stored at the
* given destination. If no appropriate message was received the destination
* variable won't get modified.
* @param userfriendly_name The userfriendly name of the variable to search for.
* @param p_variable_to_write A pointer to the destination where the double
* value will be stored if a message was received containing the desired
* variable.
* @param p_variable_to_write A pointer to the destination where to record
* whether the variable is valid or not.
* @return Positive if the destination variable was updated, negative otherwise.
*/
int af3_cc_get_double(char* userfriendly_name,
GEN_TYPE_double* p_variable_to_write,
GEN_TYPE_boolean* p_variable_to_write_noval);
/**
* \brief Clear received messages that are older than a given number of cycles
* Clears received messages stored in the list buffer that were not popped from
* the list within the given interval of cycles. Use this to clear received
* messages from the list that are not related to an existing variable and
* therefore would pile up in the list and never be popped otherwise.
* One call of this function represents one cycle.
* @param age_to_keep The maximum age of messages to keep given in cycles.
*/
void af3_cc_downstream_clean_up_rx_list(uint8_t age_to_keep);
#endif /* INC_CONTROL_CENTER_DOWNSTREAM_H_ */
......@@ -7,6 +7,7 @@
*
* Contributors:
* Florian Hoelzl - initial API and implementation
* Constantin Dresel - added destroy_list and other functions
*******************************************************************************/
#ifndef INC_LISTUTIL_H_
#define INC_LISTUTIL_H_
......@@ -20,6 +21,9 @@ typedef struct list_iterator list_iterator_t;
/** Creates a new list with the given element size. */
list_t* list_util_create_list();
/** Frees the memory occupied by the given list. */
void list_util_destroy_list(list_t* list);
/** Appends the given element to the end of the list. */
void list_util_append(list_t* list, void* element);
......@@ -46,6 +50,10 @@ bool list_util_iterator_has_next(list_iterator_t* iter);
/** Returns the next element during forward iteration and advances the iterator forward. */
void* list_util_iterator_next(list_iterator_t* iter);
/** Returns the current element during iteration without advancing the iterator.
* */
void* list_util_iterator_current(list_iterator_t* iter);
/** Checks whether the given iterator has a previous element during backward iteration. */
bool list_util_iterator_has_previous(list_iterator_t* iter);
......@@ -54,4 +62,7 @@ void* list_util_iterator_previous(list_iterator_t* iter);
/** Destroys the iterator when it is no longer needed. */
void list_util_iterator_destroy(list_iterator_t* iter);
/** Removes and returns the specified element in the list. */
void* list_util_remove_element(list_iterator_t* list_iterator);
#endif /* INC_LISTUTIL_H_ */
......@@ -7,6 +7,7 @@
*
* Contributors:
* Florian Hoelzl - initial API and implementation
* Constantin Dresel - added recceive function
*******************************************************************************/
#ifndef INC_PROTOCOL_CONTROL_CENTER_H_
......@@ -27,6 +28,9 @@ void protocol_control_center_create(protocol_control_center_configuration_t* con
/** Writes len bytes of the given text to the control center. */
void protocol_control_center_write(char* text, size_t len);
/** Reads at maximum len bytes from control center to the given buffer. */
void protocol_control_center_receive(char* text, size_t len);
/** Terminates the connection to the control center. */
void protocol_control_center_terminate();
......
No preview for this file type
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment