feat(UML-1462): Добавлен фиктивный process для отладки
This commit is contained in:
parent
9a96d327f6
commit
49ff1af977
@ -64,33 +64,41 @@ void EthEcatPdoFMMU::wait_op() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void EthEcatPdoFMMU::process_write_queue(uint8_t* process_data, uint32_t len) {
|
void EthEcatPdoFMMU::process_write_queue(uint8_t* process_data, uint32_t len) {
|
||||||
|
//DebugP_log("write lock\r\n");
|
||||||
mutex_write_.lock();
|
mutex_write_.lock();
|
||||||
|
|
||||||
auto queue = queue_write_; // Копия очереди
|
auto queue = queue_write_; // Копия очереди
|
||||||
queue_write_.clear();
|
queue_write_.clear();
|
||||||
|
|
||||||
|
//DebugP_log("write unlock\r\n");
|
||||||
mutex_write_.unlock();
|
mutex_write_.unlock();
|
||||||
|
//DebugP_log("queue write dequeue first\r\n");
|
||||||
auto next = queue.dequeue();
|
auto next = queue.dequeue();
|
||||||
|
|
||||||
while(next != nullptr) {
|
while(next != nullptr) {
|
||||||
|
//DebugP_log("set value\r\n");
|
||||||
next->set_value(process_data, len);
|
next->set_value(process_data, len);
|
||||||
|
//DebugP_log("queue write dequeue\r\n");
|
||||||
next = queue.dequeue();
|
next = queue.dequeue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EthEcatPdoFMMU::process_read_queue(uint8_t* process_data, uint32_t len) {
|
void EthEcatPdoFMMU::process_read_queue(uint8_t* process_data, uint32_t len) {
|
||||||
|
//DebugP_log("read lock\r\n");
|
||||||
mutex_read_.lock();
|
mutex_read_.lock();
|
||||||
|
|
||||||
auto queue = queue_read_; // Копия очереди
|
auto queue = queue_read_; // Копия очереди
|
||||||
queue_read_.clear();
|
queue_read_.clear();
|
||||||
|
|
||||||
|
//DebugP_log("read unlock\r\n");
|
||||||
mutex_read_.unlock();
|
mutex_read_.unlock();
|
||||||
|
//DebugP_log("queue read dequeue first\r\n");
|
||||||
auto next = queue.dequeue();
|
auto next = queue.dequeue();
|
||||||
|
|
||||||
while(next != nullptr) {
|
while(next != nullptr) {
|
||||||
|
//DebugP_log("set value\r\n");
|
||||||
next->set_value(process_data, len);
|
next->set_value(process_data, len);
|
||||||
|
//DebugP_log("queue read dequeue\r\n");
|
||||||
next = queue.dequeue();
|
next = queue.dequeue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -114,12 +122,7 @@ void EthEcatPdoFMMU::process() {
|
|||||||
read_write(0, 0, process_data);
|
read_write(0, 0, process_data);
|
||||||
|
|
||||||
//read(0, process_data);
|
//read(0, process_data);
|
||||||
/*
|
|
||||||
for(uint8_t& byte : process_data) {
|
|
||||||
DebugP_log("0x%01x", byte);
|
|
||||||
}
|
|
||||||
DebugP_log("\r\n");
|
|
||||||
*/
|
|
||||||
process_read_queue(process_data.data(), process_data.size());
|
process_read_queue(process_data.data(), process_data.size());
|
||||||
process_write_queue(process_data.data(), process_data.size());
|
process_write_queue(process_data.data(), process_data.size());
|
||||||
|
|
||||||
@ -129,6 +132,36 @@ void EthEcatPdoFMMU::process() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EthEcatPdoFMMU::process_fake(uint32_t period_microsec = 250) {
|
||||||
|
std::vector<uint8_t> process_data(110);
|
||||||
|
free_rtos::Timer& ecat_timer = ecat_buffer_.get_ecat().get_ecat_timer();
|
||||||
|
|
||||||
|
Timer::Settings ecat_tmr_sett = {
|
||||||
|
.input_clk_Hz = 25000000, // 25MHz
|
||||||
|
.base_address = 0x2400000u, // memory mapping,
|
||||||
|
.clock_src_mux_addr = 0x430081B0u, // sysconfig
|
||||||
|
.int_num = 152u, // sysconfig
|
||||||
|
.int_priority = 4, // sysconfig
|
||||||
|
.period_us = period_microsec /// microsec
|
||||||
|
};
|
||||||
|
|
||||||
|
ecat_timer.Init(ecat_tmr_sett);
|
||||||
|
ecat_timer.Start();
|
||||||
|
|
||||||
|
while(1) {
|
||||||
|
ecat_timer.Wait();
|
||||||
|
//DebugP_log("Tick !\r\n");
|
||||||
|
|
||||||
|
process_read_queue(process_data.data(), process_data.size());
|
||||||
|
process_write_queue(process_data.data(), process_data.size());
|
||||||
|
|
||||||
|
pdo_counter_++;
|
||||||
|
}
|
||||||
|
|
||||||
|
DebugP_log("process_fake terminated\r\n");
|
||||||
|
vTaskDelete(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -54,6 +54,7 @@ public:
|
|||||||
|
|
||||||
void init();
|
void init();
|
||||||
void process();
|
void process();
|
||||||
|
void process_fake(uint32_t period_microsec);
|
||||||
|
|
||||||
uint32_t get_pdo_counter() {
|
uint32_t get_pdo_counter() {
|
||||||
return pdo_counter_;
|
return pdo_counter_;
|
||||||
|
|||||||
@ -72,6 +72,10 @@ void EthEcatApi::process() {
|
|||||||
ecat_pdo_fmmu_.process();
|
ecat_pdo_fmmu_.process();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EthEcatApi::process_fake(uint32_t period_microsec = 250) {
|
||||||
|
ecat_pdo_fmmu_.process_fake(period_microsec);
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<ecat_buffer::PDOMap>& EthEcatApi::get_ecat_pdo_map() {
|
std::vector<ecat_buffer::PDOMap>& EthEcatApi::get_ecat_pdo_map() {
|
||||||
return ecat_sdo_mailbox_.get_pdo_map();
|
return ecat_sdo_mailbox_.get_pdo_map();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,6 +9,7 @@
|
|||||||
#define FREE_RTOS_ETHERNET_INDUSTRY_ETH_ECAT_API_HPP_
|
#define FREE_RTOS_ETHERNET_INDUSTRY_ETH_ECAT_API_HPP_
|
||||||
|
|
||||||
#define COMX 1
|
#define COMX 1
|
||||||
|
#define PROCESS_FAKE 1
|
||||||
|
|
||||||
#include "ethernet/eth.hpp"
|
#include "ethernet/eth.hpp"
|
||||||
#include "ethernet_industry/eth_ecat.hpp"
|
#include "ethernet_industry/eth_ecat.hpp"
|
||||||
@ -40,6 +41,7 @@ public:
|
|||||||
|
|
||||||
bool config_init(TEthMacPorts port_id, uint16_t address_base, uint32_t period_microsec);
|
bool config_init(TEthMacPorts port_id, uint16_t address_base, uint32_t period_microsec);
|
||||||
void process(); // Внутри бесконечный цикл. Запускать в отдельном потоке
|
void process(); // Внутри бесконечный цикл. Запускать в отдельном потоке
|
||||||
|
void process_fake(uint32_t period_microsec);
|
||||||
std::vector<ecat_buffer::PDOMap>& get_ecat_pdo_map();
|
std::vector<ecat_buffer::PDOMap>& get_ecat_pdo_map();
|
||||||
|
|
||||||
uint32_t get_pdo_counter() {
|
uint32_t get_pdo_counter() {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user