OpENer - Open Source EtherNet/IP(TM) I/O Target Stack  2.1
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Callback Functions Demanded by OpENer

These functions have to implemented in order to give the OpENer a method to inform the application on certain state changes. More...

Collaboration diagram for Callback Functions Demanded by OpENer:

Functions

EipStatus AfterAssemblyDataReceived (CipInstance *instance)
 Call back function to inform application on received data for an assembly object. More...
 
EipStatus ApplicationInitialization (void)
 Callback for the application initialization. More...
 
EipBool8 BeforeAssemblyDataSend (CipInstance *instance)
 Inform the application that the data of an assembly object will be sent. More...
 
void CheckIoConnectionEvent (unsigned int output_assembly_id, unsigned int input_assembly_id, IoConnectionEvent io_connection_event)
 Inform the application on changes occurred for a connection. More...
 
void * CipCalloc (size_t number_of_elements, size_t size_of_element)
 Allocate memory for the CIP stack. More...
 
void CipFree (void *data)
 Free memory allocated by the OpENer. More...
 
void CloseSocket (const int socket_handle)
 Close the given socket and clean up the stack. More...
 
int CreateUdpSocket (UdpCommuncationDirection communication_direction, struct sockaddr_in *socket_data, CipUsint qos_for_socket)
 create a producing or consuming UDP socket More...
 
void HandleApplication (void)
 Allow the device specific application to perform its execution. More...
 
EipStatus ResetDevice (void)
 Emulate as close a possible a power cycle of the device. More...
 
EipStatus ResetDeviceToInitialConfiguration (void)
 Reset the device to the initial configuration and emulate as close as possible a power cycle of the device. More...
 
void RunIdleChanged (EipUint32 run_idle_value)
 Inform the application that the Run/Idle State has been changed by the originator. More...
 
EipStatus SendUdpData (struct sockaddr_in *socket_data, int socket_handle, EipUint8 *data, EipUint16 data_length)
 Create a producing or consuming UDP socket. More...
 

Detailed Description

These functions have to implemented in order to give the OpENer a method to inform the application on certain state changes.

Function Documentation

EipStatus AfterAssemblyDataReceived ( CipInstance instance)

Call back function to inform application on received data for an assembly object.

This function has to be implemented by the user of the CIP-stack.

Parameters
instancepointer to the assembly object data was received for
Returns
Information if the data could be processed
  • EIP_OK the received data was ok
  • EIP_ERROR the received data was wrong (especially needed for configuration data assembly objects)

Assembly Objects for Configuration Data: The CIP-stack uses this function to inform on received configuration data. The length of the data is already checked within the stack. Therefore the user only has to check if the data is valid.

Definition at line 81 of file sampleapplication.c.

References DEMO_APP_CONFIG_ASSEMBLY_NUM, DEMO_APP_EXPLICT_ASSEMBLY_NUM, DEMO_APP_OUTPUT_ASSEMBLY_NUM, g_assembly_data064, g_assembly_data096, cip_instance::instance_number, kEipStatusOk, and OPENER_TRACE_INFO.

Referenced by NotifyAssemblyConnectedDataReceived(), and SetAssemblyAttributeSingle().

Here is the caller graph for this function:

EipStatus ApplicationInitialization ( void  )

Callback for the application initialization.

This function will be called by the CIP stack after it has finished its initialization. In this function the user can setup all CIP objects she likes to have.

This function is provided for convenience reasons. After the void CipStackInit(void) function has finished it is okay to also generate your CIP objects. return status EIP_ERROR .. error EIP_OK ... successful finish

Definition at line 28 of file sampleapplication.c.

References ConfigureExclusiveOwnerConnectionPoint(), ConfigureInputOnlyConnectionPoint(), ConfigureListenOnlyConnectionPoint(), CreateAssemblyObject(), DEMO_APP_CONFIG_ASSEMBLY_NUM, DEMO_APP_EXPLICT_ASSEMBLY_NUM, DEMO_APP_HEARTBEAT_INPUT_ONLY_ASSEMBLY_NUM, DEMO_APP_HEARTBEAT_LISTEN_ONLY_ASSEMBLY_NUM, DEMO_APP_INPUT_ASSEMBLY_NUM, DEMO_APP_OUTPUT_ASSEMBLY_NUM, g_assembly_data064, g_assembly_data096, g_assembly_data097, g_assembly_data09A, and kEipStatusOk.

