dev(UML-981): Технический коммит перед отключением электричества
Реализованы колбэки подключения модуля и подмодуля
This commit is contained in:
parent
f7ced70272
commit
359bef516a
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
# игнорирование папок build
|
||||
/src/build
|
||||
/profinet_test/sample_app/build
|
||||
*.bin
|
@ -9,19 +9,21 @@ int main(int argc, char * argv[])
|
||||
};
|
||||
|
||||
ProfinetSettings settings = {
|
||||
.ticks_us = 1000,
|
||||
.EthIface = "enp6s1",
|
||||
.ticks_us = 1000
|
||||
};
|
||||
|
||||
ProfinetDeviceSettings profinet_settings = {
|
||||
.product_name = "P-Net Sample Application",
|
||||
.station_name = "rt-labs-dev",
|
||||
.im_0 = {
|
||||
.vendor_id = 0x0493,
|
||||
.hw_revision = 3,
|
||||
.sw_revision = {
|
||||
.prefix = 'V',
|
||||
.functional_enhancement = 0,
|
||||
.bug_fix = 2,
|
||||
.internal_change = 0,
|
||||
.bug_fix = 2
|
||||
},
|
||||
.revision_counter = 0,
|
||||
.profile_id = 0x1234,
|
||||
@ -46,8 +48,6 @@ int main(int argc, char * argv[])
|
||||
.device_id = 0x0002,
|
||||
.oem_vendor_id = 0xcafe,
|
||||
.oem_device_id = 0xee02,
|
||||
.product_name = "P-Net Sample Application",
|
||||
.station_name = "rt-labs-dev",
|
||||
.send_hello = true,
|
||||
.min_device_interval = 32 //1ms ??
|
||||
};
|
||||
|
@ -1,6 +1,8 @@
|
||||
|
||||
set(SRC_FILES ${SRC_FILES}
|
||||
./profinet/profinet.cpp
|
||||
./profinet/profinet_slot.cpp
|
||||
./profinet/profinet_subslot.cpp
|
||||
./profinet/profinet_cb_alarm_ack_cnf.cpp
|
||||
./profinet/profinet_cb_alarm_cnf.cpp
|
||||
./profinet/profinet_cb_alarm_ind.cpp
|
||||
@ -16,8 +18,6 @@ set(SRC_FILES ${SRC_FILES}
|
||||
./profinet/profinet_cb_signal_led_ind.cpp
|
||||
./profinet/profinet_cb_state_ind.cpp
|
||||
./profinet/profinet_cb_write_ind.cpp
|
||||
./profinet/profinet.cpp
|
||||
./profinet/profinet_slot.cpp
|
||||
./profinet/profinet_subslot.cpp)
|
||||
)
|
||||
|
||||
set(INC_DIRS ${INC_DIRS} ./profinet)
|
@ -256,4 +256,187 @@ bool Profinet::addSlotAndPlugModule(std::shared_ptr<ProfinetSlot>& slot_ptr)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
ProfinetSlot * Profinet::getSlotPtr(uint16_t slot_nbr, uint32_t module_id)
|
||||
{
|
||||
/// 1. Проверить, что слот slot добавлен в конфигурацию
|
||||
if (!m_slots.count(slot_nbr))
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ProfinetSlot * const slot_ptr = m_slots[slot_nbr].get();
|
||||
|
||||
/// 2. Проверить, что в слоте slot идентификатор модуля m_module_id совпадает с module_ident
|
||||
if (slot_ptr->m_module_id != module_id)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return slot_ptr;
|
||||
}
|
||||
|
||||
|
||||
/**\
|
||||
* =========================================================================================
|
||||
* Callbacks
|
||||
* =========================================================================================
|
||||
*/
|
||||
|
||||
int Profinet::callbackStateInd ( uint32_t arep, pnet_event_values_t event)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Profinet::callbackConnectInd ( uint32_t arep, pnet_result_t * p_result)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Profinet::callbackReleaseInd ( uint32_t arep, pnet_result_t * p_result)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Profinet::callbackDcontrolInd ( uint32_t arep,
|
||||
pnet_control_command_t control_command,
|
||||
pnet_result_t * p_result)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Profinet::callbackCcontrolInd ( uint32_t arep, pnet_result_t * p_result)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Profinet::callbackReadInd ( uint32_t arep,
|
||||
uint16_t slot_nbr,
|
||||
uint16_t subslot_nbr,
|
||||
uint16_t idx,
|
||||
uint16_t sequence_number,
|
||||
uint8_t ** pp_read_data,
|
||||
uint16_t * p_read_length,
|
||||
pnet_result_t * p_result)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Profinet::callbackWriteInd ( uint32_t arep,
|
||||
uint16_t slot_nbr,
|
||||
uint16_t subslot_nbr,
|
||||
uint16_t idx,
|
||||
uint16_t sequence_number,
|
||||
uint16_t write_length,
|
||||
const uint8_t * p_write_data,
|
||||
pnet_result_t * p_result)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int Profinet::callbackExpModuleInd ( uint16_t slot, uint32_t module_ident)
|
||||
{
|
||||
ProfinetSlot * const slot_ptr = getSlotPtr(slot, module_ident);
|
||||
/**
|
||||
* @brief Проверка, что слот slot добавлен в конфигурацию и что
|
||||
* идентификатор модуля m_module_id совпадает с module_ident
|
||||
*
|
||||
*/
|
||||
if (slot_ptr == nullptr)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
/// Подключить модуль в слот
|
||||
if (!slot_ptr->plugModule(m_pnet_data))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Profinet::callbackExpSubmoduleInd ( uint16_t slot,
|
||||
uint16_t subslot,
|
||||
uint32_t module_id,
|
||||
uint32_t submodule_id,
|
||||
const pnet_data_cfg_t * p_exp_data)
|
||||
{
|
||||
ProfinetSlot * const slot_ptr = getSlotPtr(slot, module_id);
|
||||
/**
|
||||
* @brief Проверка, что слот slot добавлен в конфигурацию и что
|
||||
* идентификатор модуля m_module_id совпадает с module_ident
|
||||
*
|
||||
*/
|
||||
if (slot_ptr == nullptr)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
/// Проверка, что модуль подключен к слоту
|
||||
if (!slot_ptr->isModulePlugged())
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
ProfinetSubslot * const subslot_ptr = slot_ptr->getSubslotPtr(subslot, submodule_id, p_exp_data);
|
||||
|
||||
/**
|
||||
* Проверка того, что:
|
||||
* - подслот subslot добавлен в конфигурацию слота,
|
||||
* - идентификатор модуля подслота m_module_id совпадает с submodule_id
|
||||
* - конфигурация данных слота совпадает с p_exp_data
|
||||
*/
|
||||
if (subslot_ptr == nullptr)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
/// Подключить подмодуль submodule_id к подслоту subslot
|
||||
if (!subslot_ptr->plugSubmodule(m_pnet_data))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Profinet::callbackNewDataStatusInd ( uint32_t arep,
|
||||
uint32_t crep,
|
||||
uint8_t changes,
|
||||
uint8_t data_status)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Profinet::callbackAlarmInd ( uint32_t arep,
|
||||
const pnet_alarm_argument_t * p_alarm_arg,
|
||||
uint16_t data_len,
|
||||
uint16_t data_usi,
|
||||
const uint8_t * p_data)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Profinet::callbackAlarmCnf ( uint32_t arep, const pnet_pnio_status_t * p_pnio_status)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Profinet::callbackAlarmAckCnf ( uint32_t arep, int res)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Profinet::callbackResetInd ( bool should_reset_application, uint16_t reset_mode)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Profinet::callbackSignalLedInd (bool led_state)
|
||||
{
|
||||
return 0;
|
||||
}
|
@ -1,12 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include "../libs/include/pnet_api.h"
|
||||
#include "../../libs/include/pnet_api.h"
|
||||
#include "profinet_settings.hpp"
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include "profinet_slot.hpp"
|
||||
#include "profinet_serv_data.hpp"
|
||||
#include "profinet_iface.hpp"
|
||||
|
||||
class Profinet {
|
||||
public:
|
||||
@ -27,13 +28,44 @@ private:
|
||||
std::map<uint16_t, std::shared_ptr<ProfinetSlot>> m_slots;
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
* @brief Геттер указателя на слот. Проверяет в конфигурации наличие слота slot_nbr
|
||||
* с правильным module_id
|
||||
*
|
||||
* @param slot_nbr номер слота
|
||||
* @param module_id идентификатор модуля
|
||||
* @return ProfinetSlot* указатель на слот
|
||||
*/
|
||||
ProfinetSlot * getSlotPtr(uint16_t slot_nbr, uint32_t module_id);
|
||||
|
||||
public:
|
||||
/// AREP Application Relationship End Point
|
||||
/**
|
||||
* @brief This application call-back function is called by the Profinet stack on
|
||||
* specific state transitions within the Profinet stack.
|
||||
* @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
|
||||
* 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.
|
||||
*
|
||||
* @param arep In: The AREP.
|
||||
* @param event In: The state transition event. See pnet_event_values_t
|
||||
@ -50,9 +82,7 @@ public:
|
||||
* @return 0 on success.
|
||||
* -1 if an error occurred.
|
||||
*/
|
||||
int callbackConnectInd (
|
||||
uint32_t arep,
|
||||
pnet_result_t * p_result);
|
||||
int callbackConnectInd ( uint32_t arep, pnet_result_t * p_result);
|
||||
|
||||
/**
|
||||
* @brief This application call-back function is called by the Profinet stack on every
|
||||
@ -63,39 +93,31 @@ public:
|
||||
* @return 0 on success.
|
||||
* -1 if an error occurred.
|
||||
*/
|
||||
int callbackReleaseInd (
|
||||
uint32_t arep,
|
||||
pnet_result_t * p_result);
|
||||
int callbackReleaseInd ( uint32_t arep, pnet_result_t * p_result);
|
||||
|
||||
/**
|
||||
* @brief This application call-back function is called by the Profinet stack on every
|
||||
* DControl request from the Profinet controller.
|
||||
*
|
||||
* @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 callbackDcontrolInd (
|
||||
uint32_t arep,
|
||||
pnet_control_command_t control_command,
|
||||
pnet_result_t * p_result);
|
||||
int callbackDcontrolInd ( uint32_t arep,
|
||||
pnet_control_command_t control_command,
|
||||
pnet_result_t * p_result);
|
||||
|
||||
/**
|
||||
* @brief * This application call-back function is called by the Profinet stack on every
|
||||
* CControl confirmation from the Profinet controller.
|
||||
*
|
||||
* @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 callbackCcontrolCnf (
|
||||
uint32_t arep,
|
||||
pnet_result_t * p_result);
|
||||
int callbackCcontrolInd ( uint32_t arep, pnet_result_t * p_result);
|
||||
|
||||
/**
|
||||
* @brief This application call-back function is called by the Profinet stack on every
|
||||
* IODRead request from the Profinet controller which specify an
|
||||
@ -159,9 +181,7 @@ public:
|
||||
* @param module_ident
|
||||
* @return int
|
||||
*/
|
||||
int callbackExpModuleInd (
|
||||
uint16_t slot,
|
||||
uint32_t module_ident);
|
||||
int callbackExpModuleInd ( uint16_t slot, uint32_t module_ident);
|
||||
|
||||
/**
|
||||
* @brief This application call-back function is called by the Profinet stack to
|
||||
@ -179,9 +199,6 @@ public:
|
||||
* -1 if an error occurred.
|
||||
*/
|
||||
int callbackExpSubmoduleInd (
|
||||
pnet_t * net,
|
||||
void * arg,
|
||||
uint32_t api,
|
||||
uint16_t slot,
|
||||
uint16_t subslot,
|
||||
uint32_t module_id,
|
||||
@ -232,11 +249,7 @@ public:
|
||||
* @param p_pnio_status In: Detailed ACK information.
|
||||
* @return 0 on success. Other values are ignored.
|
||||
*/
|
||||
int callbackAlarmCnf (
|
||||
pnet_t * net,
|
||||
void * arg,
|
||||
uint32_t arep,
|
||||
const pnet_pnio_status_t * p_pnio_status);
|
||||
int callbackAlarmCnf ( uint32_t arep, const pnet_pnio_status_t * p_pnio_status);
|
||||
|
||||
/**
|
||||
* @brief This functionality is used for alarms triggered by the IO-controller.
|
||||
@ -248,9 +261,7 @@ public:
|
||||
* side. This is cnf(-).
|
||||
* @return 0 on success. Other values are ignored.
|
||||
*/
|
||||
int callbackAlarmAckCnf (
|
||||
uint32_t arep,
|
||||
int res);
|
||||
int callbackAlarmAckCnf ( uint32_t arep, int res);
|
||||
/**
|
||||
* @brief This application call-back function is called by the Profinet stack on every
|
||||
* reset request (via the DCP "Set" command) from the Profinet controller.
|
||||
@ -260,9 +271,7 @@ public:
|
||||
* @param reset_mode In: Detailed reset information.
|
||||
* @return 0 on success. Other values are ignored.
|
||||
*/
|
||||
int callbackResetInd (
|
||||
bool should_reset_application,
|
||||
uint16_t reset_mode);
|
||||
int callbackResetInd ( bool should_reset_application, uint16_t reset_mode);
|
||||
|
||||
/**
|
||||
* @brief Use this callback to implement control of the LED.
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "./profinet/profinet_cb_alarm_cnf.hpp"
|
||||
#include "./profinet/profinet.hpp"
|
||||
|
||||
int profinet_cb_alarm_cnf (
|
||||
pnet_t * net,
|
||||
@ -6,5 +7,9 @@ int profinet_cb_alarm_cnf (
|
||||
uint32_t arep,
|
||||
const pnet_pnio_status_t * p_pnio_status)
|
||||
{
|
||||
Profinet * const profinet_ptr = static_cast<Profinet*>(arg);
|
||||
|
||||
profinet_ptr->callbackAlarmCnf(arep, p_pnio_status);
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
#include "./profinet/profinet_cb_alarm_ind.hpp"
|
||||
#include "./profinet/profinet.hpp"
|
||||
|
||||
int profinet_cb_alarm_ind (
|
||||
pnet_t * net,
|
||||
@ -9,6 +10,9 @@ int profinet_cb_alarm_ind (
|
||||
uint16_t data_usi,
|
||||
const uint8_t * p_data)
|
||||
{
|
||||
|
||||
Profinet * const profinet_ptr = static_cast<Profinet*>(arg);
|
||||
|
||||
profinet_ptr->callbackAlarmInd(arep, p_alarm_arg, data_len, data_usi, p_data);
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
#include "./profinet/profinet_cb_ccontrol_ind.hpp"
|
||||
#include "./profinet/profinet.hpp"
|
||||
|
||||
int profinet_cb_ccontrol_ind (
|
||||
pnet_t * net,
|
||||
@ -6,6 +7,9 @@ int profinet_cb_ccontrol_ind (
|
||||
uint32_t arep,
|
||||
pnet_result_t * p_result)
|
||||
{
|
||||
Profinet * const profinet_ptr = static_cast<Profinet*>(arg);
|
||||
|
||||
profinet_ptr->callbackCcontrolInd(arep, p_result);
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
#include "./profinet/profinet_cb_connect_ind.hpp"
|
||||
|
||||
#include "./profinet/profinet.hpp"
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
@ -9,11 +9,9 @@ int profinet_cb_connect_ind( pnet_t * net,
|
||||
uint32_t arep,
|
||||
pnet_result_t * p_result)
|
||||
{
|
||||
cout << "profinet_cb_connect_ind: PLC connect indication. AREP:" << arep << endl;
|
||||
/*
|
||||
* Handle the request on an application level.
|
||||
* This is a very simple application which does not need to handle anything.
|
||||
* All the needed information is in the AR data structure.
|
||||
*/
|
||||
Profinet * const profinet_ptr = static_cast<Profinet*>(arg);
|
||||
|
||||
profinet_ptr->callbackConnectInd(arep, p_result);
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
#include "./profinet/profinet.hpp"
|
||||
#include "./profinet/profinet.hpp"
|
||||
|
||||
int profinet_cb_dcontrol_ind (
|
||||
pnet_t * net,
|
||||
@ -7,6 +8,9 @@ int profinet_cb_dcontrol_ind (
|
||||
pnet_control_command_t control_command,
|
||||
pnet_result_t * p_result)
|
||||
{
|
||||
|
||||
Profinet * const profinet_ptr = static_cast<Profinet*>(arg);
|
||||
|
||||
profinet_ptr->callbackDcontrolInd(arep, control_command, p_result);
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
#include "./profinet/profinet_cb_exp_module_ind.hpp"
|
||||
#include "./profinet/profinet.hpp"
|
||||
|
||||
int profinet_cb_exp_module_ind (
|
||||
pnet_t * net,
|
||||
@ -7,5 +8,9 @@ int profinet_cb_exp_module_ind (
|
||||
uint16_t slot,
|
||||
uint32_t module_ident)
|
||||
{
|
||||
Profinet * const profinet_ptr = static_cast<Profinet*>(arg);
|
||||
|
||||
profinet_ptr->callbackExpModuleInd(slot, module_ident);
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
#include "./profinet/profinet_cb_exp_submodule_ind.hpp"
|
||||
#include "./profinet/profinet.hpp"
|
||||
|
||||
int profinet_cb_exp_submodule_ind (
|
||||
pnet_t * net,
|
||||
@ -10,6 +11,9 @@ int profinet_cb_exp_submodule_ind (
|
||||
uint32_t submodule_id,
|
||||
const pnet_data_cfg_t * p_exp_data)
|
||||
{
|
||||
Profinet * const profinet_ptr = static_cast<Profinet*>(arg);
|
||||
|
||||
profinet_ptr->callbackExpSubmoduleInd(slot, subslot, module_id, submodule_id, p_exp_data);
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,4 +1,6 @@
|
||||
#include "./profinet/profinet_cb_new_data_status_ind.hpp"
|
||||
#include "./profinet/profinet.hpp"
|
||||
|
||||
|
||||
int profinet_cb_new_data_status_ind (
|
||||
pnet_t * net,
|
||||
@ -8,6 +10,9 @@ int profinet_cb_new_data_status_ind (
|
||||
uint8_t changes,
|
||||
uint8_t data_status)
|
||||
{
|
||||
|
||||
Profinet * const profinet_ptr = static_cast<Profinet*>(arg);
|
||||
|
||||
profinet_ptr->callbackNewDataStatusInd(arep, crep, changes, data_status);
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
#include "./profinet/profinet_cb_read_ind.hpp"
|
||||
|
||||
#include "./profinet/profinet.hpp"
|
||||
|
||||
int profinet_cb_read_ind (
|
||||
pnet_t * net,
|
||||
@ -14,6 +14,16 @@ int profinet_cb_read_ind (
|
||||
uint16_t * p_read_length,
|
||||
pnet_result_t * p_result)
|
||||
{
|
||||
|
||||
Profinet * const profinet_ptr = static_cast<Profinet*>(arg);
|
||||
|
||||
profinet_ptr->callbackReadInd( arep,
|
||||
slot_nbr,
|
||||
subslot_nbr,
|
||||
idx,
|
||||
sequence_number,
|
||||
pp_read_data,
|
||||
p_read_length,
|
||||
p_result);
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
#include "./profinet/profinet_cb_release_ind.hpp"
|
||||
|
||||
#include "./profinet/profinet.hpp"
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
@ -9,7 +9,9 @@ int profinet_cb_release_ind( pnet_t * net,
|
||||
uint32_t arep,
|
||||
pnet_result_t * p_result)
|
||||
{
|
||||
cout << "profinet_cb_release_ind: PLC release (disconnect) indication. AREP: " << arep << endl;
|
||||
/// По идее погасить светодиод наличия связи
|
||||
Profinet * const profinet_ptr = static_cast<Profinet*>(arg);
|
||||
|
||||
profinet_ptr->callbackReleaseInd(arep, p_result);
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
#include "./profinet/profinet_cb_reset_ind.hpp"
|
||||
#include "./profinet/profinet.hpp"
|
||||
|
||||
int profinet_cb_reset_ind (
|
||||
pnet_t * net,
|
||||
@ -6,6 +7,9 @@ int profinet_cb_reset_ind (
|
||||
bool should_reset_application,
|
||||
uint16_t reset_mode)
|
||||
{
|
||||
Profinet * const profinet_ptr = static_cast<Profinet*>(arg);
|
||||
|
||||
profinet_ptr->callbackResetInd(should_reset_application, reset_mode);
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,7 +1,11 @@
|
||||
#include "./profinet/profinet_cb_signal_led_ind.hpp"
|
||||
#include "./profinet/profinet.hpp"
|
||||
|
||||
int profinet_cb_signal_led_ind (pnet_t * net, void * arg, bool led_state)
|
||||
{
|
||||
Profinet * const profinet_ptr = static_cast<Profinet*>(arg);
|
||||
|
||||
profinet_ptr->callbackSignalLedInd(led_state);
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
#include "./profinet/profinet_cb_state_ind.hpp"
|
||||
#include "./profinet/profinet.hpp"
|
||||
|
||||
int profinet_cb_state_ind (
|
||||
pnet_t * net,
|
||||
@ -6,6 +7,9 @@ int profinet_cb_state_ind (
|
||||
uint32_t arep,
|
||||
pnet_event_values_t event)
|
||||
{
|
||||
|
||||
Profinet * const profinet_ptr = static_cast<Profinet*>(arg);
|
||||
|
||||
profinet_ptr->callbackStateInd(arep, event);
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
#include "./profinet/profinet_cb_write_ind.hpp"
|
||||
#include "./profinet/profinet.hpp"
|
||||
|
||||
int profinet_cb_write_ind (
|
||||
pnet_t * net,
|
||||
@ -13,6 +14,16 @@ int profinet_cb_write_ind (
|
||||
const uint8_t * p_write_data,
|
||||
pnet_result_t * p_result)
|
||||
{
|
||||
|
||||
Profinet * const profinet_ptr = static_cast<Profinet*>(arg);
|
||||
|
||||
profinet_ptr->callbackWriteInd( arep,
|
||||
slot_nbr,
|
||||
subslot_nbr,
|
||||
idx,
|
||||
sequence_number,
|
||||
write_length,
|
||||
p_write_data,
|
||||
p_result);
|
||||
|
||||
return 0;
|
||||
}
|
@ -57,3 +57,28 @@ bool ProfinetSlot::addSubslotAndPlugSubmodule(ProfinetServiceData& pnet_data, st
|
||||
return true;
|
||||
}
|
||||
|
||||
ProfinetSubslot * ProfinetSlot::getSubslotPtr(uint16_t subslot_nbr, uint32_t submodule_id, const pnet_data_cfg_t * const p_data_cfg)
|
||||
{
|
||||
/// Проверка наличия подслота в конфигурации
|
||||
if (!m_subslots.count(subslot_nbr))
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ProfinetSubslot * const subslot_ptr = m_subslots[subslot_nbr].get();
|
||||
/// Проверка совпадения идентификатора подмодуля
|
||||
if (subslot_ptr->m_submodule_id != submodule_id)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
/// Проверка совпадения конфигурации данных
|
||||
if ( (subslot_ptr->m_data_cfg.data_dir != p_data_cfg->data_dir) ||
|
||||
(subslot_ptr->m_data_cfg.insize != p_data_cfg->insize) ||
|
||||
(subslot_ptr->m_data_cfg.outsize != p_data_cfg->outsize)
|
||||
)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return subslot_ptr;
|
||||
}
|
||||
|
@ -44,6 +44,10 @@ public:
|
||||
|
||||
bool addSubslotAndPlugSubmodule(ProfinetServiceData& pnet_data, std::shared_ptr<ProfinetSubslot>& subslot_ptr);
|
||||
|
||||
bool isModulePlugged() { return m_module_plugged; }
|
||||
|
||||
ProfinetSubslot * getSubslotPtr(uint16_t subslot_nbr, uint32_t submodule_id, const pnet_data_cfg_t * const p_data_cfg);
|
||||
|
||||
public:
|
||||
/// Номер слота
|
||||
const uint16_t m_slot_nbr;
|
||||
|
@ -12,7 +12,7 @@
|
||||
* @param subslot InOut: Subslot structure
|
||||
* @param tag InOut: Typically a handle to a submodule
|
||||
*/
|
||||
typedef void (*ProfinetSubslotCallback) (ProfinetSubslot * subslot, void * tag);
|
||||
typedef void (*ProfinetSubslotCallback) (void * subslot, void * tag);
|
||||
|
||||
class ProfinetSubslot
|
||||
{
|
||||
|
@ -1,4 +1,6 @@
|
||||
#include "utils.h"
|
||||
#include "string.h"
|
||||
#include "pnal.h"
|
||||
|
||||
static void utils_copy_ip_to_struct (
|
||||
pnet_cfg_ip_addr_t * destination_struct,
|
||||
@ -120,7 +122,7 @@ int utils_pnet_cfg_init_netifs (
|
||||
uint32_t netmask;
|
||||
uint32_t gateway;
|
||||
|
||||
ret = app_utils_get_netif_namelist (
|
||||
ret = utils_get_netif_namelist (
|
||||
netif_list_str,
|
||||
PNET_MAX_PHYSICAL_PORTS,
|
||||
if_list,
|
||||
|
Loading…
Reference in New Issue
Block a user