Skip to content

Commit

Permalink
Moves user config for IDLE header to CMakeLists
Browse files Browse the repository at this point in the history
Moves the switches for producing and consuming IDLE headers to the CMake
configuration. CMake options are set to the standard values, as expected
in the stc/eds file.

Signed-off-by: Martin Melik-Merkumians <[email protected]>
  • Loading branch information
MartinMelikMerkumians committed Nov 9, 2018
1 parent c4cea24 commit 4e22cfd
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 28 deletions.
12 changes: 12 additions & 0 deletions source/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@ find_path( OpENer_BUILDSUPPORT_DIR OpENer.cmake ${PROJECT_SOURCE_DIR}/buildsuppo

INCLUDE( ${OpENer_BUILDSUPPORT_DIR}/OpENer.cmake )

option(OPENER_PRODUCED_DATA_HAS_RUN_IDLE_HEADER "Shall produced data from OpENer also include a run idle header?" FALSE)
option(OPENER_CONSUMED_DATA_HAS_RUN_IDLE_HEADER "Will consumed data from OpENer also include a run idle header?" TRUE)

if(OPENER_PRODUCED_DATA_HAS_RUN_IDLE_HEADER)
add_definitions(-DOPENER_PRODUCED_DATA_HAS_RUN_IDLE_HEADER)
endif()

if(OPENER_CONSUMED_DATA_HAS_RUN_IDLE_HEADER)
add_definitions(-DOPENER_CONSUMED_DATA_HAS_RUN_IDLE_HEADER)
endif()


#######################################
# Platform switches #
#######################################
Expand Down
38 changes: 20 additions & 18 deletions source/src/cip/cipioconnection.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,13 @@ EipUint16 SetupIoConnectionOriginatorToTargetConnectionPoint(
data_size -= 2; /* remove 16-bit sequence count length */
diff_size += 2;
}
if ( (kOpenerConsumedDataHasRunIdleHeader) && (data_size > 0)
&& (!is_heartbeat) ) {
#ifdef OPENER_CONSUMED_DATA_HAS_RUN_IDLE_HEADER
if ( (data_size > 0) && (!is_heartbeat) ) {
/* we only have an run idle header if it is not an heartbeat connection */
data_size -= 4; /* remove the 4 bytes needed for run/idle header */
diff_size += 4;
}
#endif
if ( ( (CipByteArray *) attribute->data )->length != data_size ) {
/*wrong connection size */
connection_object->correct_originator_to_target_size =
Expand Down Expand Up @@ -240,12 +241,13 @@ EipUint16 SetupIoConnectionTargetToOriginatorConnectionPoint(
data_size -= 2; /* remove 16-bit sequence count length */
diff_size += 2;
}
if ( (kOpenerProducedDataHasRunIdleHeader) && (data_size > 0)
&& (!is_heartbeat) ) {
#ifdef OPENER_PRODUCED_DATA_HAS_RUN_IDLE_HEADER
if ( (data_size > 0) && (!is_heartbeat) ) {
/* we only have an run idle header if it is not an heartbeat connection */
data_size -= 4; /* remove the 4 bytes needed for run/idle header */
diff_size += 4;
}
#endif
if ( ( (CipByteArray *) attribute->data )->length != data_size ) {
/*wrong connection size*/
connection_object->correct_target_to_originator_size =
Expand Down Expand Up @@ -823,9 +825,9 @@ EipStatus SendConnectedData(CipConnectionObject *connection_object) {
outgoing_message.current_message_position -= 2;
common_packet_format_data->data_item.length = producing_instance_attributes
->length;
if (kOpenerProducedDataHasRunIdleHeader) {
common_packet_format_data->data_item.length += 4;
}
#ifdef OPENER_PRODUCED_DATA_HAS_RUN_IDLE_HEADER
common_packet_format_data->data_item.length += 4;
#endif /* OPENER_PRODUCED_DATA_HAS_RUN_IDLE_HEADER */

if (kConnectionObjectTransportClassTriggerTransportClass1 ==
ConnectionObjectGetTransportClassTriggerTransportClass(connection_object) )
Expand All @@ -840,10 +842,10 @@ EipStatus SendConnectedData(CipConnectionObject *connection_object) {
&outgoing_message.current_message_position);
}

if (kOpenerProducedDataHasRunIdleHeader) {
AddDintToMessage( g_run_idle_state,
&(outgoing_message.current_message_position) );
}
#ifdef OPENER_PRODUCED_DATA_HAS_RUN_IDLE_HEADER
AddDintToMessage( g_run_idle_state,
&(outgoing_message.current_message_position) );
#endif /* OPENER_PRODUCED_DATA_HAS_RUN_IDLE_HEADER */

memcpy(outgoing_message.current_message_position,
producing_instance_attributes->data,
Expand Down Expand Up @@ -879,14 +881,14 @@ EipStatus HandleReceivedIoConnectionData(

if (data_length > 0) {
/* we have no heartbeat connection */
if (kOpenerConsumedDataHasRunIdleHeader) {
EipUint32 nRunIdleBuf = GetDintFromMessage( &(data) );
if (g_run_idle_state != nRunIdleBuf) {
RunIdleChanged(nRunIdleBuf);
}
g_run_idle_state = nRunIdleBuf;
data_length -= 4;
#ifdef OPENER_CONSUMED_DATA_HAS_RUN_IDLE_HEADER
EipUint32 nRunIdleBuf = GetDintFromMessage( &(data) );
if (g_run_idle_state != nRunIdleBuf) {
RunIdleChanged(nRunIdleBuf);
}
g_run_idle_state = nRunIdleBuf;
data_length -= 4;
#endif /* OPENER_CONSUMED_DATA_HAS_RUN_IDLE_HEADER */

if (NotifyAssemblyConnectedDataReceived(
connection_object->consuming_instance, (EipUint8 *const)data,
Expand Down
10 changes: 0 additions & 10 deletions source/src/ports/POSIX/sample_application/opener_user_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,6 @@
*/
static const MilliSeconds kOpenerTimerTickInMilliSeconds = 10;

/** @brief Define if RUN IDLE data is sent with consumed data
*/
static const int kOpenerConsumedDataHasRunIdleHeader = 1;

/** @brief Define if RUN IDLE data is to be sent with produced data
*
* Per default we don't send run idle headers with produced data
*/
static const int kOpenerProducedDataHasRunIdleHeader = 0;

#ifdef OPENER_WITH_TRACES
/* If we have tracing enabled provide print tracing macro */
#include <stdio.h>
Expand Down

0 comments on commit 4e22cfd

Please sign in to comment.