-
Notifications
You must be signed in to change notification settings - Fork 298
Open
Description
The error log always appears "too large packet received will be ignored, will drop the data".
I modified the sampleapplication.c file under POSIX as follows, and I modified the value of OPENER_CIP_NUM_EXLUSIVE_OWNER_CONNS in opener_user_conf.h to 50. When I run it, I always get the error: "too large packet received will be ignored, will drop the data".
My sampleapplication.c file :
/*******************************************************************************
* Copyright (c) 2012, Rockwell Automation, Inc.
* All rights reserved.
*
******************************************************************************/
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include "opener_api.h"
#include "appcontype.h"
#include "trace.h"
#include "cipidentity.h"
#include "ciptcpipinterface.h"
#include "cipqos.h"
#include "nvdata.h"
#if defined(OPENER_ETHLINK_CNTRS_ENABLE) && 0 != OPENER_ETHLINK_CNTRS_ENABLE
#include "cipethernetlink.h"
#include "ethlinkcbs.h"
#endif
// #define DEMO_APP_INPUT_ASSEMBLY_NUM 100 //0x064
// #define DEMO_APP_OUTPUT_ASSEMBLY_NUM 150 //0x096
// #define DEMO_APP_CONFIG_ASSEMBLY_NUM 151 //0x097
// #define DEMO_APP_HEARTBEAT_INPUT_ONLY_ASSEMBLY_NUM 152 //0x098
// #define DEMO_APP_HEARTBEAT_LISTEN_ONLY_ASSEMBLY_NUM 153 //0x099
// #define DEMO_APP_EXPLICT_ASSEMBLY_NUM 154 //0x09A
/* global variables for demo application (4 assembly data fields) ************/
// EipUint8 g_assembly_data064[32]; /* Input */
// EipUint8 g_assembly_data096[32]; /* Output */
// EipUint8 g_assembly_data097[10]; /* Config */
// EipUint8 g_assembly_data09A[32]; /* Explicit */
EipUint8 g_assembly_data_temp[4096];
EipUint8 g_assembly_config[10]; /* Config */
/* local functions */
enum AppAssemblyNum {
CONFIG_ASSEMBLY_NUM = 161,//0xA1
INPUT_ASSEMBLY_NUM = 101, //0x65
INPUT_ROBOT_STATE_ASSEMBLY_NUM,
INPUT_BOARD_IO_ASSEMBLY_NUM,
INPUT_TOOL_ASSEMBLY_NUM,
INPUT_JOINT_ASSEMBLY_NUM,
INPUT_TCP_ASSEMBLY_NUM,
INPUT_BOOL_ASSEMBLY_NUM,
INPUT_INT_ASSEMBLY_NUM,
INPUT_FLOAT_ASSEMBLY_NUM,
INPUT_IO_ASSEMBLY_NUM, // TODO: 删除此项
OUTPUT_ASSEMBLY_NUM = 131, // 0X83
OUTPUT_ROBOT_STATE_ASSEMBLY_NUM, // TODO: 删除此项
OUTPUT_BOARD_IO_ASSEMBLY_NUM, // TODO: 删除此项
OUTPUT_TOOL_ASSEMBLY_NUM, // TODO: 删除此项
OUTPUT_JOINT_ASSEMBLY_NUM, // TODO: 删除此项
OUTPUT_TCP_ASSEMBLY_NUM, // TODO: 删除此项
OUTPUT_BOOL_ASSEMBLY_NUM,
OUTPUT_INT_ASSEMBLY_NUM,
OUTPUT_FLOAT_ASSEMBLY_NUM,
OUTPUT_ROBOT_IO_ASSEMBLY_NUM
};
/* global functions called by the stack */
EipStatus ApplicationInitialization(void) {
/* create 3 assembly object instances*/
/*INPUT*/
// CreateAssemblyObject( DEMO_APP_INPUT_ASSEMBLY_NUM, g_assembly_data064,
// sizeof(g_assembly_data064) );
enum AppAssemblyNum assem = INPUT_ASSEMBLY_NUM;
CipInstance* instance = CreateAssemblyObject(assem, g_assembly_data_temp, 428);
printf("CreateAssemblyObject: %d, %p\n", assem, instance);
assem++;
instance = CreateAssemblyObject(assem, g_assembly_data_temp, 24);
printf("CreateAssemblyObject: %d, %p\n", assem, instance);
assem++;
instance = CreateAssemblyObject(assem, g_assembly_data_temp, 28);
printf("CreateAssemblyObject: %d, %p\n", assem, instance);
assem++;
instance = CreateAssemblyObject(assem, g_assembly_data_temp, 24);
printf("CreateAssemblyObject: %d, %p\n", assem, instance);
assem++;
instance = CreateAssemblyObject(assem, g_assembly_data_temp, 104);
printf("CreateAssemblyObject: %d, %p\n", assem, instance);
assem++;
instance = CreateAssemblyObject(assem, g_assembly_data_temp, 48);
printf("CreateAssemblyObject: %d, %p\n", assem, instance);
assem++;
instance = CreateAssemblyObject(assem, g_assembly_data_temp, 8);
printf("CreateAssemblyObject: %d, %p\n", assem, instance);
assem++;
instance = CreateAssemblyObject(assem, g_assembly_data_temp, 96);
printf("CreateAssemblyObject: %d, %p\n", assem, instance);
assem++;
instance = CreateAssemblyObject(assem, g_assembly_data_temp, 96);
printf("CreateAssemblyObject: %d, %p\n", assem, instance);
assem++;
instance = CreateAssemblyObject(assem, g_assembly_data_temp, 4);
printf("CreateAssemblyObject: %d, %p\n", assem, instance);
/*OUTPUT*/
// CreateAssemblyObject( DEMO_APP_OUTPUT_ASSEMBLY_NUM, g_assembly_data096,
// sizeof(g_assembly_data096) );
assem = OUTPUT_ASSEMBLY_NUM;
instance = CreateAssemblyObject(assem, g_assembly_data_temp, 232);
printf("CreateAssemblyObject: %d, %p\n", assem, instance);
assem++;
instance = CreateAssemblyObject(assem, g_assembly_data_temp, 4);
printf("CreateAssemblyObject: %d, %p\n", assem, instance);
assem++;
instance = CreateAssemblyObject(assem, g_assembly_data_temp, 4);
printf("CreateAssemblyObject: %d, %p\n", assem, instance);
assem++;
instance = CreateAssemblyObject(assem, g_assembly_data_temp, 4);
printf("CreateAssemblyObject: %d, %p\n", assem, instance);
assem++;
instance = CreateAssemblyObject(assem, g_assembly_data_temp, 4);
printf("CreateAssemblyObject: %d, %p\n", assem, instance);
assem++;
instance = CreateAssemblyObject(assem, g_assembly_data_temp, 4);
printf("CreateAssemblyObject: %d, %p\n", assem, instance);
assem++;
instance = CreateAssemblyObject(assem, g_assembly_data_temp, 8);
printf("CreateAssemblyObject: %d, %p\n", assem, instance);
assem++;
instance = CreateAssemblyObject(assem, g_assembly_data_temp, 96);
printf("CreateAssemblyObject: %d, %p\n", assem, instance);
assem++;
instance = CreateAssemblyObject(assem, g_assembly_data_temp, 96);
printf("CreateAssemblyObject: %d, %p\n", assem, instance);
assem++;
instance = CreateAssemblyObject(assem, g_assembly_data_temp, 32);
printf("CreateAssemblyObject: %d, %p\n", assem, instance);
/*CONFIG*/
// CreateAssemblyObject( DEMO_APP_CONFIG_ASSEMBLY_NUM, g_assembly_data097,
// sizeof(g_assembly_data097) );
instance = CreateAssemblyObject(CONFIG_ASSEMBLY_NUM, g_assembly_config, sizeof(g_assembly_config) );
printf("CreateAssemblyObject: %d, %p\n", CONFIG_ASSEMBLY_NUM, instance);
// /*Heart-beat output assembly for Input only connections */
// CreateAssemblyObject(DEMO_APP_HEARTBEAT_INPUT_ONLY_ASSEMBLY_NUM, NULL, 0);
// /*Heart-beat output assembly for Listen only connections */
// CreateAssemblyObject(DEMO_APP_HEARTBEAT_LISTEN_ONLY_ASSEMBLY_NUM, NULL, 0);
// /* assembly for explicit messaging */
// CreateAssemblyObject( DEMO_APP_EXPLICT_ASSEMBLY_NUM, g_assembly_data09A,
// sizeof(g_assembly_data09A) );
enum AppAssemblyNum assem_i = INPUT_ASSEMBLY_NUM;
enum AppAssemblyNum assem_o = OUTPUT_ASSEMBLY_NUM;
ConfigureExclusiveOwnerConnectionPoint(0, assem_o, assem_i, CONFIG_ASSEMBLY_NUM);
printf("ConfigureExclusiveOwnerConnectionPoint: assem_o:%d, assem_i:%d\n", assem_o, assem_i);
assem_i++;
assem_o++;
ConfigureExclusiveOwnerConnectionPoint(1, assem_o, assem_i, CONFIG_ASSEMBLY_NUM);
printf("ConfigureExclusiveOwnerConnectionPoint: assem_o:%d, assem_i:%d\n", assem_o, assem_i);
assem_i++;
assem_o++;
ConfigureExclusiveOwnerConnectionPoint(2, assem_o, assem_i, CONFIG_ASSEMBLY_NUM);
printf("ConfigureExclusiveOwnerConnectionPoint: assem_o:%d, assem_i:%d\n", assem_o, assem_i);
assem_i++;
assem_o++;
ConfigureExclusiveOwnerConnectionPoint(3, assem_o, assem_i, CONFIG_ASSEMBLY_NUM);
printf("ConfigureExclusiveOwnerConnectionPoint: assem_o:%d, assem_i:%d\n", assem_o, assem_i);
assem_i++;
assem_o++;
ConfigureExclusiveOwnerConnectionPoint(4, assem_o, assem_i, CONFIG_ASSEMBLY_NUM);
printf("ConfigureExclusiveOwnerConnectionPoint: assem_o:%d, assem_i:%d\n", assem_o, assem_i);
assem_i++;
assem_o++;
ConfigureExclusiveOwnerConnectionPoint(5, assem_o, assem_i, CONFIG_ASSEMBLY_NUM);
printf("ConfigureExclusiveOwnerConnectionPoint: assem_o:%d, assem_i:%d\n", assem_o, assem_i);
assem_i++;
assem_o++;
ConfigureExclusiveOwnerConnectionPoint(6, assem_o, assem_i, CONFIG_ASSEMBLY_NUM);
printf("ConfigureExclusiveOwnerConnectionPoint: assem_o:%d, assem_i:%d\n", assem_o, assem_i);
assem_i++;
assem_o++;
ConfigureExclusiveOwnerConnectionPoint(7, assem_o, assem_i, CONFIG_ASSEMBLY_NUM);
printf("ConfigureExclusiveOwnerConnectionPoint: assem_o:%d, assem_i:%d\n", assem_o, assem_i);
assem_i++;
assem_o++;
ConfigureExclusiveOwnerConnectionPoint(8, assem_o, assem_i, CONFIG_ASSEMBLY_NUM);
printf("ConfigureExclusiveOwnerConnectionPoint: assem_o:%d, assem_i:%d\n", assem_o, assem_i);
assem_i++;
assem_o++;
ConfigureExclusiveOwnerConnectionPoint(9, assem_o, assem_i, CONFIG_ASSEMBLY_NUM);
printf("ConfigureExclusiveOwnerConnectionPoint: assem_o:%d, assem_i:%d\n", assem_o, assem_i);
// ConfigureExclusiveOwnerConnectionPoint(0, DEMO_APP_OUTPUT_ASSEMBLY_NUM,
// DEMO_APP_INPUT_ASSEMBLY_NUM,
// DEMO_APP_CONFIG_ASSEMBLY_NUM);
// ConfigureInputOnlyConnectionPoint(0,
// DEMO_APP_HEARTBEAT_INPUT_ONLY_ASSEMBLY_NUM,
// DEMO_APP_INPUT_ASSEMBLY_NUM,
// DEMO_APP_CONFIG_ASSEMBLY_NUM);
// ConfigureListenOnlyConnectionPoint(0,
// DEMO_APP_HEARTBEAT_LISTEN_ONLY_ASSEMBLY_NUM,
// DEMO_APP_INPUT_ASSEMBLY_NUM,
// DEMO_APP_CONFIG_ASSEMBLY_NUM);
/* For NV data support connect callback functions for each object class with
* NV data.
*/
InsertGetSetCallback(GetCipClass(kCipQoSClassCode), NvQosSetCallback,
kNvDataFunc);
InsertGetSetCallback(GetCipClass(kCipTcpIpInterfaceClassCode),
NvTcpipSetCallback,
kNvDataFunc);
#if defined(OPENER_ETHLINK_CNTRS_ENABLE) && 0 != OPENER_ETHLINK_CNTRS_ENABLE
/* For the Ethernet Interface & Media Counters connect a PreGetCallback and
* a PostGetCallback.
* The PreGetCallback is used to fetch the counters from the hardware.
* The PostGetCallback is utilized by the GetAndClear service to clear
* the hardware counters after the current data have been transmitted.
*/
{
CipClass *p_eth_link_class = GetCipClass(kCipEthernetLinkClassCode);
InsertGetSetCallback(p_eth_link_class,
EthLnkPreGetCallback,
kPreGetFunc);
InsertGetSetCallback(p_eth_link_class,
EthLnkPostGetCallback,
kPostGetFunc);
/* Specify the attributes for which the callback should be executed. */
for (int idx = 0; idx < OPENER_ETHLINK_INSTANCE_CNT; ++idx)
{
CipAttributeStruct *p_eth_link_attr;
CipInstance *p_eth_link_inst =
GetCipInstance(p_eth_link_class, idx + 1);
OPENER_ASSERT(p_eth_link_inst);
/* Interface counters attribute */
p_eth_link_attr = GetCipAttribute(p_eth_link_inst, 4);
p_eth_link_attr->attribute_flags |= (kPreGetFunc | kPostGetFunc);
/* Media counters attribute */
p_eth_link_attr = GetCipAttribute(p_eth_link_inst, 5);
p_eth_link_attr->attribute_flags |= (kPreGetFunc | kPostGetFunc);
}
}
#endif
return kEipStatusOk;
}
void HandleApplication(void) {
/* check if application needs to trigger an connection */
}
void CheckIoConnectionEvent(unsigned int output_assembly_id,
unsigned int input_assembly_id,
IoConnectionEvent io_connection_event) {
/* maintain a correct output state according to the connection state*/
(void) output_assembly_id; /* suppress compiler warning */
(void) input_assembly_id; /* suppress compiler warning */
(void) io_connection_event; /* suppress compiler warning */
}
EipStatus AfterAssemblyDataReceived(CipInstance *instance) {
EipStatus status = kEipStatusOk;
/*handle the data received e.g., update outputs of the device */
// switch (instance->instance_number) {
// case DEMO_APP_OUTPUT_ASSEMBLY_NUM:
// /* Data for the output assembly has been received.
// * Mirror it to the inputs */
// memcpy( &g_assembly_data064[0], &g_assembly_data096[0],
// sizeof(g_assembly_data064) );
// break;
// case DEMO_APP_EXPLICT_ASSEMBLY_NUM:
// /* do something interesting with the new data from
// * the explicit set-data-attribute message */
// break;
// case DEMO_APP_CONFIG_ASSEMBLY_NUM:
// /* Add here code to handle configuration data and check if it is ok
// * The demo application does not handle config data.
// * However in order to pass the test we accept any data given.
// * EIP_ERROR
// */
// status = kEipStatusOk;
// break;
// default:
// OPENER_TRACE_INFO(
// "Unknown assembly instance ind AfterAssemblyDataReceived");
// break;
// }
return status;
}
EipBool8 BeforeAssemblyDataSend(CipInstance *pa_pstInstance) {
/*update data to be sent e.g., read inputs of the device */
/*In this sample app we mirror the data from out to inputs on data receive
* therefore we need nothing to do here. Just return true to inform that
* the data is new.
*/
// if (pa_pstInstance->instance_number == DEMO_APP_EXPLICT_ASSEMBLY_NUM) {
// /* do something interesting with the existing data
// * for the explicit get-data-attribute message */
// }
return true;
}
EipStatus ResetDevice(void) {
/* add reset code here*/
CloseAllConnections();
CipQosUpdateUsedSetQosValues();
return kEipStatusOk;
}
EipStatus ResetDeviceToInitialConfiguration(void) {
/*rest the parameters */
g_tcpip.encapsulation_inactivity_timeout = 120;
CipQosResetAttributesToDefaultValues();
/*than perform device reset*/
ResetDevice();
return kEipStatusOk;
}
void *
CipCalloc(size_t number_of_elements,
size_t size_of_element) {
return calloc(number_of_elements, size_of_element);
}
void CipFree(void *data) {
free(data);
}
void RunIdleChanged(EipUint32 run_idle_value) {
OPENER_TRACE_INFO("Run/Idle handler triggered\n");
if( (0x0001 & run_idle_value) == 1 ) {
CipIdentitySetExtendedDeviceStatus(kAtLeastOneIoConnectionInRunMode);
} else {
CipIdentitySetExtendedDeviceStatus(
kAtLeastOneIoConnectionEstablishedAllInIdleMode);
}
(void) run_idle_value;
}
Through debugging and packet capturing, I've found that in the NetworkHandlerProcessCyclic() function of the generic_networkhandler.c file, the call to HandleDataOnTcpSocket() receives UDP data on port 2222 and parses this packet in an incorrect way.
Metadata
Metadata
Assignees
Labels
No labels
