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 9ab9fcf..033ca14 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 @@ -31,24 +31,26 @@ void EthEcatPdoFMMU::wait_op() { uint32_t logical_full_length_write = ecat_buffer_.get_fmmu_global_properties().logical_full_length_write; uint32_t logical_full_length_read = ecat_buffer_.get_fmmu_global_properties().logical_full_length_read; - std::vector process_data(std::min(logical_full_length_write, logical_full_length_read)); + std::vector pdo_read(logical_full_length_read, 0x00); + std::vector pdo_write(logical_full_length_write, 0x00); + custom_tuple&> data_tuple_read{pdo_read}; + custom_tuple&> data_tuple_write{pdo_write}; + + read(0, pdo_write); // read to pdo_write ! - read(0, process_data); /* for(uint8_t& byte : process_data) { DebugP_log("0x%01x", byte); } DebugP_log("\r\n"); */ - write(0, process_data); + write(0, pdo_write); init_sem.post(); process_sem.pend(); - read(0, process_data); - for(uint32_t i = 0; i < 250; i++) { - read_write(0, 0, process_data); + read_write(0, data_tuple_read, 0, data_tuple_write); //read(0, process_data); /* @@ -108,23 +110,27 @@ void EthEcatPdoFMMU::process() { uint32_t logical_full_length_write = ecat_buffer_.get_fmmu_global_properties().logical_full_length_write; uint32_t logical_full_length_read = ecat_buffer_.get_fmmu_global_properties().logical_full_length_read; - std::vector process_data(std::min(logical_full_length_write, logical_full_length_read)); + std::vector pdo_read(logical_full_length_read, 0x00); + std::vector pdo_write(logical_full_length_write, 0x00); + custom_tuple&> data_tuple_read{pdo_read}; + custom_tuple&> data_tuple_write{pdo_write}; free_rtos::Timer& ecat_timer = ecat_buffer_.get_ecat().get_ecat_timer(); ecat_timer.Wait(); - read(0, process_data); + read(0, pdo_write); // read to pdo_write ! + write(0, pdo_write); while(1) { ecat_timer.Wait(); //DebugP_log("Tick !\r\n"); - read_write(0, 0, process_data); + read_write(0, data_tuple_read, 0, data_tuple_write); //read(0, process_data); - process_read_queue(process_data.data(), process_data.size()); - process_write_queue(process_data.data(), process_data.size()); + process_read_queue(pdo_read.data(), pdo_read.size()); + process_write_queue(pdo_write.data(), pdo_write.size()); //write(0, process_data); @@ -133,7 +139,8 @@ void EthEcatPdoFMMU::process() { } void EthEcatPdoFMMU::process_fake(uint32_t period_microsec = 250) { - std::vector process_data(110); + std::vector pdo_read(110, 0x00); + std::vector pdo_write(110, 0x00); free_rtos::Timer& ecat_timer = ecat_buffer_.get_ecat().get_ecat_timer(); Timer::Settings ecat_tmr_sett = { @@ -152,14 +159,11 @@ void EthEcatPdoFMMU::process_fake(uint32_t period_microsec = 250) { ecat_timer.Wait(); //DebugP_log("Tick !\r\n"); - process_read_queue(process_data.data(), process_data.size()); - process_write_queue(process_data.data(), process_data.size()); + process_read_queue(pdo_read.data(), pdo_read.size()); + process_write_queue(pdo_write.data(), pdo_write.size()); pdo_counter_++; } - - DebugP_log("process_fake terminated\r\n"); - vTaskDelete(NULL); } } 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 73fc7e8..cda86c2 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 @@ -156,7 +156,7 @@ private: } template - void read_write(address::Offset offset_read, address::Offset offset_write, DataTypes&... data) { + void read_write(address::Offset offset_read, custom_tuple data_read, address::Offset offset_write, custom_tuple data_write) { using TDatagramRead = datagram::EcatDatagram; using TDatagramWrite = datagram::EcatDatagram; @@ -164,10 +164,10 @@ private: ecat_buffer::FMMUGlobalProperties& fmmu_global_properties = ecat_buffer_.get_fmmu_global_properties(); address::Logical logical_read = fmmu_global_properties.logical_start_address + fmmu_global_properties.logical_full_length_write + offset_read; - TDatagramRead datagram_read{ {{logical_read}}, data... }; + TDatagramRead datagram_read{ {{logical_read}}, data_read }; address::Logical logical_write = fmmu_global_properties.logical_start_address + offset_write; - TDatagramWrite datagram_write{ {{logical_write}}, data... }; + TDatagramWrite datagram_write{ {{logical_write}}, data_write }; auto queue = datagram_read + datagram_write; diff --git a/components/free_rtos/ethernet_industry/eth_ecat_datagram.hpp b/components/free_rtos/ethernet_industry/eth_ecat_datagram.hpp index f0d7657..2890187 100644 --- a/components/free_rtos/ethernet_industry/eth_ecat_datagram.hpp +++ b/components/free_rtos/ethernet_industry/eth_ecat_datagram.hpp @@ -77,7 +77,10 @@ public: , command_{command} , data_tuple_{data...} { } - EcatDatagram() { } + EcatDatagram(CommandT&& command, custom_tuple data_tuple) + : IEcatDatagram{} + , command_{command} + , data_tuple_{data_tuple} { } ~EcatDatagram() { }