From 7f65963fc36da7cda9a7c9ae2c9c9d297676f229 Mon Sep 17 00:00:00 2001 From: algin Date: Thu, 8 Jun 2023 14:46:25 +0300 Subject: [PATCH] =?UTF-8?q?feat(UML-1462):=20=D0=94=D0=BE=D0=B1=D0=B0?= =?UTF-8?q?=D0=B2=D0=B8=D0=BB=20=D1=81=D1=87=D0=B5=D1=82=D1=87=D0=B8=D0=BA?= =?UTF-8?q?=20PDO=20=D0=B8=20=D0=BF=D0=BE=D0=BF=D1=80=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D0=B2=D0=B0=D1=80=D0=BD=D0=B8=D0=BD=D0=B3=D0=B8=20?= =?UTF-8?q?=D0=BE=D1=82=20=D0=BB=D0=BE=D0=B3=D0=B8=D1=80=D0=BE=D0=B2=D0=B0?= =?UTF-8?q?=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CoE/eth_ecat_pdo_fmmu.cpp | 2 + .../CoE/eth_ecat_pdo_fmmu.hpp | 6 +++ .../CoE/eth_ecat_sdo_mailbox.cpp | 8 ++-- .../CoE/eth_ecat_sdo_mailbox.hpp | 8 ++-- .../free_rtos/ethernet_industry/eth_ecat.cpp | 40 +++++++++---------- .../free_rtos/ethernet_industry/eth_ecat.hpp | 10 ++--- .../ethernet_industry/eth_ecat_api.hpp | 3 ++ .../ethernet_industry/eth_ecat_buffer.hpp | 8 ++-- .../eth_ecat_custom_promise.hpp | 2 +- components/free_rtos/ethernet_ip/eth_arp.cpp | 2 +- components/free_rtos/ethernet_ip/eth_icmp.cpp | 2 +- components/free_rtos/ethernet_ip/eth_ip.cpp | 2 +- .../free_rtos/ethernet_ip/eth_udp_server.cpp | 2 +- 13 files changed, 53 insertions(+), 42 deletions(-) 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 6e170f0..fec444e 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 @@ -113,6 +113,8 @@ void EthEcatPdoFMMU::process() { process_write_queue(process_data.data(), process_data.size()); write(0, process_data); + + pdo_counter_++; } } 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 3514d25..40a44bf 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 @@ -80,6 +80,10 @@ public: void init(); void process(); + uint32_t get_pdo_counter() { + return pdo_counter_; + } + template bool pdo_write(uint32_t timeout_ticks, address::Offset offset, DataTypes&... data) { custom_promise::WritePromise promise{offset, data...}; @@ -141,6 +145,8 @@ private: custom_promise::WritePromise<> queue_write_{0}; custom_promise::ReadPromise<> queue_read_{0}; + uint32_t pdo_counter_{0}; + void wait_op(); void process_write_queue(uint8_t* process_data, uint32_t len); diff --git a/components/free_rtos/ethernet_industry/CoE/eth_ecat_sdo_mailbox.cpp b/components/free_rtos/ethernet_industry/CoE/eth_ecat_sdo_mailbox.cpp index 4f65ead..c41fd4d 100644 --- a/components/free_rtos/ethernet_industry/CoE/eth_ecat_sdo_mailbox.cpp +++ b/components/free_rtos/ethernet_industry/CoE/eth_ecat_sdo_mailbox.cpp @@ -30,16 +30,16 @@ void EthEcatSdoMailbox::read_pdo_map(uint16_t pdo_map_rx_index, uint16_t pdo_map uint16_t pdo_tx_data_size{0x0000}; ecat_buffer::PDOMap pdo_map; - DebugP_log("Reading rx pdo map\r\n"); + DebugP_log((char*)"Reading rx pdo map\r\n"); pdo_rx_data_size = sdo_mailbox_slave.pdo_map_read(telegram, pdo_map, pdo_map_rx_index); - DebugP_log("Reading tx pdo map\r\n"); + DebugP_log((char*)"Reading tx pdo map\r\n"); pdo_tx_data_size = sdo_mailbox_slave.pdo_map_read(telegram, pdo_map, pdo_map_tx_index); pdo_map_.emplace_back(std::move(pdo_map)); - DebugP_log("pdo_rx_data_size = %d\r\n", pdo_rx_data_size); - DebugP_log("pdo_tx_data_size = %d\r\n", pdo_tx_data_size); + DebugP_log((char*)"pdo_rx_data_size = %d\r\n", pdo_rx_data_size); + DebugP_log((char*)"pdo_tx_data_size = %d\r\n", pdo_tx_data_size); } } diff --git a/components/free_rtos/ethernet_industry/CoE/eth_ecat_sdo_mailbox.hpp b/components/free_rtos/ethernet_industry/CoE/eth_ecat_sdo_mailbox.hpp index 383360e..aca3cbf 100644 --- a/components/free_rtos/ethernet_industry/CoE/eth_ecat_sdo_mailbox.hpp +++ b/components/free_rtos/ethernet_industry/CoE/eth_ecat_sdo_mailbox.hpp @@ -280,7 +280,7 @@ public: if( (elements.coe_header.service != static_cast(Service::SDO_RESPONSE)) || (elements.command_specifier.command_spec != static_cast(SDOReqCommandSpecifier::UPLOAD)) ) { - DebugP_log("CoE error: = 0x%04x\r\n", complete_size.value); // 0x601004 - The object cannot be accessed via complete access + DebugP_log((char*)"CoE error: = 0x%04x\r\n", complete_size.value); // 0x601004 - The object cannot be accessed via complete access } //DebugP_log("elements.coe_header.number = %d\r\n", elements.coe_header.number); @@ -318,7 +318,7 @@ public: if( (elements.coe_header.service != static_cast(Service::SDO_RESPONSE)) || (elements.command_specifier.command_spec != static_cast(SDOReqCommandSpecifier::UPLOAD)) ) { - DebugP_log("CoE error: = 0x%04x\r\n", complete_size.value); // 0x601004 - The object cannot be accessed via complete access + DebugP_log((char*)"CoE error: = 0x%04x\r\n", complete_size.value); // 0x601004 - The object cannot be accessed via complete access } //DebugP_log("elements.coe_header.number = %d\r\n", elements.coe_header.number); @@ -345,7 +345,7 @@ public: sdo_read(telegram, pdo_map_index, 0x00, pdo_block_count); pdo_map.block_index_map[pdo_map_index].emplace(0, pdo_block_count); - DebugP_log("pdo_block_count = 0x%01x\r\n", pdo_block_count); + DebugP_log((char*)"pdo_block_count = 0x%01x\r\n", pdo_block_count); for(uint8_t pdo_map_subindex = 1; pdo_map_subindex < (pdo_block_count + 1); pdo_map_subindex++) { uint16_t pdo_block_index{0x0000}; @@ -363,7 +363,7 @@ public: sdo_read(telegram, pdo_block_index, 0, pdo_block_object_count); pdo_map.object_descriptor_map[pdo_block_index].emplace(0, tmp); - DebugP_log("pdo_block_object_count = 0x%01x\r\n", pdo_block_object_count); + DebugP_log((char*)"pdo_block_object_count = 0x%01x\r\n", pdo_block_object_count); for(uint8_t pdo_block_subindex = 1; pdo_block_subindex < (pdo_block_object_count + 1); pdo_block_subindex++) { ecat_buffer::PDODescriptor descriptor; diff --git a/components/free_rtos/ethernet_industry/eth_ecat.cpp b/components/free_rtos/ethernet_industry/eth_ecat.cpp index cb92e42..787ccea 100644 --- a/components/free_rtos/ethernet_industry/eth_ecat.cpp +++ b/components/free_rtos/ethernet_industry/eth_ecat.cpp @@ -109,19 +109,19 @@ void EthEcat::set_slaves_to_default() { //telegram_.transfer(l); //telegram_.transfer(m); - DebugP_log("a.get_wkc() = %d\r\n", a.get_wkc()); - DebugP_log("b.get_wkc() = %d\r\n", b.get_wkc()); - DebugP_log("c.get_wkc() = %d\r\n", c.get_wkc()); - DebugP_log("d.get_wkc() = %d\r\n", d.get_wkc()); - DebugP_log("e.get_wkc() = %d\r\n", e.get_wkc()); - DebugP_log("f.get_wkc() = %d\r\n", f.get_wkc()); - DebugP_log("g.get_wkc() = %d\r\n", g.get_wkc()); - DebugP_log("h.get_wkc() = %d\r\n", h.get_wkc()); - DebugP_log("i.get_wkc() = %d\r\n", i.get_wkc()); - DebugP_log("j.get_wkc() = %d\r\n", j.get_wkc()); - DebugP_log("k.get_wkc() = %d\r\n", k.get_wkc()); - DebugP_log("l.get_wkc() = %d\r\n", l.get_wkc()); - DebugP_log("m.get_wkc() = %d\r\n", m.get_wkc()); + DebugP_log((char*)"a.get_wkc() = %d\r\n", a.get_wkc()); + DebugP_log((char*)"b.get_wkc() = %d\r\n", b.get_wkc()); + DebugP_log((char*)"c.get_wkc() = %d\r\n", c.get_wkc()); + DebugP_log((char*)"d.get_wkc() = %d\r\n", d.get_wkc()); + DebugP_log((char*)"e.get_wkc() = %d\r\n", e.get_wkc()); + DebugP_log((char*)"f.get_wkc() = %d\r\n", f.get_wkc()); + DebugP_log((char*)"g.get_wkc() = %d\r\n", g.get_wkc()); + DebugP_log((char*)"h.get_wkc() = %d\r\n", h.get_wkc()); + DebugP_log((char*)"i.get_wkc() = %d\r\n", i.get_wkc()); + DebugP_log((char*)"j.get_wkc() = %d\r\n", j.get_wkc()); + DebugP_log((char*)"k.get_wkc() = %d\r\n", k.get_wkc()); + DebugP_log((char*)"l.get_wkc() = %d\r\n", l.get_wkc()); + DebugP_log((char*)"m.get_wkc() = %d\r\n", m.get_wkc()); } uint16_t EthEcat::slaves_detecting() { @@ -184,16 +184,16 @@ void EthEcat::get_addresses_of_slaves() { } while(datagrams[0].get_all_wkc() < number_of_slaves); for(EcatSlave& slave : slaves_) { - DebugP_log("Slave %d address = %d\r\n", -slave.get_slave_address(), slave.get_slave_address()); + DebugP_log((char*)"Slave %d address = %d\r\n", -slave.get_slave_address(), slave.get_slave_address()); } } uint16_t EthEcat::config_init(uint16_t address_base) { - DebugP_log("Initializing slaves...\r\n"); + DebugP_log((char*)"Initializing slaves...\r\n"); set_slaves_to_default(); uint16_t number_of_slaves = slaves_detecting(); - DebugP_log("number_of_slaves = %d\r\n", number_of_slaves); + DebugP_log((char*)"number_of_slaves = %d\r\n", number_of_slaves); set_addresses_of_slaves(number_of_slaves, address_base); get_addresses_of_slaves(); @@ -214,7 +214,7 @@ bool EthEcat::init_to_preop() { success &= slave.init_to_preop(telegram_); } - DebugP_log("success = %d\r\n", success); + DebugP_log((char*)"success = %d\r\n", success); return success; } @@ -226,7 +226,7 @@ bool EthEcat::preop_to_safeop() { success &= slave.preop_to_safeop(telegram_); } - DebugP_log("success = %d\r\n", success); + DebugP_log((char*)"success = %d\r\n", success); return success; } @@ -269,8 +269,8 @@ bool EthEcat::safeop_to_op() { ecat_timer_.Start(); } - DebugP_log("stat.state = %d, stat.fault = %d\r\n", stat.state, stat.fault); - DebugP_log("success = %d\r\n", success); + DebugP_log((char*)"stat.state = %d, stat.fault = %d\r\n", stat.state, stat.fault); + DebugP_log((char*)"success = %d\r\n", success); return success; } diff --git a/components/free_rtos/ethernet_industry/eth_ecat.hpp b/components/free_rtos/ethernet_industry/eth_ecat.hpp index 230aff1..d674ecc 100644 --- a/components/free_rtos/ethernet_industry/eth_ecat.hpp +++ b/components/free_rtos/ethernet_industry/eth_ecat.hpp @@ -90,7 +90,7 @@ public: } while(datagram.get_wkc() < 0x0001); } - DebugP_log("stat.state = %d, stat.fault = %d\r\n", stat.state, stat.fault); + DebugP_log((char*)"stat.state = %d, stat.fault = %d\r\n", stat.state, stat.fault); if((stat.state & 0x0010) != 0) { using TCommand = command::EcatCommand; @@ -133,7 +133,7 @@ public: } while(datagram.get_wkc() < 0x0001); } - DebugP_log("stat.state = %d, stat.fault = %d\r\n", stat.state, stat.fault); + DebugP_log((char*)"stat.state = %d, stat.fault = %d\r\n", stat.state, stat.fault); if((stat.state & 0x0010) != 0) { using TCommand = command::EcatCommand; @@ -145,7 +145,7 @@ public: telegram.transfer(datagram); } while(datagram.get_wkc() < 0x0001); - DebugP_log("stat_code = 0x%02x\r\n", stat_code); + DebugP_log((char*)"stat_code = 0x%02x\r\n", stat_code); } return (stat.state == EC_STATE_SAFE_OP) && (stat.fault == 0); @@ -178,7 +178,7 @@ public: } while(datagram.get_wkc() < 0x0001); } - DebugP_log("stat.state = %d, stat.fault = %d\r\n", stat.state, stat.fault); + DebugP_log((char*)"stat.state = %d, stat.fault = %d\r\n", stat.state, stat.fault); if((stat.state & 0x0010) != 0) { using TCommand = command::EcatCommand; @@ -190,7 +190,7 @@ public: telegram.transfer(datagram); } while(datagram.get_wkc() < 0x0001); - DebugP_log("stat_code = 0x%02x\r\n", stat_code); + DebugP_log((char*)"stat_code = 0x%02x\r\n", stat_code); } return (stat.state == EC_STATE_OPERATIONAL) && (stat.fault == 0); diff --git a/components/free_rtos/ethernet_industry/eth_ecat_api.hpp b/components/free_rtos/ethernet_industry/eth_ecat_api.hpp index d6adbfc..af12e0c 100644 --- a/components/free_rtos/ethernet_industry/eth_ecat_api.hpp +++ b/components/free_rtos/ethernet_industry/eth_ecat_api.hpp @@ -25,6 +25,9 @@ public: static void process(); // Внутри бесконечный цикл. Запускать в отдельном потоке static std::vector& get_ecat_pdo_map(); + static uint32_t get_pdo_counter() { + return get_ecat_pdo_fmmu().get_pdo_counter(); + } template static ecat_sdo_mailbox::CompleteSize sdo_write(size_t slave_index, uint16_t index, uint8_t subindex, DataTypes&... data) { diff --git a/components/free_rtos/ethernet_industry/eth_ecat_buffer.hpp b/components/free_rtos/ethernet_industry/eth_ecat_buffer.hpp index d6772e8..2f1afe8 100644 --- a/components/free_rtos/ethernet_industry/eth_ecat_buffer.hpp +++ b/components/free_rtos/ethernet_industry/eth_ecat_buffer.hpp @@ -163,8 +163,8 @@ public: buffer_regs_[MailboxesRegs::WRITE] = buffer_properties_write_.offset; buffer_regs_[MailboxesRegs::READ] = buffer_properties_read_.offset; - DebugP_log("buffer_properties_write_ = 0x%04x\r\n", buffer_properties_write_); - DebugP_log("buffer_properties_read_ = 0x%04x\r\n", buffer_properties_read_); + DebugP_log((char*)"buffer_properties_write_ = 0x%04x\r\n", buffer_properties_write_); + DebugP_log((char*)"buffer_properties_read_ = 0x%04x\r\n", buffer_properties_read_); } template @@ -202,8 +202,8 @@ public: buffer_regs_[MailboxesRegs::EMPTY] = sync_manager_write.offset + 0x05; buffer_regs_[MailboxesRegs::AVAILABLE] = sync_manager_read.offset + 0x05; - DebugP_log("datagram_write.get_wkc() = %d\r\n", datagram_write.get_wkc()); - DebugP_log("datagram_read.get_wkc() = %d\r\n", datagram_read.get_wkc()); + DebugP_log((char*)"datagram_write.get_wkc() = %d\r\n", datagram_write.get_wkc()); + DebugP_log((char*)"datagram_read.get_wkc() = %d\r\n", datagram_read.get_wkc()); } template 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 ff9727d..9053b89 100644 --- a/components/free_rtos/ethernet_industry/eth_ecat_custom_promise.hpp +++ b/components/free_rtos/ethernet_industry/eth_ecat_custom_promise.hpp @@ -44,7 +44,6 @@ struct DatagramPackFunctor : public PackFunctor { raw = data[data.size() - 1].pack(raw); } }; -*/ // Функтор для обхода и распаковки датаграмм в custom_tuple struct DatagramUnpackFunctor : public UnpackFunctor { @@ -69,6 +68,7 @@ struct DatagramUnpackFunctor : public UnpackFunctor { raw = data[data.size() - 1].unpack(raw); } }; +*/ template class Future { diff --git a/components/free_rtos/ethernet_ip/eth_arp.cpp b/components/free_rtos/ethernet_ip/eth_arp.cpp index 2a8a36a..7ecb722 100644 --- a/components/free_rtos/ethernet_ip/eth_arp.cpp +++ b/components/free_rtos/ethernet_ip/eth_arp.cpp @@ -207,5 +207,5 @@ int32_t free_rtos::EthArp::Process(uint8_t * p_data, uint32_t len) uint32_t free_rtos::EthArp::Sender(uint8_t * p_data, size_t scatter_segment) { - + return 0; } diff --git a/components/free_rtos/ethernet_ip/eth_icmp.cpp b/components/free_rtos/ethernet_ip/eth_icmp.cpp index 780ea35..3a2d3b9 100644 --- a/components/free_rtos/ethernet_ip/eth_icmp.cpp +++ b/components/free_rtos/ethernet_ip/eth_icmp.cpp @@ -42,5 +42,5 @@ int32_t free_rtos::EthIcmp::Process(uint8_t * p_data, uint32_t len) uint32_t free_rtos::EthIcmp::Sender(uint8_t * p_data, size_t scatter_segment) { - + return 0; } diff --git a/components/free_rtos/ethernet_ip/eth_ip.cpp b/components/free_rtos/ethernet_ip/eth_ip.cpp index ca8a9e7..e59205d 100644 --- a/components/free_rtos/ethernet_ip/eth_ip.cpp +++ b/components/free_rtos/ethernet_ip/eth_ip.cpp @@ -72,7 +72,7 @@ int32_t free_rtos::EthIp::Process(uint8_t * p_data, uint32_t len) uint32_t free_rtos::EthIp::Sender(uint8_t * p_data, size_t scatter_segment) { - + return 0; } bool free_rtos::EthIp::send(TEthMacPorts port_id, uint32_t dest_ip, uint8_t prot_id, TEthPkt& pkt) diff --git a/components/free_rtos/ethernet_ip/eth_udp_server.cpp b/components/free_rtos/ethernet_ip/eth_udp_server.cpp index ecd16e7..446e99a 100644 --- a/components/free_rtos/ethernet_ip/eth_udp_server.cpp +++ b/components/free_rtos/ethernet_ip/eth_udp_server.cpp @@ -73,6 +73,6 @@ int32_t free_rtos::EthUdpServer::Process(uint8_t * p_data, uint32_t len) uint32_t free_rtos::EthUdpServer::Sender(uint8_t * p_data, size_t scatter_segment) { - + return 0; }