From ac6e7845adaa60e92950bf4b533bc4e103ed2e94 Mon Sep 17 00:00:00 2001 From: algin Date: Thu, 8 Jun 2023 12:51:15 +0300 Subject: [PATCH] =?UTF-8?q?feat(UML-1493):=20=D0=94=D0=BE=D0=B1=D0=B0?= =?UTF-8?q?=D0=B2=D0=B8=D0=BB=20=D1=82=D0=B0=D0=B9=D0=BC=D0=B0=D1=83=D1=82?= =?UTF-8?q?=20=D1=87=D1=82=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=B7=D0=B0=D0=BF?= =?UTF-8?q?=D0=B8=D1=81=D0=B8=20PDO?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ethernet_industry/CoE/eth_ecat_pdo_fmmu.hpp | 14 ++++++++++---- .../free_rtos/ethernet_industry/eth_ecat_api.hpp | 8 ++++---- .../ethernet_industry/eth_ecat_custom_promise.hpp | 4 ++-- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/components/free_rtos/ethernet_industry/CoE/eth_ecat_pdo_fmmu.hpp b/components/free_rtos/ethernet_industry/CoE/eth_ecat_pdo_fmmu.hpp index 038787b..3514d25 100644 --- a/components/free_rtos/ethernet_industry/CoE/eth_ecat_pdo_fmmu.hpp +++ b/components/free_rtos/ethernet_industry/CoE/eth_ecat_pdo_fmmu.hpp @@ -81,8 +81,9 @@ public: void process(); template - void pdo_write(address::Offset offset, DataTypes&... data) { + bool pdo_write(uint32_t timeout_ticks, address::Offset offset, DataTypes&... data) { custom_promise::WritePromise promise{offset, data...}; + auto future = promise.get_future(); mutex_write_.lock(); @@ -90,12 +91,15 @@ public: mutex_write_.unlock(); - promise.get_future().get(); + future.get(timeout_ticks); + + return future.is_ready(); } template - void pdo_read(address::Offset offset, DataTypes&... data) { + bool pdo_read(uint32_t timeout_ticks, address::Offset offset, DataTypes&... data) { custom_promise::ReadPromise promise{offset, data...}; + auto future = promise.get_future(); mutex_read_.lock(); @@ -103,7 +107,9 @@ public: mutex_read_.unlock(); - promise.get_future().get(); + future.get(timeout_ticks); + + return future.is_ready(); } diff --git a/components/free_rtos/ethernet_industry/eth_ecat_api.hpp b/components/free_rtos/ethernet_industry/eth_ecat_api.hpp index 42c68c8..d6adbfc 100644 --- a/components/free_rtos/ethernet_industry/eth_ecat_api.hpp +++ b/components/free_rtos/ethernet_industry/eth_ecat_api.hpp @@ -37,13 +37,13 @@ public: } template - static void pdo_write(address::Offset offset, DataTypes&... data) { - get_ecat_pdo_fmmu().pdo_write(offset, data...); + static bool pdo_write(uint32_t timeout_ticks, address::Offset offset, DataTypes&... data) { + return get_ecat_pdo_fmmu().pdo_write(timeout_ticks, offset, data...); } template - static void pdo_read(address::Offset offset, DataTypes&... data) { - get_ecat_pdo_fmmu().pdo_read(offset, data...); + static bool pdo_read(uint32_t timeout_ticks, address::Offset offset, DataTypes&... data) { + return get_ecat_pdo_fmmu().pdo_read(timeout_ticks, offset, data...); } static void pdo_write_async(custom_promise::IPromise& promise) { diff --git a/components/free_rtos/ethernet_industry/eth_ecat_custom_promise.hpp b/components/free_rtos/ethernet_industry/eth_ecat_custom_promise.hpp index 3a7ce6d..ff9727d 100644 --- a/components/free_rtos/ethernet_industry/eth_ecat_custom_promise.hpp +++ b/components/free_rtos/ethernet_industry/eth_ecat_custom_promise.hpp @@ -80,9 +80,9 @@ public: return ready_; } - custom_tuple get() { + custom_tuple get(uint32_t timeout_ticks = SystemP_WAIT_FOREVER) { ready_ = false; - sem_.pend(); + sem_.pend(timeout_ticks); return data_tuple_; }