feat(UML-1462): Добавил счетчик PDO и поправил варнинги от логирования

This commit is contained in:
algin 2023-06-08 14:46:25 +03:00
parent ac6e7845ad
commit 7f65963fc3
13 changed files with 53 additions and 42 deletions

View File

@ -113,6 +113,8 @@ void EthEcatPdoFMMU::process() {
process_write_queue(process_data.data(), process_data.size());
write(0, process_data);
pdo_counter_++;
}
}

View File

@ -80,6 +80,10 @@ public:
void init();
void process();
uint32_t get_pdo_counter() {
return pdo_counter_;
}
template<typename... DataTypes>
bool pdo_write(uint32_t timeout_ticks, address::Offset offset, DataTypes&... data) {
custom_promise::WritePromise<DataTypes...> 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);

View File

@ -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<command::FP>(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<command::FP>(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);
}
}

View File

@ -280,7 +280,7 @@ public:
if( (elements.coe_header.service != static_cast<uint8_t>(Service::SDO_RESPONSE)) ||
(elements.command_specifier.command_spec != static_cast<uint8_t>(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<uint8_t>(Service::SDO_RESPONSE)) ||
(elements.command_specifier.command_spec != static_cast<uint8_t>(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<TypeT, uint8_t>(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<TypeT, uint8_t>(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;

View File

@ -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<command::AP>(), slave.get_slave_address<command::FP>());
DebugP_log((char*)"Slave %d address = %d\r\n", -slave.get_slave_address<command::AP>(), slave.get_slave_address<command::FP>());
}
}
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<command::FP>(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<command::FP>(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;
}

View File

@ -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<TypeT, command::RD>;
@ -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<TypeT, command::RD>;
@ -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<TypeT, command::RD>;
@ -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);

View File

@ -25,6 +25,9 @@ public:
static void process(); // Внутри бесконечный цикл. Запускать в отдельном потоке
static std::vector<ecat_buffer::PDOMap>& get_ecat_pdo_map();
static uint32_t get_pdo_counter() {
return get_ecat_pdo_fmmu().get_pdo_counter();
}
template<typename... DataTypes>
static ecat_sdo_mailbox::CompleteSize sdo_write(size_t slave_index, uint16_t index, uint8_t subindex, DataTypes&... data) {

View File

@ -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<typename TypeT>
@ -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<typename TypeT>

View File

@ -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<typename... DataTypes>
class Future {

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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)

View File

@ -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;
}