fix(UML-1462): Исправлена передача PDO в одной телеграмме

This commit is contained in:
algin 2023-06-27 10:43:07 +03:00
parent c1f7cb6df4
commit 7f00744ba1
3 changed files with 28 additions and 21 deletions

View File

@ -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_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; uint32_t logical_full_length_read = ecat_buffer_.get_fmmu_global_properties().logical_full_length_read;
std::vector<uint8_t> process_data(std::min(logical_full_length_write, logical_full_length_read)); std::vector<uint8_t> pdo_read(logical_full_length_read, 0x00);
std::vector<uint8_t> pdo_write(logical_full_length_write, 0x00);
custom_tuple<std::vector<uint8_t>&> data_tuple_read{pdo_read};
custom_tuple<std::vector<uint8_t>&> data_tuple_write{pdo_write};
read(0, pdo_write); // read to pdo_write !
read(0, process_data);
/* /*
for(uint8_t& byte : process_data) { for(uint8_t& byte : process_data) {
DebugP_log("0x%01x", byte); DebugP_log("0x%01x", byte);
} }
DebugP_log("\r\n"); DebugP_log("\r\n");
*/ */
write(0, process_data); write(0, pdo_write);
init_sem.post(); init_sem.post();
process_sem.pend(); process_sem.pend();
read(0, process_data);
for(uint32_t i = 0; i < 250; i++) { 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); //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_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; uint32_t logical_full_length_read = ecat_buffer_.get_fmmu_global_properties().logical_full_length_read;
std::vector<uint8_t> process_data(std::min(logical_full_length_write, logical_full_length_read)); std::vector<uint8_t> pdo_read(logical_full_length_read, 0x00);
std::vector<uint8_t> pdo_write(logical_full_length_write, 0x00);
custom_tuple<std::vector<uint8_t>&> data_tuple_read{pdo_read};
custom_tuple<std::vector<uint8_t>&> data_tuple_write{pdo_write};
free_rtos::Timer& ecat_timer = ecat_buffer_.get_ecat().get_ecat_timer(); free_rtos::Timer& ecat_timer = ecat_buffer_.get_ecat().get_ecat_timer();
ecat_timer.Wait(); ecat_timer.Wait();
read(0, process_data); read(0, pdo_write); // read to pdo_write !
write(0, pdo_write);
while(1) { while(1) {
ecat_timer.Wait(); ecat_timer.Wait();
//DebugP_log("Tick !\r\n"); //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); //read(0, process_data);
process_read_queue(process_data.data(), process_data.size()); process_read_queue(pdo_read.data(), pdo_read.size());
process_write_queue(process_data.data(), process_data.size()); process_write_queue(pdo_write.data(), pdo_write.size());
//write(0, process_data); //write(0, process_data);
@ -133,7 +139,8 @@ void EthEcatPdoFMMU::process() {
} }
void EthEcatPdoFMMU::process_fake(uint32_t period_microsec = 250) { void EthEcatPdoFMMU::process_fake(uint32_t period_microsec = 250) {
std::vector<uint8_t> process_data(110); std::vector<uint8_t> pdo_read(110, 0x00);
std::vector<uint8_t> pdo_write(110, 0x00);
free_rtos::Timer& ecat_timer = ecat_buffer_.get_ecat().get_ecat_timer(); free_rtos::Timer& ecat_timer = ecat_buffer_.get_ecat().get_ecat_timer();
Timer::Settings ecat_tmr_sett = { Timer::Settings ecat_tmr_sett = {
@ -152,14 +159,11 @@ void EthEcatPdoFMMU::process_fake(uint32_t period_microsec = 250) {
ecat_timer.Wait(); ecat_timer.Wait();
//DebugP_log("Tick !\r\n"); //DebugP_log("Tick !\r\n");
process_read_queue(process_data.data(), process_data.size()); process_read_queue(pdo_read.data(), pdo_read.size());
process_write_queue(process_data.data(), process_data.size()); process_write_queue(pdo_write.data(), pdo_write.size());
pdo_counter_++; pdo_counter_++;
} }
DebugP_log("process_fake terminated\r\n");
vTaskDelete(NULL);
} }
} }

View File

@ -156,7 +156,7 @@ private:
} }
template<typename... DataTypes> template<typename... DataTypes>
void read_write(address::Offset offset_read, address::Offset offset_write, DataTypes&... data) { void read_write(address::Offset offset_read, custom_tuple<DataTypes&...> data_read, address::Offset offset_write, custom_tuple<DataTypes&...> data_write) {
using TDatagramRead = datagram::EcatDatagram<command::LRD, DataTypes...>; using TDatagramRead = datagram::EcatDatagram<command::LRD, DataTypes...>;
using TDatagramWrite = datagram::EcatDatagram<command::LWR, DataTypes...>; using TDatagramWrite = datagram::EcatDatagram<command::LWR, DataTypes...>;
@ -164,10 +164,10 @@ private:
ecat_buffer::FMMUGlobalProperties& fmmu_global_properties = ecat_buffer_.get_fmmu_global_properties(); 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; 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; 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; auto queue = datagram_read + datagram_write;

View File

@ -77,7 +77,10 @@ public:
, command_{command} , command_{command}
, data_tuple_{data...} { } , data_tuple_{data...} { }
EcatDatagram() { } EcatDatagram(CommandT&& command, custom_tuple<DataTypes&...> data_tuple)
: IEcatDatagram{}
, command_{command}
, data_tuple_{data_tuple} { }
~EcatDatagram() { } ~EcatDatagram() { }