fix(SF-33): Очередные баг фиксы
This commit is contained in:
parent
09fbc270bd
commit
bb4a206507
@ -153,7 +153,7 @@ private:
|
||||
telegram::EcatTelegram& telegram = ecat_buffer_.get_ecat().get_telegram();
|
||||
ecat_buffer::FMMUGlobalProperties& fmmu_global_properties = ecat_buffer_.get_fmmu_global_properties();
|
||||
address::Logical logical = fmmu_global_properties.logical_start_address + offset;
|
||||
const datagram::TEcatWkc expected_wkc = pdo_fmmu_slaves_.size();
|
||||
const datagram::TEcatWkc expected_wkc = 1;
|
||||
TDatagram datagram{ {{logical}}, expected_wkc, data... };
|
||||
|
||||
return telegram.transfer(datagram);
|
||||
@ -166,7 +166,7 @@ private:
|
||||
telegram::EcatTelegram& telegram = ecat_buffer_.get_ecat().get_telegram();
|
||||
ecat_buffer::FMMUGlobalProperties& fmmu_global_properties = ecat_buffer_.get_fmmu_global_properties();
|
||||
address::Logical logical = fmmu_global_properties.logical_start_address + fmmu_global_properties.logical_full_length_write + offset;
|
||||
const datagram::TEcatWkc expected_wkc = pdo_fmmu_slaves_.size();
|
||||
const datagram::TEcatWkc expected_wkc = 1;
|
||||
TDatagram datagram{ {{logical}}, expected_wkc, data... };
|
||||
|
||||
return telegram.transfer(datagram);
|
||||
|
||||
@ -28,8 +28,6 @@ bool EthEcatSdoMailbox::read_pdo_map(uint16_t pdo_map_rx_index, uint16_t pdo_map
|
||||
bool status = true;
|
||||
|
||||
for(EcatSdoMailboxSlave& sdo_mailbox_slave : sdo_mailbox_slaves_) {
|
||||
uint16_t pdo_rx_data_size{0x0000};
|
||||
uint16_t pdo_tx_data_size{0x0000};
|
||||
ecat_buffer::PDOMap pdo_map;
|
||||
|
||||
DebugP_log((char*)"Reading rx pdo map\r\n");
|
||||
|
||||
@ -256,6 +256,8 @@ public:
|
||||
bool receive(telegram::EcatTelegram& telegram, const datagram::TEcatWkc expected_wkc, DataTypes&... data) {
|
||||
if(wait_available<TypeT>(telegram, expected_wkc) != true) return false;
|
||||
if(receive_data<TypeT, DataTypes...>(telegram, expected_wkc, data...) != true) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
template<typename TypeT, typename... DataTypes>
|
||||
@ -264,6 +266,8 @@ public:
|
||||
if(wait_empty<TypeT>(telegram, expected_wkc) != true) return false;
|
||||
if(send_data<TypeT, DataTypes...>(telegram, expected_wkc, channel, priority, type, data...) != true) return false;
|
||||
if(wait_empty<TypeT>(telegram, expected_wkc) != true) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
template<typename TypeT, typename... DataTypes>
|
||||
@ -366,7 +370,7 @@ public:
|
||||
|
||||
template<typename TypeT>
|
||||
bool pdo_map_read(telegram::EcatTelegram& telegram, const datagram::TEcatWkc expected_wkc, ecat_buffer::PDOMap& pdo_map, uint16_t pdo_map_index) {
|
||||
uint16_t pdo_data_size{0x0000}; // Размер данных в битах !
|
||||
uint16_t pdo_data_size{0x0000}; // Size is in bits !
|
||||
uint8_t pdo_block_count{0x00};
|
||||
bool status;
|
||||
|
||||
@ -393,7 +397,7 @@ public:
|
||||
|
||||
pdo_map.block_index_map[pdo_map_index].emplace(pdo_map_subindex, pdo_block_index);
|
||||
|
||||
DebugP_log("pdo_block_index = 0x02%x\r\n", pdo_block_index);
|
||||
//DebugP_log((char*)"pdo_block_index = 0x02%x\r\n", pdo_block_index);
|
||||
|
||||
ecat_buffer::PDODescriptor tmp;
|
||||
uint8_t& pdo_block_object_count = tmp.size;
|
||||
@ -430,7 +434,7 @@ public:
|
||||
|
||||
pdo_map.data_size_map.emplace(pdo_map_index, pdo_data_size/8);
|
||||
|
||||
DebugP_log("pdo_data_size = %d\r\n", pdo_data_size/8);
|
||||
DebugP_log((char*)"pdo_data_size = %d\r\n", pdo_data_size/8);
|
||||
|
||||
return status;
|
||||
}
|
||||
@ -453,17 +457,17 @@ public:
|
||||
}
|
||||
|
||||
template<typename TypeT, typename... DataTypes>
|
||||
CompleteSize sdo_write(size_t slave_index, uint16_t index, uint8_t subindex, DataTypes&... data) {
|
||||
CompleteSize sdo_write(const datagram::TEcatWkc expected_wkc, size_t slave_index, uint16_t index, uint8_t subindex, DataTypes&... data) {
|
||||
telegram::EcatTelegram& telegram = ecat_buffer_.get_ecat().get_telegram();
|
||||
|
||||
return sdo_mailbox_slaves_[slave_index].sdo_write<TypeT, DataTypes...>(telegram, index, subindex, data...);
|
||||
return sdo_mailbox_slaves_[slave_index].sdo_write<TypeT, DataTypes...>(telegram, expected_wkc, index, subindex, data...);
|
||||
}
|
||||
|
||||
template<typename TypeT, typename... DataTypes>
|
||||
CompleteSize sdo_read(size_t slave_index, uint16_t index, uint8_t subindex, DataTypes&... data) {
|
||||
CompleteSize sdo_read(const datagram::TEcatWkc expected_wkc, size_t slave_index, uint16_t index, uint8_t subindex, DataTypes&... data) {
|
||||
telegram::EcatTelegram& telegram = ecat_buffer_.get_ecat().get_telegram();
|
||||
|
||||
return sdo_mailbox_slaves_[slave_index].sdo_read<TypeT, DataTypes...>(telegram, index, subindex, data...);
|
||||
return sdo_mailbox_slaves_[slave_index].sdo_read<TypeT, DataTypes...>(telegram, expected_wkc, index, subindex, data...);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@ -218,7 +218,7 @@ bool EthEcat::config_init(uint16_t address_base) {
|
||||
uint16_t number_of_slaves;
|
||||
bool status;
|
||||
|
||||
DebugP_log((char*)"Initializing slaves...\r\n");
|
||||
DebugP_log((char*)"EthercatMaster starting. Initializing slaves...\r\n");
|
||||
|
||||
status = set_slaves_to_default();
|
||||
|
||||
@ -289,19 +289,20 @@ bool EthEcat::preop_to_safeop() {
|
||||
}
|
||||
|
||||
bool EthEcat::safeop_to_op() {
|
||||
const uint16_t number_of_slaves = slaves_.size();
|
||||
bool status;
|
||||
|
||||
const datagram::TEcatWkc expected_wkc = slaves_.size();
|
||||
address::Broadcast broadcast{0x0000};
|
||||
ALSTAT stat{0x0000, 0x0000};
|
||||
uint16_t zero{0x00000000};
|
||||
bool status;
|
||||
|
||||
process_sem_.post();
|
||||
init_sem_.pend();
|
||||
if(init_sem_.pend(process_timeout_ticks_) != SystemP_SUCCESS) {
|
||||
return false;
|
||||
}
|
||||
|
||||
{
|
||||
uint16_t data{EC_STATE_OPERATIONAL};
|
||||
datagram::EcatDatagram<command::BWR, uint16_t> datagram{ {{broadcast, ECT_REG_ALCTL}}, number_of_slaves, data };
|
||||
datagram::EcatDatagram<command::BWR, uint16_t> datagram{ {{broadcast, ECT_REG_ALCTL}}, expected_wkc, data };
|
||||
|
||||
status = telegram_.transfer(datagram);
|
||||
|
||||
@ -311,10 +312,12 @@ bool EthEcat::safeop_to_op() {
|
||||
}
|
||||
|
||||
process_sem_.post();
|
||||
init_sem_.pend();
|
||||
if(init_sem_.pend(process_timeout_ticks_) != SystemP_SUCCESS) {
|
||||
return false;
|
||||
}
|
||||
|
||||
{
|
||||
datagram::EcatDatagram<command::BRD, ALSTAT, uint16_t> datagram{ {{broadcast, ECT_REG_ALSTAT}}, number_of_slaves, stat, zero };
|
||||
datagram::EcatDatagram<command::BRD, ALSTAT, uint16_t> datagram{ {{broadcast, ECT_REG_ALSTAT}}, expected_wkc, stat, zero };
|
||||
|
||||
status = telegram_.transfer(datagram);
|
||||
|
||||
|
||||
@ -134,7 +134,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
ClockP_usleep(1000000ul);
|
||||
ClockP_usleep(1500000ul);
|
||||
|
||||
{
|
||||
using TCommand = command::EcatCommand<TypeT, command::RD>;
|
||||
@ -248,6 +248,8 @@ private:
|
||||
e_pktTotal
|
||||
};
|
||||
|
||||
static constexpr uint32_t process_timeout_ticks_ = 100;
|
||||
|
||||
free_rtos::Timer ecat_timer_;
|
||||
|
||||
free_rtos::Semaphore rx_sem_;
|
||||
|
||||
@ -10,7 +10,6 @@
|
||||
namespace free_rtos {
|
||||
|
||||
bool EthEcatApi::config_init(TEthMacPorts port_id, uint16_t address_base, uint32_t period_microsec, ecat_pdo_fmmu::ProcessCallback callback) {
|
||||
uint16_t number_of_slaves;
|
||||
bool status = false;
|
||||
|
||||
ecat_.Init(port_id, period_microsec);
|
||||
@ -18,36 +17,48 @@ bool EthEcatApi::config_init(TEthMacPorts port_id, uint16_t address_base, uint32
|
||||
status = ecat_.config_init(address_base);
|
||||
|
||||
if(status != true) {
|
||||
DebugP_log((char*)"config_init() failed");
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
status = ecat_buffer_sdo_.init(ECT_SII_RXMBXADR, ECT_SII_TXMBXADR);
|
||||
|
||||
if(status != true) {
|
||||
DebugP_log((char*)"ecat_buffer_sdo_.init() failed");
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
status = ecat_buffer_sdo_.init_sync_manager(sync_manager::SYNC_M0, sync_manager::SYNC_M1);
|
||||
|
||||
if(status != true) {
|
||||
DebugP_log((char*)"ecat_buffer_sdo_.init_sync_manager() failed");
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
status = ecat_buffer_pdo_.init(ECT_PDOOUTPUTADR, ECT_PDOINPUTADR);
|
||||
|
||||
if(status != true) {
|
||||
DebugP_log((char*)"ecat_buffer_pdo_.init() failed");
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
status = ecat_.enable_PDI();
|
||||
|
||||
if(status != true) {
|
||||
DebugP_log((char*)"ecat_.enable_PDI() failed");
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
status = ecat_.init_to_preop();
|
||||
|
||||
if(status != true) {
|
||||
DebugP_log((char*)"ecat_.init_to_preop() failed");
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
@ -55,6 +66,8 @@ bool EthEcatApi::config_init(TEthMacPorts port_id, uint16_t address_base, uint32
|
||||
status = ecat_sdo_mailbox_.read_pdo_map(ECT_RXPDOMAPINDEX, ECT_TXPDOMAPINDEX);
|
||||
|
||||
if(status != true) {
|
||||
DebugP_log((char*)"ecat_sdo_mailbox_.read_pdo_map() failed");
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
@ -67,12 +80,16 @@ bool EthEcatApi::config_init(TEthMacPorts port_id, uint16_t address_base, uint32
|
||||
status = ecat_buffer_pdo_.init_sync_manager(sync_manager::SYNC_M2, sync_manager::SYNC_M3);
|
||||
|
||||
if(status != true) {
|
||||
DebugP_log((char*)"ecat_buffer_pdo_.init_sync_manager() failed");
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
status = ecat_buffer_pdo_.init_fmmu(fmmu::FMMU0, fmmu::FMMU1);
|
||||
|
||||
if(status != true) {
|
||||
DebugP_log((char*)"ecat_buffer_pdo_.init_fmmu() failed");
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
@ -81,12 +98,16 @@ bool EthEcatApi::config_init(TEthMacPorts port_id, uint16_t address_base, uint32
|
||||
status = ecat_.preop_to_safeop();
|
||||
|
||||
if(status != true) {
|
||||
DebugP_log((char*)"ecat_.preop_to_safeop() failed");
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
status = ecat_.safeop_to_op();
|
||||
|
||||
if(status != true) {
|
||||
DebugP_log((char*)"ecat_.safeop_to_op() failed");
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
@ -187,8 +187,8 @@ public:
|
||||
buffer_regs_[MailboxesRegs::WRITE] = buffer_properties_write_.offset;
|
||||
buffer_regs_[MailboxesRegs::READ] = buffer_properties_read_.offset;
|
||||
|
||||
//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_);
|
||||
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_);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
@ -125,16 +125,6 @@ public:
|
||||
, command_{command}
|
||||
, data_tuple_{data_tuple} { }
|
||||
|
||||
EcatDatagram(CommandT&& command, DataTypes&... data)
|
||||
: IEcatDatagram{}
|
||||
, command_{command}
|
||||
, data_tuple_{data...} { }
|
||||
|
||||
EcatDatagram(CommandT&& command, custom_tuple<DataTypes&...> data_tuple)
|
||||
: IEcatDatagram{}
|
||||
, command_{command}
|
||||
, data_tuple_{data_tuple} { }
|
||||
|
||||
~EcatDatagram() { }
|
||||
|
||||
virtual uint8_t* pack(uint8_t *raw) override {
|
||||
|
||||
@ -58,20 +58,72 @@ public:
|
||||
|
||||
template<typename TypeT, typename... DataTypes>
|
||||
bool read(const datagram::TEcatWkc expected_wkc, typename TypeT::TSlaveAddress& slave_address, uint16_t eeprom_address, DataTypes&... data) {
|
||||
if(wait_busy<TypeT>(expected_wkc, slave_address) != true) return false;
|
||||
if(control_register<TypeT>(expected_wkc, slave_address, EC_ECMD_READ, eeprom_address) != true) return false;
|
||||
if(wait_busy<TypeT>(expected_wkc, slave_address) != true) return false;
|
||||
if(data_register<TypeT, command::RD, DataTypes...>(expected_wkc, slave_address, data...) != true) return false;
|
||||
if(wait_busy<TypeT>(expected_wkc, slave_address) != true) return false;
|
||||
if(wait_busy<TypeT>(expected_wkc, slave_address) != true) {
|
||||
DebugP_log((char*)"read, wait_busy() failed\r\n");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if(control_register<TypeT>(expected_wkc, slave_address, EC_ECMD_READ, eeprom_address) != true) {
|
||||
DebugP_log((char*)"read, control_register() is failed\r\n");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if(wait_busy<TypeT>(expected_wkc, slave_address) != true) {
|
||||
DebugP_log((char*)"read, wait_busy() failed\r\n");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if(data_register<TypeT, command::RD, DataTypes...>(expected_wkc, slave_address, data...) != true) {
|
||||
DebugP_log((char*)"read, data_register() failed\r\n");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if(wait_busy<TypeT>(expected_wkc, slave_address) != true){
|
||||
DebugP_log((char*)"read, wait_busy() failed\r\n");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
// 2 bytes (1 word) max
|
||||
template<typename TypeT, typename... DataTypes>
|
||||
bool write(const datagram::TEcatWkc expected_wkc, typename TypeT::TSlaveAddress& slave_address, uint16_t eeprom_address, DataTypes&... data) {
|
||||
if(wait_busy<TypeT>(expected_wkc, slave_address) != true) return false;
|
||||
if(data_register<TypeT, command::WR, DataTypes...>(expected_wkc, slave_address, data...) != true) return false;
|
||||
if(wait_busy<TypeT>(expected_wkc, slave_address) != true) return false;
|
||||
if(control_register<TypeT>( expected_wkc, slave_address, EC_ECMD_WRITE, eeprom_address) != true) return false;
|
||||
if(wait_busy<TypeT>(expected_wkc, slave_address) != true) return false;
|
||||
if(wait_busy<TypeT>(expected_wkc, slave_address) != true) {
|
||||
DebugP_log((char*)"write, wait_busy() failed\r\n");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if(data_register<TypeT, command::WR, DataTypes...>(expected_wkc, slave_address, data...) != true) {
|
||||
DebugP_log((char*)"write, data_register() failed\r\n");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if(wait_busy<TypeT>(expected_wkc, slave_address) != true) {
|
||||
DebugP_log((char*)"write, wait_busy() failed\r\n");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if(control_register<TypeT>( expected_wkc, slave_address, EC_ECMD_WRITE, eeprom_address) != true) {
|
||||
DebugP_log((char*)"write, control_register() is failed\r\n");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if(wait_busy<TypeT>(expected_wkc, slave_address) != true) {
|
||||
DebugP_log((char*)"write, wait_busy() failed\r\n");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@ -99,7 +99,6 @@ bool EcatTelegram::transfer() {
|
||||
uint32_t transfer_attempts = 0;
|
||||
bool stat;
|
||||
bool as_expected;
|
||||
int status;
|
||||
|
||||
if(first == nullptr) {
|
||||
status_.result = EcatTelegramResult::SUCCESS;
|
||||
@ -135,9 +134,7 @@ bool EcatTelegram::transfer() {
|
||||
continue;
|
||||
}
|
||||
|
||||
status = rx_sem_.pend(connection_timeout_ticks_);
|
||||
|
||||
if(status != SystemP_SUCCESS) {
|
||||
if(rx_sem_.pend(connection_timeout_ticks_) != SystemP_SUCCESS) {
|
||||
status_.transfer_errors++;
|
||||
status_.result = EcatTelegramResult::WARNING_TIMEOUT_ERROR;
|
||||
|
||||
|
||||
@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<configurations XML_version="1.2" id="configurations_0">
|
||||
<configuration XML_version="1.2" id="configuration_0">
|
||||
<instance XML_version="1.2" desc="Texas Instruments XDS110 USB Debug Probe" href="connections/TIXDS110_Connection.xml" id="Texas Instruments XDS110 USB Debug Probe" xml="TIXDS110_Connection.xml" xmlpath="connections"/>
|
||||
<connection XML_version="1.2" id="Texas Instruments XDS110 USB Debug Probe">
|
||||
<instance XML_version="1.2" href="drivers/tixds510cs_dap.xml" id="drivers" xml="tixds510cs_dap.xml" xmlpath="drivers"/>
|
||||
<instance XML_version="1.2" href="drivers/tixds510cortexA53.xml" id="drivers" xml="tixds510cortexA53.xml" xmlpath="drivers"/>
|
||||
<instance XML_version="1.2" href="drivers/tixds510cortexR.xml" id="drivers" xml="tixds510cortexR.xml" xmlpath="drivers"/>
|
||||
<instance XML_version="1.2" href="drivers/tixds510cortexM.xml" id="drivers" xml="tixds510cortexM.xml" xmlpath="drivers"/>
|
||||
<instance XML_version="1.2" href="drivers/tixds510pru.xml" id="drivers" xml="tixds510pru.xml" xmlpath="drivers"/>
|
||||
<instance XML_version="1.2" href="drivers/tixds510csstm.xml" id="drivers" xml="tixds510csstm.xml" xmlpath="drivers"/>
|
||||
<instance XML_version="1.2" href="drivers/tixds510ctset2.xml" id="drivers" xml="tixds510ctset2.xml" xmlpath="drivers"/>
|
||||
<instance XML_version="1.2" href="drivers/tixds510etbcs.xml" id="drivers" xml="tixds510etbcs.xml" xmlpath="drivers"/>
|
||||
<platform XML_version="1.2" id="platform_0">
|
||||
<instance XML_version="1.2" desc="AM64x" href="devices/AM64x.xml" id="AM64x" xml="AM64x.xml" xmlpath="devices"/>
|
||||
</platform>
|
||||
</connection>
|
||||
</configuration>
|
||||
</configurations>
|
||||
Loading…
Reference in New Issue
Block a user