Referenced by CipStackInit().

Here is the call graph for this function:

Here is the caller graph for this function:

EipBool8 BeforeAssemblyDataSend ( CipInstance instance)

Inform the application that the data of an assembly object will be sent.

Within this function the user can update the data of the assembly object before it gets sent. The application can inform the application if data has changed.

Parameters
instanceinstance of assembly object that should send data.
Returns
data has changed:
  • true assembly data has changed
  • false assembly data has not changed

Definition at line 108 of file sampleapplication.c.

References DEMO_APP_EXPLICT_ASSEMBLY_NUM, and cip_instance::instance_number.

Referenced by GetAttributeSingle(), GetAttributeSingleTcpIpInterface(), and SendConnectedData().

Here is the caller graph for this function:

void CheckIoConnectionEvent ( unsigned int  output_assembly_id,
unsigned int  input_assembly_id,
IoConnectionEvent  io_connection_event 
)

Inform the application on changes occurred for a connection.

Parameters
output_assembly_idthe output assembly connection point of the connection
input_assembly_idthe input assembly connection point of the connection
io_connection_eventinformation on the change occurred

Definition at line 71 of file sampleapplication.c.

Referenced by CloseAllConnectionsForInputWithSameType(), CloseIoConnection(), EstablishIoConnection(), and HandleIoConnectionTimeOut().

Here is the caller graph for this function:

void* CipCalloc ( size_t  number_of_elements,
size_t  size_of_element 
)

Allocate memory for the CIP stack.

emulate the common c-library function calloc In OpENer allocation only happens on application startup and on class/instance creation and configuration not on during operation (processing messages).

Parameters
number_of_elementsnumber of elements to allocate
size_of_elementsize in bytes of one element
Returns
pointer to the allocated memory, 0 on error

Definition at line 137 of file sampleapplication.c.

Referenced by AddCipInstances(), AllocateAttributeMasks(), ConfigureDomainName(), ConfigureHostName(), ConfigureIpMacAddress(), ConfigureNetworkInterface(), CreateAssemblyObject(), CreateCipClass(), and RegisterCipClass().

Here is the caller graph for this function:

void CipFree ( void *  data)

Free memory allocated by the OpENer.

emulate the common c-library function free

Parameters
datapointer to the allocated memory

Definition at line 142 of file sampleapplication.c.

Referenced by ConfigureDomainName(), ConfigureHostName(), ConfigureIpMacAddress(), ConfigureNetworkInterface(), DeleteAllClasses(), ShutdownAssemblies(), and ShutdownTcpIpInterface().

Here is the caller graph for this function:

void CloseSocket ( const int  socket_handle)

Close the given socket and clean up the stack.

Parameters
socket_handlesocket descriptor to close

Definition at line 998 of file generic_networkhandler.c.

References CloseSocketPlatform(), master_socket, and OPENER_TRACE_INFO.

Referenced by CloseTcpSocket(), CloseUdpSocket(), ConfigureMacAddress(), ConfigureNetworkInterface(), CreateUdpSocket(), and NetworkHandlerFinish().

Here is the call graph for this function:

Here is the caller graph for this function:

int CreateUdpSocket ( UdpCommuncationDirection  communication_direction,
struct sockaddr_in *  socket_data,
CipUsint  qos_for_socket 
)

create a producing or consuming UDP socket

Parameters
communication_directionkUdpCommunicationDirectionProducing or kUdpCommunicationDirectionConsuming
socket_datapointer to the address holding structure Attention: For producing point-to-point connection the *pa_pstAddr->sin_addr.s_addr member is set to 0 by OpENer. The network layer of the application has to set the correct address of the originator. Attention: For consuming connection the network layer has to set the pa_pstAddr->sin_addr.s_addr to the correct address of the originator. FIXME add an additional parameter that can be used by the CIP stack to request the originators sockaddr_in data.
qos_for_socketCIP QoS object parameter value
Returns
socket identifier on success -1 on error

