From 569b714557318d70085c8ada6d27ddc0d8273ac6 Mon Sep 17 00:00:00 2001 From: Vadim Sychev Date: Wed, 20 Jul 2022 14:21:00 +0300 Subject: [PATCH] =?UTF-8?q?dev(UML-981):=20=D0=94=D0=BE=D0=B1=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=BE=20=D0=BE=D0=BF=D0=B8=D1=81=D0=B0=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=BA=D0=BE=D0=BB=D0=B1=D1=8D=D0=BA=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/profinet/profinet.cpp | 5 ++ src/profinet/profinet.hpp | 10 --- src/profinet/profinet_cb_alarm_ack_cnf.hpp | 24 +++++++ src/profinet/profinet_cb_alarm_cnf.hpp | 22 ++++++ src/profinet/profinet_cb_alarm_ind.hpp | 26 +++++++ src/profinet/profinet_cb_ccontrol_ind.hpp | 33 +++++++++ src/profinet/profinet_cb_connect_ind.cpp | 3 - src/profinet/profinet_cb_connect_ind.hpp | 31 ++++++++ src/profinet/profinet_cb_dcontrol_ind.cpp | 2 +- src/profinet/profinet_cb_dcontrol_ind.hpp | 36 ++++++++++ src/profinet/profinet_cb_exp_module_ind.hpp | 40 +++++++++++ .../profinet_cb_exp_submodule_ind.hpp | 51 +++++++++++++ .../profinet_cb_new_data_status_ind.hpp | 28 ++++++++ src/profinet/profinet_cb_read_ind.hpp | 49 +++++++++++++ src/profinet/profinet_cb_release_ind.hpp | 31 +++++++- src/profinet/profinet_cb_reset_ind.hpp | 72 +++++++++++++++++++ src/profinet/profinet_cb_signal_led_ind.hpp | 26 +++++++ src/profinet/profinet_cb_state_ind.hpp | 37 +++++++++- src/profinet/profinet_cb_write_ind.hpp | 46 ++++++++++++ 19 files changed, 556 insertions(+), 16 deletions(-) diff --git a/src/profinet/profinet.cpp b/src/profinet/profinet.cpp index 80a107f..b2925c2 100644 --- a/src/profinet/profinet.cpp +++ b/src/profinet/profinet.cpp @@ -291,6 +291,11 @@ int Profinet::callbackStateInd ( uint32_t arep, pnet_event_values_t event) int Profinet::callbackConnectInd ( uint32_t arep, pnet_result_t * p_result) { + /** + * @brief По идее здесь ничего не нужно делать + * Если будет возвращено 0, то соединение будет установлено. + * Если будет возвращено значение отличное от 0, то не будет, в этом случае нужно указать p_result. + */ return 0; } diff --git a/src/profinet/profinet.hpp b/src/profinet/profinet.hpp index 370fed3..3b1f39e 100644 --- a/src/profinet/profinet.hpp +++ b/src/profinet/profinet.hpp @@ -7,7 +7,6 @@ #include #include "profinet_slot.hpp" #include "profinet_serv_data.hpp" -#include "profinet_iface.hpp" class Profinet { public: @@ -39,15 +38,6 @@ private: ProfinetSlot * getSlotPtr(uint16_t slot_nbr, uint32_t module_id); public: - /** - * @brief - * AREP - Application Relationship End Point (uint32), - * pretty much an index into an array of AR. - * AR - Application Relation. Consists of several communication relations (CR). - * Typically an IO AR, which is a connection to a PLC, but can also be an - * Supervisor AR. - */ - /** * * Indication to the application that a module is requested by the controller in diff --git a/src/profinet/profinet_cb_alarm_ack_cnf.hpp b/src/profinet/profinet_cb_alarm_ack_cnf.hpp index afd7c1d..6e38810 100644 --- a/src/profinet/profinet_cb_alarm_ack_cnf.hpp +++ b/src/profinet/profinet_cb_alarm_ack_cnf.hpp @@ -2,6 +2,30 @@ #include "../../libs/include/pnet_api.h" +/** + * The controller acknowledges the alarm ACK sent previously. + * + * This functionality is used for alarms triggered by the IO-controller. + * + * It is optional to implement this callback. + * The return value from this call-back function is ignored by the Profinet + * stack. + * + * Контроллер подтверждает отправленный ранее ACK аварийного сигнала. + * + * Эта функциональность используется для аварийных сигналов, запускаемых IO-контроллером. + * + * Реализовать этот обратный вызов необязательно. Возвращаемое значение этой функции обратного вызова игнорируется стеком Profinet. + * + * @param net InOut: The p-net stack instance + * @param arg InOut: User-defined data (not used by p-net) + * @param arep In: The AREP. + * @param res In: 0 if ACK was received by the remote side. + * This is cnf(+). + * -1 if ACK was not received by the remote + * side. This is cnf(-). + * @return 0 on success. Other values are ignored. + */ int profinet_cb_alarm_ack_cnf ( pnet_t * net, void * arg, diff --git a/src/profinet/profinet_cb_alarm_cnf.hpp b/src/profinet/profinet_cb_alarm_cnf.hpp index c4167b9..c318c4d 100644 --- a/src/profinet/profinet_cb_alarm_cnf.hpp +++ b/src/profinet/profinet_cb_alarm_cnf.hpp @@ -2,6 +2,28 @@ #include "../../libs/include/pnet_api.h" +/** + * The controller acknowledges the alarm sent previously. + * It is now possible to send another alarm. + * + * This functionality is used for alarms triggered by the IO-device. + * + * It is optional to implement this callback. + * The return value from this call-back function is ignored by the Profinet + * stack. + * + * Контроллер подтверждает отправленный ранее аварийный сигнал. Теперь можно отправить еще один сигнал тревоги. + * + * Эта функция используется для аварийных сигналов, инициируемых IO-устройством. + * + * Реализовать этот обратный вызов необязательно. Возвращаемое значение этой функции обратного вызова игнорируется стеком Profinet. + * + * @param net InOut: The p-net stack instance + * @param arg InOut: User-defined data (not used by p-net) + * @param arep In: The AREP. + * @param p_pnio_status In: Detailed ACK information. + * @return 0 on success. Other values are ignored. + */ int profinet_cb_alarm_cnf ( pnet_t * net, void * arg, diff --git a/src/profinet/profinet_cb_alarm_ind.hpp b/src/profinet/profinet_cb_alarm_ind.hpp index d86552e..1570204 100644 --- a/src/profinet/profinet_cb_alarm_ind.hpp +++ b/src/profinet/profinet_cb_alarm_ind.hpp @@ -2,6 +2,32 @@ #include "../../libs/include/pnet_api.h" +/** + * The IO-controller has sent an alarm to the device. + * + * This functionality is used for alarms triggered by the IO-controller. + * + * When receiving this indication, the application shall + * respond with \a pnet_alarm_send_ack(), which + * may be called in the context of this callback. + * + * IO-контроллер отправил сигнал тревоги на устройство. + * + * Эта функциональность используется для аварийных сигналов, запускаемых IO-контроллером. + * При получении этого указания приложение должно ответить \a pnet_alarm_send_ack(), которое + * может быть вызвано в контексте этого обратного вызова. + * + * @param net InOut: The p-net stack instance + * @param arg InOut: User-defined data (not used by p-net) + * @param arep In: The AREP. + * @param p_alarm_argument In: The alarm argument (with slot, subslot, + * alarm_type etc) + * @param data_len In: Data length + * @param data_usi In: Alarm USI + * @param p_data In: Alarm data + * @return 0 on success. + * Other values are ignored. + */ int profinet_cb_alarm_ind ( pnet_t * net, void * arg, diff --git a/src/profinet/profinet_cb_ccontrol_ind.hpp b/src/profinet/profinet_cb_ccontrol_ind.hpp index f0a925c..054ecce 100644 --- a/src/profinet/profinet_cb_ccontrol_ind.hpp +++ b/src/profinet/profinet_cb_ccontrol_ind.hpp @@ -2,6 +2,39 @@ #include "../../libs/include/pnet_api.h" + +/** + * Indication to the application that a CControl confirmation was received from + * the controller. Typically this means that the controller has received our + * "Application ready" message. + * + * This application call-back function is called by the Profinet stack on every + * CControl confirmation from the Profinet controller. + * + * The application is not required to take any action. + * The return value from this call-back function is ignored by the Profinet + * stack. In case of error the application should provide error information in + * \a p_result. + * + * It is optional to implement this callback (assumes success?). + * + * Индикация приложению о том, что от контроллера получено подтверждение CControl. Обычно это означает, + * что контроллер получил наше сообщение «Приложение готово». + * + * Эта функция обратного вызова приложения вызывается стеком Profinet при каждом подтверждении CControl от контроллера Profinet. + * + * Приложение не требует никаких действий. Возвращаемое значение этой функции обратного вызова игнорируется стеком Profinet. + * + * В случае ошибки приложение должно предоставить информацию об ошибке в \a p_result. + * + * Реализовать этот обратный вызов необязательно (предполагается успех?). + * + * @param net InOut: The p-net stack instance + * @param arg InOut: User-defined data (not used by p-net) + * @param arep In: The AREP. + * @param p_result Out: Detailed error information. + * @return 0 on success. Other values are ignored. + */ int profinet_cb_ccontrol_ind ( pnet_t * net, void * arg, diff --git a/src/profinet/profinet_cb_connect_ind.cpp b/src/profinet/profinet_cb_connect_ind.cpp index c9a6e55..cd9baec 100644 --- a/src/profinet/profinet_cb_connect_ind.cpp +++ b/src/profinet/profinet_cb_connect_ind.cpp @@ -1,8 +1,5 @@ #include "./profinet/profinet_cb_connect_ind.hpp" #include "./profinet/profinet.hpp" -#include - -using namespace std; int profinet_cb_connect_ind( pnet_t * net, void * arg, diff --git a/src/profinet/profinet_cb_connect_ind.hpp b/src/profinet/profinet_cb_connect_ind.hpp index 646f645..db53214 100644 --- a/src/profinet/profinet_cb_connect_ind.hpp +++ b/src/profinet/profinet_cb_connect_ind.hpp @@ -2,6 +2,37 @@ #include "../../libs/include/pnet_api.h" +/** + * Indication to the application that a Connect request was received from the + * controller. + * + * This application call-back function is called by the Profinet stack on every + * Connect request from the Profinet controller. + * + * The connection will be opened if this function returns 0 (zero) and the stack + * is otherwise able to establish a connection. + * + * If this function returns something other than 0 (zero) then the Connect + * request is refused by the device. In case of error the application should + * provide error information in \a p_result. + * + * It is optional to implement this callback (assumes success if not + * implemented). + * + * Индикация приложению о том, что от контроллера получен запрос на подключение. + * Эта функция обратного вызова приложения вызывается стеком Profinet при каждом запросе Connect от контроллера Profinet. + * Соединение будет открыто, если эта функция вернет 0 (ноль) и стек в противном случае сможет установить соединение. + * Если эта функция возвращает значение, отличное от 0 (нуля), то запрос на подключение отклоняется устройством. + * В случае ошибки приложение должно предоставить информацию об ошибке в p_result. + * Реализовать этот обратный вызов необязательно (предполагается успех, если он не реализован). + * + * @param net InOut: The p-net stack instance + * @param arg InOut: User-defined data (not used by p-net) + * @param arep In: The AREP. + * @param p_result Out: Detailed error information if return != 0. + * @return 0 on success. + * -1 if an error occurred. + */ int profinet_cb_connect_ind( pnet_t * net, void * arg, uint32_t arep, diff --git a/src/profinet/profinet_cb_dcontrol_ind.cpp b/src/profinet/profinet_cb_dcontrol_ind.cpp index d4f114c..70058f4 100644 --- a/src/profinet/profinet_cb_dcontrol_ind.cpp +++ b/src/profinet/profinet_cb_dcontrol_ind.cpp @@ -1,4 +1,4 @@ -#include "./profinet/profinet.hpp" +#include "./profinet/profinet_cb_dcontrol_ind.hpp" #include "./profinet/profinet.hpp" int profinet_cb_dcontrol_ind ( diff --git a/src/profinet/profinet_cb_dcontrol_ind.hpp b/src/profinet/profinet_cb_dcontrol_ind.hpp index 4e5cfa6..f915a16 100644 --- a/src/profinet/profinet_cb_dcontrol_ind.hpp +++ b/src/profinet/profinet_cb_dcontrol_ind.hpp @@ -2,6 +2,42 @@ #include "../../libs/include/pnet_api.h" +/** + * Indication to the application that a DControl request was received from the + * controller. Typically this means that the controller is done writing + * parameters. + * + * This application call-back function is called by the Profinet stack on every + * DControl request from the Profinet controller. + * + * The application is not required to take any action but the function must + * return 0 (zero) for proper function of the stack. If this function returns + * something other than 0 (zero) then the DControl request is refused by the + * device. In case of error the application should provide error information in + * \a p_result. + * + * It is optional to implement this callback (assumes success if not + * implemented). + * + * Индикация приложению о том, что от контроллера получен запрос DControl. Обычно это означает, что контроллер закончил запись параметров. + * + * Эта функция обратного вызова приложения вызывается стеком Profinet при каждом запросе DControl от контроллера Profinet. + * + * От приложения не требуется никаких действий, но функция должна возвращать 0 (ноль) для правильной работы стека. + * Если эта функция возвращает значение, отличное от 0 (нуля), то запрос DControl отклоняется устройством. + * В случае ошибки приложение должно предоставить информацию об ошибке в \a p_result. + * + * Реализовать этот обратный вызов необязательно (предполагается успех, если он не реализован). + * + * + * @param net InOut: The p-net stack instance + * @param arg InOut: User-defined data (not used by p-net) + * @param arep In: The AREP. + * @param control_command In: The DControl command code. + * @param p_result Out: Detailed error information if return != 0. + * @return 0 on success. + * -1 if an error occurred. + */ int profinet_cb_dcontrol_ind ( pnet_t * net, void * arg, diff --git a/src/profinet/profinet_cb_exp_module_ind.hpp b/src/profinet/profinet_cb_exp_module_ind.hpp index a957586..43137db 100644 --- a/src/profinet/profinet_cb_exp_module_ind.hpp +++ b/src/profinet/profinet_cb_exp_module_ind.hpp @@ -2,6 +2,46 @@ #include "../../libs/include/pnet_api.h" +/** + * Indication to the application that a module is requested by the controller in + * a specific slot. + * + * This application call-back function is called by the Profinet stack to + * indicate that the controller has requested the presence of a specific module, + * ident number \a module_ident, in the slot number \a slot. + * + * The application must react to this by configuring itself accordingly (if + * possible) and call function pnet_plug_module() to configure the stack for + * this module. + * + * If the wrong module ident number is plugged then the stack will accept this, + * but signal to the controller that a substitute module is fitted. + * + * This function should return 0 (zero) if a valid module was plugged. Or return + * -1 if the application cannot handle this request. + * + * Индикация приложению о том, что модуль запрошен контроллером в определенном слоте. + * + * Эта функция обратного вызова приложения вызывается стеком Profinet, чтобы указать, что + * контроллер запросил наличие определенного модуля с идентификационным номером \a module_ident в слоте с номером \a slot. + * + * Приложение должно отреагировать на это, соответствующим образом сконфигурировав себя (если это возможно) и вызвать + * функцию pnet_plug_module() для настройки стека для этого модуля. + * + * Если установлен неправильный идентификационный номер модуля, стек примет это, но сигнализирует контроллеру, что установлен + * заменяющий модуль. + * + * Эта функция должна возвращать 0 (ноль), если был подключен допустимый модуль. + * Или верните -1, если приложение не может обработать этот запрос. + * + * @param net InOut: The p-net stack instance + * @param arg InOut: User-defined data (not used by p-net) + * @param api In: The AP identifier. + * @param slot In: The slot number. + * @param module_ident In: The module ident number. + * @return 0 on success. + * -1 if an error occurred. + */ int profinet_cb_exp_module_ind ( pnet_t * net, void * arg, diff --git a/src/profinet/profinet_cb_exp_submodule_ind.hpp b/src/profinet/profinet_cb_exp_submodule_ind.hpp index 3904a3a..d431872 100644 --- a/src/profinet/profinet_cb_exp_submodule_ind.hpp +++ b/src/profinet/profinet_cb_exp_submodule_ind.hpp @@ -2,6 +2,57 @@ #include "../../libs/include/pnet_api.h" +/** + * Indication to the application that a sub-module is requested by the + * controller in a specific sub-slot. + * + * This application call-back function is called by the Profinet stack to + * indicate that the controller has requested the presence of a specific + * sub-module with ident number \a submodule_ident, in the sub-slot number + * \a subslot, with module ident number \a module_ident in slot \a slot. + * + * If a module has not been plugged in the slot \a slot then an automatic plug + * request is issued internally by the stack. + * + * The application must react to this by configuring itself accordingly (if + * possible) and call function \a pnet_plug_submodule() to configure the stack + * with the correct input/output data sizes. + * + * If the wrong sub-module ident number is plugged then the stack will accept + * this, but signal to the controller that a substitute sub-module is fitted. + * + * This function should return 0 (zero) if a valid sub-module was plugged, + * or return -1 if the application cannot handle this request. + * + * Индикация приложению о том, что субмодуль запрошен контроллером в определенном субслоте. + * + * Эта функция обратного вызова приложения вызывается стеком Profinet, чтобы указать, что контроллер + * запросил наличие определенного подмодуля с идентификационным номером \a идентификатор_подмодуля, + * в подслоте с номером подслота \a, с идентификационным номером модуля \a module_ident в слоте \a slot. + * + * Если модуль не был вставлен в слот \a slot, то внутри стека выдается автоматический запрос на вставку. + * + * Приложение должно отреагировать на это, настроив себя соответствующим образом (если это возможно) и + * вызвать функцию \a pnet_plug_submodule() для настройки стека с правильными размерами входных/выходных данных. + * + * Если установлен неправильный идентификационный номер субмодуля, стек примет это, но сигнализирует контроллеру, + * что установлен замещающий субмодуль. + * + * Эта функция должна возвращать 0 (ноль), если был подключен допустимый подмодуль, или возвращать -1, + * если приложение не может обработать этот запрос. + * + * @param net InOut: The p-net stack instance + * @param arg InOut: User-defined data (not used by p-net) + * @param api In: The AP identifier. + * @param slot In: The slot number. + * @param subslot In: The sub-slot number. + * @param module_ident In: The module ident number. + * @param submodule_ident In: The sub-module ident number. + * @param p_exp_data In: The expected data configuration (sizes and + * direction) + * @return 0 on success. + * -1 if an error occurred. + */ int profinet_cb_exp_submodule_ind ( pnet_t * net, void * arg, diff --git a/src/profinet/profinet_cb_new_data_status_ind.hpp b/src/profinet/profinet_cb_new_data_status_ind.hpp index 67ff16b..4fcd5a7 100644 --- a/src/profinet/profinet_cb_new_data_status_ind.hpp +++ b/src/profinet/profinet_cb_new_data_status_ind.hpp @@ -2,6 +2,34 @@ #include "../../libs/include/pnet_api.h" +/** + * Indication to the application that the data status received from the + * controller has changed. + * + * This application call-back function is called by the Profinet stack to + * indicate that the received data status has changed. + * + * The application is not required by the Profinet stack to take any action. It + * may use this information as it wishes. The return value from this call-back + * function is ignored by the Profinet stack. + * + * Индикация приложению, что статус данных, полученных от контроллера, изменился. + * + * Эта функция обратного вызова приложения вызывается стеком Profinet, чтобы указать, что статус полученных данных изменился. + * + * Стек Profinet не требует от приложения каких-либо действий. Он может использовать эту информацию по своему усмотрению. + * Возвращаемое значение этой функции обратного вызова игнорируется стеком Profinet. + * + * @param net InOut: The p-net stack instance + * @param arg InOut: User-defined data (not used by p-net) + * @param arep In: The AREP. + * @param crep In: The CREP. + * @param changes In: The changed bits in the received data status. + * See pnet_data_status_bits_t + * @param data_status In: Current received data status (after changes). + * See pnet_data_status_bits_t + * @return 0 on success. Other values are ignored. + */ int profinet_cb_new_data_status_ind ( pnet_t * net, void * arg, diff --git a/src/profinet/profinet_cb_read_ind.hpp b/src/profinet/profinet_cb_read_ind.hpp index babe3b7..d9dffb6 100644 --- a/src/profinet/profinet_cb_read_ind.hpp +++ b/src/profinet/profinet_cb_read_ind.hpp @@ -2,6 +2,55 @@ #include "../../libs/include/pnet_api.h" +/** + * Indication to the application that an IODRead request was received from the + * controller. + * + * This application call-back function is called by the Profinet stack on every + * IODRead request from the Profinet controller which specify an + * application-specific value of \a idx (0x0000 - 0x7fff). All other values of + * \a idx are handled internally by the Profinet stack. + * + * The application must verify the value of \a idx, and that \a p_read_length is + * large enough. Further, the application must provide a + * pointer to the binary value in \a pp_read_data and the size, in bytes, of the + * binary value in \a p_read_length. + * + * The Profinet stack does not perform any endianness conversion on the binary + * value. + * + * In case of error the application should provide error information in \a + * p_result. + * + * Индикация приложению о том, что от контроллера получен запрос IODRead. + * + * Эта функция обратного вызова приложения вызывается стеком Profinet при каждом запросе IODRead от контроллера Profinet, + * в котором указывается специфичное для приложения значение \a idx (0x0000 - 0x7fff). Все остальные значения \a idx + * обрабатываются внутри стека Profinet. + * + * Приложение должно проверить значение \a idx и достаточно ли велико значение \a p_read_length. + * Кроме того, приложение должно предоставить указатель на двоичное значение в \a pp_read_data и размер в байтах + * двоичного значения в \a p_read_length. + * + * Стек Profinet не выполняет никакого преобразования порядка байтов в двоичном значении. + * + * В случае ошибки приложение должно предоставить информацию об ошибке в \a p_result. + * + * @param net InOut: The p-net stack instance + * @param arg InOut: User-defined data (not used by p-net) + * @param arep In: The AREP. + * @param api In: The AP identifier. + * @param slot In: The slot number. + * @param subslot In: The sub-slot number. + * @param idx In: The data record index. + * @param sequence_number In: The sequence number. + * @param pp_read_data Out: A pointer to the binary value. + * @param p_read_length InOut: The maximum (in) and actual (out) length in + * bytes of the binary value. + * @param p_result Out: Detailed error information if returning != 0 + * @return 0 on success. + * -1 if an error occurred. + */ int profinet_cb_read_ind ( pnet_t * net, void * arg, diff --git a/src/profinet/profinet_cb_release_ind.hpp b/src/profinet/profinet_cb_release_ind.hpp index 1da5f00..55e8c10 100644 --- a/src/profinet/profinet_cb_release_ind.hpp +++ b/src/profinet/profinet_cb_release_ind.hpp @@ -1,7 +1,36 @@ #pragma once #include "../../libs/include/pnet_api.h" - +/** + * Indication to the application that a Release request was received from the + * controller. + * + * This application call-back function is called by the Profinet stack on every + * Release request from the Profinet controller. + * + * The connection will be closed regardless of the return value from this + * function. In case of error the application should provide error information + * in \a p_result. + * + * It is optional to implement this callback (assumes success if not + * implemented). + * + * Индикация приложению о том, что от контроллера получен запрос Release. + * + * Эта функция обратного вызова приложения вызывается стеком Profinet при каждом запросе Release от контроллера Profinet. + * + * Соединение будет закрыто независимо от возвращаемого значения этой функцией. В случае ошибки приложение должно предоставить + * информацию об ошибке в \a p_result. + * + * Реализовать этот обратный вызов необязательно (предполагается успех, если он не реализован). + * + * @param net InOut: The p-net stack instance + * @param arg InOut: User-defined data (not used by p-net) + * @param arep In: The AREP. + * @param p_result Out: Detailed error information if return != 0. + * @return 0 on success. + * -1 if an error occurred. + */ int profinet_cb_release_ind( pnet_t * net, void * arg, uint32_t arep, diff --git a/src/profinet/profinet_cb_reset_ind.hpp b/src/profinet/profinet_cb_reset_ind.hpp index 0688b75..74cce72 100644 --- a/src/profinet/profinet_cb_reset_ind.hpp +++ b/src/profinet/profinet_cb_reset_ind.hpp @@ -2,6 +2,78 @@ #include "../../libs/include/pnet_api.h" +/** + * Indication to the application that a reset request was received from the + * IO-controller. + * + * The IO-controller can ask for communication parameters or application + * data to be reset, or to do a factory reset. + * + * This application call-back function is called by the Profinet stack on every + * reset request (via the DCP "Set" command) from the Profinet controller. + * + * The application should reset the application data if + * \a should_reset_application is true. For other cases this callback is + * triggered for diagnostic reasons. + * + * The return value from this call-back function is ignored by the Profinet + * stack. + * + * It is optional to implement this callback (if you do not have any application + * data that could be reset). + * + * Reset modes: + * * 0: (Power-on reset, not from IO-controller. Will not trigger this.) + * * 1: Reset application data + * * 2: Reset communication parameters (done by the stack) + * * 99: Reset all (factory reset). + * + * The reset modes 1-9 (out of which 1 and 2 are supported here) are defined + * by the Profinet standard. Value 99 is used here to indicate that the + * IO-controller has requested a factory reset via another mechanism. + * + * In order to remain responsive to DCP communication and Ethernet switching, + * the device should not do a hard or soft reset for reset mode 1 or 2. It is + * allowed for the factory reset case (but not mandatory). + * + * No \a arep information is available, as this callback typically is triggered + * when there is no active connection. + * + * Индикация приложению о том, что от IO-контроллера получен запрос на сброс. + * + * Контроллер ввода-вывода может запросить сброс параметров связи или данных приложения или выполнить сброс к заводским настройкам. + * + * Эта функция обратного вызова приложения вызывается стеком Profinet при каждом запросе на сброс (через команду «Set» DCP) + * от контроллера Profinet. + * + * Приложение должно сбросить данные приложения, если \a should_reset_application имеет значение true. В других случаях этот + * обратный вызов запускается по диагностическим причинам. + * + * Возвращаемое значение этой функции обратного вызова игнорируется стеком Profinet. + * + * Реализовать этот обратный вызов необязательно (если у вас нет данных приложения, которые можно было бы сбросить). + * + * Режимы сброса: + * 0: (Сброс при включении питания, а не от IO-контроллера. Это не срабатывает.) + * 1: Сбросить данные приложения + * 2: Сброс параметров связи (выполняется стеком) + * 99: Сбросить все (сброс настроек). + * + * Режимы сброса 1-9 (из которых здесь поддерживаются 1 и 2) определены стандартом Profinet. Здесь используется значение 99, + * чтобы указать, что контроллер ввода-вывода запросил сброс к заводским настройкам с помощью другого механизма. + * + * Чтобы оставаться чувствительным к связи DCP и коммутации Ethernet, устройство не должно выполнять аппаратный + * или программный сброс для режима сброса 1 или 2. Это разрешено для случая сброса к заводским настройкам (но не обязательно). + * + * Информация \a arep недоступна, так как этот обратный вызов обычно запускается при отсутствии активного соединения. + * + * @param net InOut: The p-net stack instance + * @param arg InOut: User-defined data (not used by p-net) + * @param should_reset_application In: True if the user should reset the + * application data. + * @param reset_mode In: Detailed reset information. + * @return 0 on success. Other values are ignored. + */ int profinet_cb_reset_ind ( pnet_t * net, void * arg, diff --git a/src/profinet/profinet_cb_signal_led_ind.hpp b/src/profinet/profinet_cb_signal_led_ind.hpp index 1dcf0b5..b24bf15 100644 --- a/src/profinet/profinet_cb_signal_led_ind.hpp +++ b/src/profinet/profinet_cb_signal_led_ind.hpp @@ -2,4 +2,30 @@ #include "../../libs/include/pnet_api.h" +/** + * Indication to the application that the Profinet signal LED should change + * state. + * + * Use this callback to implement control of the LED. + * + * It is optional to implement this callback (but a compliant Profinet device + * must have a signal LED) + * + * No \a arep information is available, as this callback typically is triggered + * when there is no active connection. + * + * Индикация приложению о том, что сигнальный светодиод Profinet должен изменить состояние. + * + * Используйте этот обратный вызов для реализации управления светодиодом. + * + * Реализовать этот обратный вызов необязательно (но совместимое с Profinet устройство должно иметь сигнальный светодиод). + * + * Информация \a arep недоступна, так как этот обратный вызов обычно запускается при отсутствии активного соединения. + * + * @param net InOut: The p-net stack instance + * @param arg InOut: User-defined data (not used by p-net) + * @param led_state In: True if the signal LED should be on. + * @return 0 on success. + * -1 if an error occurred. Will trigger a log message. + */ int profinet_cb_signal_led_ind (pnet_t * net, void * arg, bool led_state); \ No newline at end of file diff --git a/src/profinet/profinet_cb_state_ind.hpp b/src/profinet/profinet_cb_state_ind.hpp index 18e50dd..5d8a7e6 100644 --- a/src/profinet/profinet_cb_state_ind.hpp +++ b/src/profinet/profinet_cb_state_ind.hpp @@ -1,7 +1,42 @@ #pragma once #include "../../libs/include/pnet_api.h" - +/** + * Indication to the application that a state transition has occurred within the + * Profinet stack. + * + * This application call-back function is called by the Profinet stack on + * specific state transitions within the Profinet stack. + * + * At the very least the application must react to the PNET_EVENT_PRMEND state + * transition. After this event the application must call \a + * pnet_application_ready(), when it has finished its setup and it is ready to + * exchange data. + * + * The return value from this call-back function is ignored by the Profinet + * stack. + * + * It is optional to implement this callback (but then it would be difficult + * to know when to call the \a pnet_application_ready() function). + * + * Указание приложению о том, что в стеке Profinet произошел переход состояния. + * + * Эта функция обратного вызова приложения вызывается стеком Profinet при определенных переходах состояний в стеке Profinet. + * + * По крайней мере, приложение должно реагировать на переход состояния PNET_EVENT_PRMEND. После этого события приложение + * должно вызвать \a pnet_application_ready(), когда оно закончит настройку и будет готово к обмену данными. + * + * Возвращаемое значение этой функции обратного вызова игнорируется стеком Profinet. + * + * Реализовать этот обратный вызов необязательно (но тогда будет трудно понять, когда вызывать функцию \a pnet_application_ready()). + * + * @param net InOut: The p-net stack instance + * @param arg InOut: User-defined data (not used by p-net) + * @param arep In: The AREP. + * @param state In: The state transition event. See + * pnet_event_values_t. + * @return 0 on success. Other values are ignored. + */ int profinet_cb_state_ind( pnet_t * net, void * arg, uint32_t arep, diff --git a/src/profinet/profinet_cb_write_ind.hpp b/src/profinet/profinet_cb_write_ind.hpp index ac32635..412e4e5 100644 --- a/src/profinet/profinet_cb_write_ind.hpp +++ b/src/profinet/profinet_cb_write_ind.hpp @@ -2,6 +2,52 @@ #include "../../libs/include/pnet_api.h" +/** + * Indication to the application that an IODWrite request was received from the + * controller. + * + * This application call-back function is called by the Profinet stack on every + * IODWrite request from the Profinet controller which specify an + * application-specific value of \a idx (0x0000 - 0x7fff). All other values of + * \a idx are handled internally by the Profinet stack. + * + * The application must verify the values of \a idx and \a write_length and save + * (copy) the binary value in \a p_write_data. A future IODRead must return the + * latest written value. + * + * The Profinet stack does not perform any endianness conversion on the binary + * value. + * + * In case of error the application should provide error information in \a + * p_result. + * + * Индикация приложению о том, что от контроллера получен запрос IODWrite. + * + * Эта функция обратного вызова приложения вызывается стеком Profinet при каждом запросе IODWrite от контроллера Profinet, + * в котором указывается специфичное для приложения значение \a idx (0x0000 - 0x7fff). Все остальные значения \a idx + * обрабатываются внутри стека Profinet. + * + * Приложение должно проверить значения \a idx и \a write_length и сохранить (скопировать) двоичное значение в \a p_write_data. + * Будущий IODRead должен возвращать самое последнее записанное значение. + * + * Стек Profinet не выполняет никакого преобразования порядка байтов в двоичном значении. + * + * В случае ошибки приложение должно предоставить информацию об ошибке в \a p_result. + * + * @param net InOut: The p-net stack instance + * @param arg InOut: User-defined data (not used by p-net) + * @param arep In: The AREP. + * @param api In: The API identifier. + * @param slot In: The slot number. + * @param subslot In: The sub-slot number. + * @param idx In: The data record index. + * @param sequence_number In: The sequence number. + * @param write_length In: The length in bytes of the binary value. + * @param p_write_data In: A pointer to the binary value. + * @param p_result Out: Detailed error information if returning != 0 + * @return 0 on success. + * -1 if an error occurred. + */ int profinet_cb_write_ind ( pnet_t * net, void * arg,