Skip to content
Snippets Groups Projects
Commit 1b34ba37 authored by Stefan Duenhuber's avatar Stefan Duenhuber
Browse files

Update af3pihal files


adapt Output/input Platoon message



Signed-off-by: default avatarStefan Duenhuber <stefan.duenhuber@gmail.com>
parent 5536807c
No related branches found
No related tags found
No related merge requests found
......@@ -11,6 +11,9 @@
#define AF3_V2V_H_
#include "v2v_message_types.h"
#include "af3.h"
#include <stdint.h>
#include <stdbool.h>
/** the number of received messages storable in the message read buffer at worst
* case */
......@@ -23,6 +26,7 @@
typedef struct af3_v2v_generic_message_t {
uint8_t type_id;
uint16_t source_uid;
size_t payload_length;
uint8_t actual_message_start;
}__attribute__ ((packed)) af3_v2v_generic_message_t;
......@@ -30,18 +34,22 @@ typedef struct af3_v2v_generic_message_t {
* Type for function pointer to v2v message handler for type DELETEME.
* @param p_msg_deleteme A pointer to the message to be handled
*/
typedef void (*v2v_msg_deleteme_handler_t) (v2v_msg_deleteme_t* p_msg_deleteme);
typedef void (*v2v_msg_platoon_handler_t) (v2v_msg_platoon_t* p_msg_platoon);
typedef void (*v2v_msg_leader_heartbeat_handler_t)
(v2v_msg_leader_heartbeat_t* p_msg_leader_heartbeat);
typedef void (*v2v_msg_follower_handler_t) (v2v_msg_follower_t* p_msg_follower);
typedef void (*v2v_msg_leave_platoon_handler_t)
(v2v_msg_leave_platoon_t* p_msg_leave_platoon);
typedef void (*v2v_msg_split_handler_t) (v2v_msg_split_t* p_msg_split);
typedef void (*v2v_msg_new_leader_handler_t)
(v2v_msg_new_leader_t* p_msg_new_leader);
typedef void (*v2v_msg_fuse_platoon_handler_t)
(v2v_msg_fuse_platoon_t* p_msg_fuse_platoon);
typedef void (*v2v_msg_deleteme_handler_t) (uint8_t* p_msg,
size_t msg_payload_len);
typedef void (*v2v_msg_platoon_handler_t) (uint8_t* p_msg,
size_t msg_payload_len);
typedef void (*v2v_msg_leader_heartbeat_handler_t) (uint8_t* p_msg,
size_t msg_payload_len);
typedef void (*v2v_msg_follower_handler_t) (uint8_t* p_msg,
size_t msg_payload_len);
typedef void (*v2v_msg_leave_platoon_handler_t) (uint8_t* p_msg,
size_t msg_payload_len);
typedef void (*v2v_msg_split_handler_t) (uint8_t* p_msg, size_t msg_payload_len)
;
typedef void (*v2v_msg_new_leader_handler_t) (uint8_t* p_msg,
size_t msg_payload_len);
typedef void (*v2v_msg_fuse_platoon_handler_t) (uint8_t* p_msg,
size_t msg_payload_len);
/**
* A strut for passing message handler pointers to functions.
......@@ -66,7 +74,7 @@ typedef struct af3_v2v_handler_functions_container_t {
* @param local_uid A unique id for the local device.
* @return The socket file descriptor on success a negative value otherwise.
*/
int af3_v2v_activate(uint16_t port, uint16_t local_uid);
int af3_v2v_activate(uint16_t port, uint16_t local_uid, bool start_lsitener);
/**
* \brief Call this to exit vehicle 2 vehicle communication.
......@@ -82,9 +90,10 @@ int af3_v2v_deactivate(void);
* @param msg_type The type identifier of the message to be transmitted.
* @param p_msg A pointer to the first Byte of the actual message to be
* transmitted.
* @param msg_len The length of the message to send given in bytes.
* @return The number of bytes transmitted on success, negative otherwise.
*/
ssize_t af3_v2v_send_msg(uint8_t msg_type, uint8_t* p_msg);
ssize_t af3_v2v_send_msg(uint8_t msg_type, uint8_t* p_msg, size_t msg_len);
/**
* \brief Wait for incoming messages and pass them to specified handlers.
......@@ -115,5 +124,22 @@ void af3_v2v_set_leader_vehicle_of_interest_uid(uint16_t uid);
*/
void af3_v2v_set_preceding_vehicle_of_interest_uid(uint16_t uid);
void af3_v2v_get_deleteme(uint8_t* p_target_struct, size_t target_size);
void af3_v2v_get_platoon(uint8_t* p_target_struct, size_t target_size);
void af3_v2v_get_leader_heartbeat(uint8_t* p_target_struct, size_t target_size);
void af3_v2v_get_follower(uint8_t* p_target_struct, size_t target_size);
void af3_v2v_get_leave_platoon(uint8_t* p_target_struct, size_t target_size);
void af3_v2v_get_split(uint8_t* p_target_struct, size_t target_size);
void af3_v2v_get_new_leader(uint8_t* p_target_struct, size_t target_size);
void af3_v2v_get_fuse_platoon(uint8_t* p_target_struct, size_t target_size);
void af3_v2v_send_deleteme(uint8_t* p_src_struct, size_t src_size);
void af3_v2v_send_platoon(uint8_t* p_src_struct, size_t src_size);
void af3_v2v_send_leader_heartbeat(uint8_t* p_src_struct, size_t src_size);
void af3_v2v_send_follower(uint8_t* p_src_struct, size_t src_size);
void af3_v2v_send_leave_platoon(uint8_t* p_src_struct, size_t src_size);
void af3_v2v_send_split(uint8_t* p_src_struct, size_t src_size);
void af3_v2v_send_new_leader(uint8_t* p_src_struct, size_t src_size);
void af3_v2v_send_fuse_platoon(uint8_t* p_src_struct, size_t src_size);
#endif /* AF3_V2V_H_ */
<<<<<<< HEAD
/*******************************************************************************
* 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
/*
* control_center_downstream.h
*
* Contributors:
* Constantin Dresel - initial API and implementation
*******************************************************************************/
* Created on: 05.06.2018
* Author: Constantin
*/
#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)
#define CC_DOWNSTREAM_INTBASE 10 /*!< Base for conversion from string to int
(10 for dec) */
#define CC_DOWNSTREAM_MAX_MSG_LEN 500 /*!< The maximum length of downstream
messages that can be received given in
byte */
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));
}rx_msg_container_t; /*!< a container for a received message and the message
age given in cycles of the main loop since reception */
/**
* \brief Initialize the downstream communication for control center.
......@@ -99,7 +97,7 @@ 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
* \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
......
No preview for this file type
......@@ -53,7 +53,7 @@ abstract class V2VGeneratorExtensionBase<T extends EObject> extends
sb.append("// initialize the v2v communicaton\n");
// initialize the v2v communicaton
sb.append("srand((unsigned int)time(NULL));\n");
sb.append("af3_v2v_activate( 9990, (uint16_t)rand());\n");
sb.append("af3_v2v_activate( 9990, (uint16_t)rand(), true);\n");
return sb.toString();
}
......
......@@ -36,8 +36,8 @@ abstract class V2VOutputGeneratorExtension<T extends EObject> extends
@Override
public String getWriteCode(OutputPort logicalSignal, String value) {
return "af3_v2v_send_msg(" + getV2VMessageType() + ", (uint8_t*) &" + value + " ) ;\n";
return "af3_v2v_send_msg(" + getV2VMessageType() + ", (uint8_t*) &" + value + ", sizeof(" +
value + ") ) ;\n";
}
/** {@inheritDoc} */
......
......@@ -31,7 +31,8 @@ public class V2VPlatoonInputGeneratorExtension extends V2VGeneratorExtensionBase
@Override
public String getReadCode(InputPort logicalSignal, String targetVariable) {
// TODO Auto-generated method stub
return null;
return "af3_v2v_get_platoon( (uint8_t*) &" + targetVariable + ", sizeof(" + targetVariable +
"));\n";
}
/** {@inheritDoc} */
......
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