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

Add local uid as main argument


add noval to leader and preceding UID

restructure coding

Signed-off-by: default avatarStefan Duenhuber <stefan.duenhuber@gmail.com>
parent 78c62801
No related branches found
No related tags found
No related merge requests found
Showing
with 57 additions and 99 deletions
......@@ -25,7 +25,7 @@
*/
typedef struct af3_v2v_generic_message_t {
uint8_t type_id;
uint16_t source_uid;
GEN_TYPE_int source_uid;
size_t payload_length;
uint8_t actual_message_start;
}__attribute__ ((packed)) af3_v2v_generic_message_t;
......@@ -50,6 +50,8 @@ 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);
typedef void (*v2v_msg_handshake_handler_t) (uint8_t* p_msg,
size_t msg_payload_len);
/**
* A strut for passing message handler pointers to functions.
......@@ -63,6 +65,7 @@ typedef struct af3_v2v_handler_functions_container_t {
v2v_msg_split_handler_t split_handler;
v2v_msg_new_leader_handler_t new_leader_handler;
v2v_msg_fuse_platoon_handler_t fuse_platoon_handler;
v2v_msg_handshake_handler_t handshake_handler;
}af3_v2v_handler_functions_container_t;
/**
......@@ -74,7 +77,8 @@ 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, bool start_lsitener);
int af3_v2v_activate(uint16_t port, GEN_TYPE_int local_uid, bool start_lsitener)
;
/**
* \brief Call this to exit vehicle 2 vehicle communication.
......@@ -113,16 +117,20 @@ void af3_v2v_listen(af3_v2v_handler_functions_container_t* p_message_handlers);
* Sets the uid for the leader vehicle to listen to to the given value. This uid
* e.g. is used for filtering incoming messages.
* @param uid The unique ID of the leader vehicle to listen to.
* @param uid_noval Indicator whether the given uid is valid or unset.
*/
void af3_v2v_set_leader_vehicle_of_interest_uid(uint16_t uid);
void af3_v2v_set_leader_vehicle_of_interest_uid(GEN_TYPE_int uid,
GEN_TYPE_boolean uid_noval);
/**
* \brief Set the uid for the preceding vehicle to listen to.
* Sets the uid for the vehicle directly preceding the ego vehicle to the given
* value. This uid e.g. is used for filtering incoming messages.
* @param uid The unique ID of the directly preceding vehicle to listen to.
* @param uid_noval Indicator whether the given uid is valid or unset.
*/
void af3_v2v_set_preceding_vehicle_of_interest_uid(uint16_t uid);
void af3_v2v_set_preceding_vehicle_of_interest_uid(GEN_TYPE_int uid,
GEN_TYPE_boolean uid_noval);
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);
......@@ -132,6 +140,7 @@ 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_get_handshake(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);
......@@ -141,5 +150,6 @@ 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);
void af3_v2v_send_handshake(uint8_t* p_src_struct, size_t src_size);
#endif /* AF3_V2V_H_ */
No preview for this file type
......@@ -1058,21 +1058,7 @@
</objectClass>
</target>
</transformationProvider>
<transformationProvider
transformationProvider="org.fortiss.af3.platform.raspberry.generator.transform.v2v.V2VLocalUIDOutputTransformation">
<source>
<objectClass
objectClass="org.fortiss.af3.platform.raspberry.model.v2v.V2VLocalUIDOutput">
</objectClass>
</source>
<target>
<objectClass
objectClass="org.fortiss.af3.platform.raspberry.generator.extension.v2v.V2VLocalUIDOutputGeneratorExtension">
</objectClass>
</target>
</transformationProvider>
<transformationProvider
transformationProvider="org.fortiss.af3.platform.raspberry.generator.transform.v2v.V2VNewLeaderOutputTransformation">
<source>
......
......@@ -50,7 +50,7 @@ abstract class V2VGeneratorExtensionBase<T extends EObject> extends
StringBuilder sb = new StringBuilder();
sb.append("// initialize the v2v communicaton\n");
// initialize the v2v communicaton
sb.append("af3_v2v_activate( 9990, -1, true);\n");
sb.append("af3_v2v_activate( 9990, arguments.local_uid, true);\n");
return sb.toString();
}
......
......@@ -31,7 +31,7 @@ public class V2VHandshakeInputGeneratorExtension extends
@Override
public String getReadCode(InputPort logicalSignal, String targetVariable) {
// TODO Auto-generated method stub
return "af3_v2v_get_FIXME_Handshake( (uint8_t*) &" + targetVariable + ", sizeof(" +
return "af3_v2v_get_handshake( (uint8_t*) &" + targetVariable + ", sizeof(" +
targetVariable + "));\n";
}
......
......@@ -34,7 +34,8 @@ public class V2VLeaderUIDOutputGeneratorExtension extends
/** {@inheritDoc} */
@Override
public String getWriteCode(OutputPort logicalSignal, String value) {
return "af3_v2v_set_leader_vehicle_of_interest_uid(" + value + ");\n";
return "af3_v2v_set_leader_vehicle_of_interest_uid(" + value + " , noval_" + value +
" );\n";
}
/** {@inheritDoc} */
......
/*-------------------------------------------------------------------------+
| Copyright 2018 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.af3.platform.raspberry.generator.extension.v2v;
import org.fortiss.af3.component.model.OutputPort;
import org.fortiss.af3.platform.raspberry.generator.framework.IWriteableGeneratorExtension;
import org.fortiss.af3.platform.raspberry.model.v2v.V2VLocalUIDOutput;
/**
* @author duenhuber
* Executable for v2v output {@link V2VLocalUIDOutput}.
*/
public class V2VLocalUIDOutputGeneratorExtension extends
V2VGeneratorExtensionBase<V2VLocalUIDOutput> implements IWriteableGeneratorExtension {
/** Constructor. */
public V2VLocalUIDOutputGeneratorExtension(V2VLocalUIDOutput modelElement) {
super(modelElement);
}
/** {@inheritDoc} */
@Override
public String getWriteCode(OutputPort logicalSignal, String value) {
return "af3_v2v_set_local_uid(" + value + ");\n";
}
/** {@inheritDoc} */
@Override
public String getNoValWriteCode(OutputPort logicalSignal) {
// TODO Auto-generated method stub
return null;
}
}
......@@ -34,7 +34,8 @@ public class V2VPrecedingUIDOutputGeneratorExtension extends
@Override
public String getWriteCode(OutputPort logicalSignal, String value) {
// TODO Auto-generated method stub
return "af3_v2v_set_preceding_vehicle_of_interest_uid(" + value + ");\n";
return "af3_v2v_set_preceding_vehicle_of_interest_uid(" + value + " , noval_" + value +
" );\n";
}
/** {@inheritDoc} */
......
......@@ -18,6 +18,7 @@ $SYSTEM_INCLUDES$
#include <af3.h>
#include <debugprint.h>
#include <timeutil.h>
#include <argp.h>
#define STOP_AT_LOGICAL_CLOCK (uint64_t)0 // run infinitely
......@@ -28,6 +29,35 @@ static uint64_t step = 0;
int global_debug_print_level = DEBUG_PRINT_LEVEL_NONE;
const int cycle_time = $CYCLE_TIME_IN_MILLIS$;
//use main arguments
struct arguments {
uint64_t local_uid;
};
static struct argp_option options[] = {
{ "local_uid", 'u', "UID", 0, "Local Rover UID for V2V communications" , 1},
{ 0 }
};
static error_t parse_opt(int key, char* arg, struct argp_state* state) {
struct arguments* arguments = state->input;
switch(key) {
case 'u':
arguments->local_uid = atoll(arg);
break;
case ARGP_KEY_ARG: return 0;
default: return ARGP_ERR_UNKNOWN;
}
return 0;
}
static char doc[] = "Arguments for V2V communication currently only local uid needed.";
static char args_doc[] = "";
static struct argp argp = { options, parse_opt, args_doc, doc, NULL, NULL, NULL };
$SENSOR_VARIABLES$
$AUXILIARY_FUNCTIONS$
......@@ -45,6 +75,12 @@ static void worker() {
int main(int argc, char** argv) {
// set default values of input arguments
struct arguments arguments;
arguments.local_uid = -1;
argp_parse(&argp, argc, argv, 0, 0, &arguments);
local_logical_clock = 1;
$SYSTEM_INIT_CODE$
......
/*-------------------------------------------------------------------------+
| Copyright 2018 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.af3.platform.raspberry.generator.transform.v2v;
import org.fortiss.af3.platform.raspberry.generator.extension.v2v.V2VLocalUIDOutputGeneratorExtension;
import org.fortiss.af3.platform.raspberry.generator.transform.RasPiGeneratorTransformationBase;
import org.fortiss.af3.platform.raspberry.model.v2v.V2VLocalUIDOutput;
/**
* @author duenhuber
* Transformation for {@link V2VLocalUIDOutput}.
*/
public class V2VLocalUIDOutputTransformation extends RasPiGeneratorTransformationBase {
/** Constructor. */
public V2VLocalUIDOutputTransformation() {
super(V2VLocalUIDOutput.class, V2VLocalUIDOutputGeneratorExtension.class);
}
}
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