Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions source/src/cip/cipconnection.cc
Original file line number Diff line number Diff line change
Expand Up @@ -929,11 +929,11 @@ CipError ConnectionData::CorrectSizes( ConnMgrStatus* aExtError )
// an assembly object should always have an attribute 3
CIPSTER_ASSERT( attribute );

ByteBuf* attr_data = (ByteBuf*) consuming_instance->Data( attribute );
int attr_size = static_cast<AssemblyInstance*>(consuming_instance)->SizeBytes();

data_size = consuming_ncp.ConnectionSize();
diff_size = 0;
is_heartbeat = ( attr_data->size() == 0 );
is_heartbeat = ( attr_size == 0 );

if( trigger.Class() == kConnTransportClass1 )
{
Expand All @@ -950,19 +950,19 @@ CipError ConnectionData::CorrectSizes( ConnMgrStatus* aExtError )
diff_size += 4;
}

if( ( consuming_ncp.IsFixed() && data_size != attr_data->size() )
|| data_size > attr_data->size() )
if( ( consuming_ncp.IsFixed() && data_size != attr_size )
|| data_size > attr_size )
{
// wrong connection size
corrected_consuming_size = attr_data->size() + diff_size;
corrected_consuming_size = attr_size + diff_size;

*aExtError = kConnMgrStatusInvalidOToTConnectionSize;

CIPSTER_TRACE_INFO(
"%s: assembly size(%d) != requested conn_size(%d) for consuming:'%s'\n"
" corrected_o_t:%d\n",
__func__,
(int) attr_data->size(),
attr_size,
data_size,
ConsumingPath().Format().c_str(),
corrected_consuming_size
Expand Down Expand Up @@ -991,13 +991,13 @@ CipError ConnectionData::CorrectSizes( ConnMgrStatus* aExtError )
// an assembly object should always have an attribute 3
CIPSTER_ASSERT( attribute );

ByteBuf* attr_data = (ByteBuf*) producing_instance->Data( attribute );
int attr_size = static_cast<AssemblyInstance*>(producing_instance)->SizeBytes();

data_size = producing_ncp.ConnectionSize();
diff_size = 0;

// Note: spec never talks about a heartbeat t_o connection, so why this?
is_heartbeat = ( attr_data->size() == 0 );
is_heartbeat = ( attr_size == 0 );

if( trigger.Class() == kConnTransportClass1 )
{
Expand All @@ -1010,23 +1010,23 @@ CipError ConnectionData::CorrectSizes( ConnMgrStatus* aExtError )
// and is not kRealTimeFmtModeless
&& !is_heartbeat )
{
data_size -= 4; // remove the 4 bytes needed for run/idle header
data_size -= 4; // remove the 4 bytes needed for run/idle header
diff_size += 4;
}

if( ( producing_ncp.IsFixed() && data_size != attr_data->size() )
|| data_size > attr_data->size() )
if( ( producing_ncp.IsFixed() && data_size != attr_size )
|| data_size > attr_size )
{
// wrong connection size
corrected_producing_size = attr_data->size() + diff_size;
corrected_producing_size = attr_size + diff_size;

*aExtError = kConnMgrStatusInvalidTToOConnectionSize;

CIPSTER_TRACE_INFO(
"%s: assembly size(%d) != requested conn_size(%d) for producing:'%s'\n"
" corrected_t_o:%d\n",
__func__,
(int) attr_data->size(),
attr_size,
data_size,
ProducingPath().Format().c_str(),
corrected_producing_size
Expand Down