create a producing or consuming UDP socket

Parameters
communication_directionConsuming or producing port
socket_dataData for socket creation
Returns
the socket handle if successful, else kEipInvalidSocket

Definition at line 808 of file generic_networkhandler.c.

References CloseSocket(), FreeErrorMessage(), g_current_active_tcp_socket, g_multicast_configuration, g_time_to_live_value, GetErrorMessage(), GetPriorityForSocket(), GetSocketErrorNumber(), highest_socket_handle, kEipStatusError, kUdpCommuncationDirectionConsuming, kUdpCommuncationDirectionProducing, master_socket, OPENER_ASSERT, OPENER_TRACE_ERR, OPENER_TRACE_INFO, SetQosOnSocket(), SetSocketToNonBlocking(), and multicast_address_configuration::starting_multicast_address.

Referenced by OpenConsumingPointToPointConnection(), OpenMulticastConnection(), and OpenProducingPointToPointConnection().

Here is the call graph for this function:

Here is the caller graph for this function:

void HandleApplication ( void  )

Allow the device specific application to perform its execution.

This function will be executed by the stack at the beginning of each execution of EIP_STATUS ManageConnections(void). It allows to implement device specific application functions. Execution within this function should be short.

Definition at line 67 of file sampleapplication.c.

Referenced by ManageConnections().

Here is the caller graph for this function:

EipStatus ResetDevice ( void  )

Emulate as close a possible a power cycle of the device.

Returns
if the service is supported the function will not return. EIP_ERROR if this service is not supported

Definition at line 122 of file sampleapplication.c.

References CloseAllConnections(), and kEipStatusOk.

Referenced by ResetDeviceToInitialConfiguration().

Here is the call graph for this function:

Here is the caller graph for this function:

EipStatus ResetDeviceToInitialConfiguration ( void  )

Reset the device to the initial configuration and emulate as close as possible a power cycle of the device.

Returns
if the service is supported the function will not return. EIP_ERROR if this service is not supported

Definition at line 128 of file sampleapplication.c.

References g_encapsulation_inactivity_timeout, kEipStatusOk, and ResetDevice().

Here is the call graph for this function:

void RunIdleChanged ( EipUint32  run_idle_value)

Inform the application that the Run/Idle State has been changed by the originator.

Parameters
run_idle_valuethe current value of the run/idle flag according to CIP spec Vol 1 3-6.5

Definition at line 146 of file sampleapplication.c.

References CipIdentitySetExtendedDeviceStatus(), kAtLeastOneIoConnectionEstablishedAllInIdleMode, kAtLeastOneIoConnectionInRunMode, and OPENER_TRACE_INFO.

Referenced by HandleReceivedIoConnectionData().

Here is the call graph for this function:

Here is the caller graph for this function:

EipStatus SendUdpData ( struct sockaddr_in *  socket_data,
int  socket_handle,
EipUint8 data,
EipUint16  data_length 
)

Create a producing or consuming UDP socket.

Parameters
socket_dataPointer to the "send to" address
socket_handleSocket descriptor to send on
dataPointer to the data to send
data_lengthLength of the data to send
Returns
kEipStatusOk on success

Definition at line 552 of file generic_networkhandler.c.

References FreeErrorMessage(), GetErrorMessage(), GetSocketErrorNumber(), kEipStatusError, kEipStatusOk, OPENER_TRACE_ERR, OPENER_TRACE_INFO, OPENER_TRACE_WARN, PC_OPENER_ETHERNET_BUFFER_SIZE, UDPHeader::source_port, UDPHeaderCalculateChecksum(), UDPHeaderGenerate(), and UDPHeaderSetChecksum().

Referenced by ManageEncapsulationMessages(), and SendConnectedData().

Here is the call graph for this function:

Here is the caller graph for this function: