OpENer - Open Source EtherNet/IP(TM) I/O Target Stack
2.1
|
These functions have to implemented in order to give the OpENer a method to inform the application on certain state changes. More...
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... | |
These functions have to implemented in order to give the OpENer a method to inform the application on certain state changes.
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.
instance | pointer to the assembly object data was received for |
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().
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().
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.
instance | instance of assembly object that should send data. |
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().
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.
output_assembly_id | the output assembly connection point of the connection |
input_assembly_id | the input assembly connection point of the connection |
io_connection_event | information on the change occurred |
Definition at line 71 of file sampleapplication.c.
Referenced by CloseAllConnectionsForInputWithSameType(), CloseIoConnection(), EstablishIoConnection(), and HandleIoConnectionTimeOut().
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).
number_of_elements | number of elements to allocate |
size_of_element | size in bytes of one element |
Definition at line 137 of file sampleapplication.c.
Referenced by AddCipInstances(), AllocateAttributeMasks(), ConfigureDomainName(), ConfigureHostName(), ConfigureIpMacAddress(), ConfigureNetworkInterface(), CreateAssemblyObject(), CreateCipClass(), and RegisterCipClass().
void CipFree | ( | void * | data | ) |
Free memory allocated by the OpENer.
emulate the common c-library function free
data | pointer to the allocated memory |
Definition at line 142 of file sampleapplication.c.
Referenced by ConfigureDomainName(), ConfigureHostName(), ConfigureIpMacAddress(), ConfigureNetworkInterface(), DeleteAllClasses(), ShutdownAssemblies(), and ShutdownTcpIpInterface().
void CloseSocket | ( | const int | socket_handle | ) |
Close the given socket and clean up the stack.
socket_handle | socket 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().
int CreateUdpSocket | ( | UdpCommuncationDirection | communication_direction, |
struct sockaddr_in * | socket_data, | ||
CipUsint | qos_for_socket | ||
) |
create a producing or consuming UDP socket
communication_direction | kUdpCommunicationDirectionProducing or kUdpCommunicationDirectionConsuming |
socket_data | pointer 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_socket | CIP QoS object parameter value |
create a producing or consuming UDP socket
communication_direction | Consuming or producing port |
socket_data | Data for socket creation |
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().
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().
EipStatus ResetDevice | ( | void | ) |
Emulate as close a possible a power cycle of the device.
Definition at line 122 of file sampleapplication.c.
References CloseAllConnections(), and kEipStatusOk.
Referenced by ResetDeviceToInitialConfiguration().
EipStatus ResetDeviceToInitialConfiguration | ( | void | ) |
Reset the device to the initial configuration and emulate as close as possible a power cycle of the device.
Definition at line 128 of file sampleapplication.c.
References g_encapsulation_inactivity_timeout, kEipStatusOk, and ResetDevice().
void RunIdleChanged | ( | EipUint32 | run_idle_value | ) |
Inform the application that the Run/Idle State has been changed by the originator.
run_idle_value | the 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().
EipStatus SendUdpData | ( | struct sockaddr_in * | socket_data, |
int | socket_handle, | ||
EipUint8 * | data, | ||
EipUint16 | data_length | ||
) |
Create a producing or consuming UDP socket.
socket_data | Pointer to the "send to" address |
socket_handle | Socket descriptor to send on |
data | Pointer to the data to send |
data_length | Length of the data to send |
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().