dev(UML-1547): Доработал передачу размера PDO Map

This commit is contained in:
algin 2023-05-23 11:08:25 +03:00
parent b99aff3b7a
commit dea7d4e8d8
3 changed files with 26 additions and 17 deletions

View File

@ -15,13 +15,14 @@ void EthEcatSdoMailbox::init() {
std::vector<ecat_buffer::EcatBufferSlave>& buffer_slaves = ecat_buffer_.get_buffer_slaves();
sdo_mailbox_slaves_.reserve(buffer_slaves.size());
pdo_map_.reserve(buffer_slaves.size());
for(ecat_buffer::EcatBufferSlave& mailbox_slave : buffer_slaves) {
sdo_mailbox_slaves_.push_back(EcatSdoMailboxSlave{mailbox_slave});
}
}
void EthEcatSdoMailbox::pdo_map_read(PDOMap& pdo_map) {
void EthEcatSdoMailbox::pdo_map_read() {
datagram::EcatTelegram& telegram = ecat_buffer_.get_ecat().get_telegram();
uint16_t pdo_map_rx_index{0x1C12};
uint16_t pdo_map_tx_index{0x1C13};
@ -30,17 +31,16 @@ void EthEcatSdoMailbox::pdo_map_read(PDOMap& pdo_map) {
for(EcatSdoMailboxSlave& sdo_mailbox_slave : sdo_mailbox_slaves_) {
DebugP_log("Reading rx pdo map\r\n");
pdo_rx_data_size += sdo_mailbox_slave.pdo_map_read<command::FP>(telegram, pdo_map_rx_index);
pdo_rx_data_size = sdo_mailbox_slave.pdo_map_read<command::FP>(telegram, pdo_map_rx_index);
DebugP_log("Reading tx pdo map\r\n");
pdo_tx_data_size += sdo_mailbox_slave.pdo_map_read<command::FP>(telegram, pdo_map_tx_index);
pdo_tx_data_size = sdo_mailbox_slave.pdo_map_read<command::FP>(telegram, pdo_map_tx_index);
pdo_map_.push_back(ecat_buffer::PDOMap{pdo_rx_data_size, pdo_tx_data_size});
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);
}
pdo_map.rx_data_size = pdo_rx_data_size;
pdo_map.tx_data_size = pdo_tx_data_size;
DebugP_log("pdo_map.rx_data_size = %d\r\n", pdo_map.rx_data_size);
DebugP_log("pdo_map.tx_data_size = %d\r\n", pdo_map.tx_data_size);
}
}

View File

@ -46,11 +46,6 @@ enum class Service : uint16_t {
SDO_INFORMATION
};
struct PDOMap {
uint16_t rx_data_size;
uint16_t tx_data_size;
};
struct PDODescriptor {
uint8_t size;
uint8_t subindex;
@ -385,12 +380,18 @@ public:
EthEcatSdoMailbox(ecat_buffer::EthEcatBuffer& ecat_buffer): ecat_buffer_{ecat_buffer} { }
void init();
void pdo_map_read(PDOMap& map);
void pdo_map_read();
std::vector<ecat_buffer::PDOMap>& get_pdo_map() {
return pdo_map_;
}
private:
ecat_buffer::EthEcatBuffer& ecat_buffer_;
std::vector<EcatSdoMailboxSlave> sdo_mailbox_slaves_;
std::vector<ecat_buffer::PDOMap> pdo_map_;
};
} // namespace ecat_sdo_mailbox

View File

@ -17,6 +17,11 @@ namespace free_rtos {
namespace ecat_buffer {
struct PDOMap {
uint16_t rx_data_size;
uint16_t tx_data_size;
};
struct FMMUSettings {
uint32_t log_start_address;
uint16_t log_data_len;
@ -332,9 +337,12 @@ public:
}
// Размер в байтах !
void set_buffer_length(uint16_t rx_length, uint16_t tx_length) {
void set_buffer_length(std::vector<PDOMap>& pdo_map) {
uint32_t i = 0;
for(EcatBufferSlave& buffer_slave : buffer_slaves_) {
buffer_slave.set_buffer_length(rx_length, tx_length);
buffer_slave.set_buffer_length(pdo_map[i].rx_data_size, pdo_map[i].tx_data_size);
i++;
}
}