From 39ef0906b7024d624e9f2c84df4a9987593e660f Mon Sep 17 00:00:00 2001 From: algin Date: Wed, 20 Sep 2023 15:52:57 +0300 Subject: [PATCH] =?UTF-8?q?fix(SF-33):=20=D0=9E=D1=87=D0=B5=D1=80=D0=B5?= =?UTF-8?q?=D0=B4=D0=BD=D1=8B=D0=B5=20=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D0=B8?= =?UTF-8?q?=20=D1=81=D0=BE=20=D1=81=D1=82=D0=B5=D0=BD=D0=B4=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/free_rtos/ethernet/eth.cpp | 6 +++++- .../ethernet_industry/CoE/eth_ecat_pdo_fmmu.cpp | 4 ++++ .../free_rtos/ethernet_industry/eth_ecat.cpp | 16 ++++++++++++---- .../free_rtos/ethernet_industry/eth_ecat.hpp | 2 +- .../ethernet_industry/eth_ecat_telegram.hpp | 2 +- 5 files changed, 23 insertions(+), 7 deletions(-) diff --git a/components/free_rtos/ethernet/eth.cpp b/components/free_rtos/ethernet/eth.cpp index f33bbee..a73b66b 100644 --- a/components/free_rtos/ethernet/eth.cpp +++ b/components/free_rtos/ethernet/eth.cpp @@ -168,6 +168,10 @@ void free_rtos::Eth::link_task() { for (int i = 0; i < macPortNum_; ++i) { + if(linkUp_[i] == true) { + continue; + } + macPort = macPort_[i]; linkUp = false; @@ -248,7 +252,7 @@ void free_rtos::Eth::link_task() } - ClockP_usleep(100000); // 100ms /// ������ 10�� ���������� ��������� ����� + ClockP_usleep(1000000); // 100ms /// ������ 10�� ���������� ��������� ����� } } diff --git a/components/free_rtos/ethernet_industry/CoE/eth_ecat_pdo_fmmu.cpp b/components/free_rtos/ethernet_industry/CoE/eth_ecat_pdo_fmmu.cpp index e684dd4..ddda647 100644 --- a/components/free_rtos/ethernet_industry/CoE/eth_ecat_pdo_fmmu.cpp +++ b/components/free_rtos/ethernet_industry/CoE/eth_ecat_pdo_fmmu.cpp @@ -28,6 +28,7 @@ void EthEcatPdoFMMU::init(ProcessCallback callback) { bool EthEcatPdoFMMU::wait_op() { free_rtos::Semaphore& init_sem = ecat_buffer_.get_ecat().get_init_sem(); free_rtos::Semaphore& process_sem = ecat_buffer_.get_ecat().get_process_sem(); + free_rtos::Timer& ecat_timer = ecat_buffer_.get_ecat().get_ecat_timer(); process_sem.pend(); @@ -55,6 +56,8 @@ bool EthEcatPdoFMMU::wait_op() { process_sem.pend(); for(uint32_t i = 0; i < 250; i++) { + ecat_timer.Wait(); + status = read_write(0, data_tuple_read, 0, data_tuple_write); if(status != true) { @@ -63,6 +66,7 @@ bool EthEcatPdoFMMU::wait_op() { } init_sem.post(); + process_sem.pend(); return status; } diff --git a/components/free_rtos/ethernet_industry/eth_ecat.cpp b/components/free_rtos/ethernet_industry/eth_ecat.cpp index f500f9c..8d5eccc 100644 --- a/components/free_rtos/ethernet_industry/eth_ecat.cpp +++ b/components/free_rtos/ethernet_industry/eth_ecat.cpp @@ -295,8 +295,12 @@ bool EthEcat::safeop_to_op() { uint16_t zero{0x00000000}; bool status; + ecat_timer_.Start(); + process_sem_.post(); if(init_sem_.pend(process_timeout_ticks_) != SystemP_SUCCESS) { + DebugP_log((char*)"Process task timeout !\r\n"); + return false; } @@ -313,6 +317,8 @@ bool EthEcat::safeop_to_op() { process_sem_.post(); if(init_sem_.pend(process_timeout_ticks_) != SystemP_SUCCESS) { + DebugP_log((char*)"Process task timeout !\r\n"); + return false; } @@ -326,16 +332,18 @@ bool EthEcat::safeop_to_op() { } } - //DebugP_log((char*)"stat.state = %d, stat.fault = %d\r\n", stat.state, stat.fault); - status = (stat.state == EC_STATE_OPERATIONAL) && (stat.fault == 0); - if(status == true) { - ecat_timer_.Start(); + if(status != true) { + DebugP_log((char*)"stat.state = %d, stat.fault = %d\r\n", stat.state, stat.fault); + + return status; } //DebugP_log((char*)"success = %d\r\n", success); + process_sem_.post(); + return status; } diff --git a/components/free_rtos/ethernet_industry/eth_ecat.hpp b/components/free_rtos/ethernet_industry/eth_ecat.hpp index 6594039..154bbde 100644 --- a/components/free_rtos/ethernet_industry/eth_ecat.hpp +++ b/components/free_rtos/ethernet_industry/eth_ecat.hpp @@ -248,7 +248,7 @@ private: e_pktTotal }; - static constexpr uint32_t process_timeout_ticks_ = 100; + static constexpr uint32_t process_timeout_ticks_ = 5000; free_rtos::Timer ecat_timer_; diff --git a/components/free_rtos/ethernet_industry/eth_ecat_telegram.hpp b/components/free_rtos/ethernet_industry/eth_ecat_telegram.hpp index 71e133c..5d7644b 100644 --- a/components/free_rtos/ethernet_industry/eth_ecat_telegram.hpp +++ b/components/free_rtos/ethernet_industry/eth_ecat_telegram.hpp @@ -74,7 +74,7 @@ public: bool transfer(queue::Queue& next); private: - static constexpr uint32_t connection_timeout_ticks_ = 50; + static constexpr uint32_t connection_timeout_ticks_ = 200; static constexpr uint32_t max_transfer_attempts_ = 2; Eth& eth_;