fix(UML-1462): Исправил баги при получении и распаковке данных
This commit is contained in:
parent
7f65963fc3
commit
64e4f695f8
@ -65,7 +65,7 @@ void EthEcatPdoFMMU::process_write_queue(uint8_t* process_data, uint32_t len) {
|
||||
mutex_write_.lock();
|
||||
|
||||
next = queue_write_.get_next();
|
||||
queue_write_.detach();
|
||||
last_write_ = &queue_write_;
|
||||
|
||||
mutex_write_.unlock();
|
||||
|
||||
@ -81,7 +81,7 @@ void EthEcatPdoFMMU::process_read_queue(uint8_t* process_data, uint32_t len) {
|
||||
mutex_read_.lock();
|
||||
|
||||
next = queue_read_.get_next();
|
||||
queue_read_.detach();
|
||||
last_read_ = &queue_read_;
|
||||
|
||||
mutex_read_.unlock();
|
||||
|
||||
|
||||
@ -91,7 +91,8 @@ public:
|
||||
|
||||
mutex_write_.lock();
|
||||
|
||||
queue_write_ + promise;
|
||||
custom_promise::IPromise& last_write = (*last_write_) >> promise;
|
||||
last_write_ = &last_write;
|
||||
|
||||
mutex_write_.unlock();
|
||||
|
||||
@ -107,7 +108,8 @@ public:
|
||||
|
||||
mutex_read_.lock();
|
||||
|
||||
queue_read_ + promise;
|
||||
custom_promise::IPromise& last_read = (*last_read_) >> promise;
|
||||
last_read_ = &last_read;
|
||||
|
||||
mutex_read_.unlock();
|
||||
|
||||
@ -120,16 +122,17 @@ public:
|
||||
void pdo_write_async(custom_promise::IPromise& promise) {
|
||||
mutex_write_.lock();
|
||||
|
||||
queue_write_ + promise;
|
||||
custom_promise::IPromise& last_write = (*last_write_) >> promise;
|
||||
last_write_ = &last_write;
|
||||
|
||||
mutex_write_.unlock();
|
||||
}
|
||||
|
||||
|
||||
void pdo_read_async(custom_promise::IPromise& promise) {
|
||||
mutex_read_.lock();
|
||||
|
||||
queue_read_ + promise;
|
||||
custom_promise::IPromise& last_read = (*last_read_) >> promise;
|
||||
last_read_ = &last_read;
|
||||
|
||||
mutex_read_.unlock();
|
||||
}
|
||||
@ -145,6 +148,9 @@ private:
|
||||
custom_promise::WritePromise<> queue_write_{0};
|
||||
custom_promise::ReadPromise<> queue_read_{0};
|
||||
|
||||
custom_promise::IPromise *last_write_{&queue_write_};
|
||||
custom_promise::IPromise *last_read_{&queue_read_};
|
||||
|
||||
uint32_t pdo_counter_{0};
|
||||
|
||||
void wait_op();
|
||||
|
||||
@ -95,7 +95,11 @@ void EthEcat::set_slaves_to_default() {
|
||||
datagram::EcatDatagram<command::BWR, uint8_t> m{ {{broadcast, ECT_REG_EEPCFG}}, m_data_out };
|
||||
|
||||
a + b + c + d + e + f + g + h + i + j + k + l + m;
|
||||
telegram_.transfer(a);
|
||||
|
||||
do {
|
||||
telegram_.transfer(a);
|
||||
} while(a.get_all_wkc() < 0x0001);
|
||||
|
||||
//telegram_.transfer(b);
|
||||
//telegram_.transfer(c);
|
||||
//telegram_.transfer(d);
|
||||
|
||||
@ -136,8 +136,10 @@ public:
|
||||
return next;
|
||||
}
|
||||
|
||||
void detach() {
|
||||
queue_entity_.detach();
|
||||
IPromise& operator>>(IPromise &next) {
|
||||
queue_entity_ >> next.get_queue_entity();
|
||||
|
||||
return next;
|
||||
}
|
||||
|
||||
virtual void set_value(uint8_t* process_data, uint32_t len) = 0;
|
||||
|
||||
@ -56,10 +56,12 @@ public:
|
||||
return next;
|
||||
}
|
||||
|
||||
void detach() {
|
||||
more_ = ec_moredatagrams::EC_MOREDATAGRAMS_LAST;
|
||||
IEcatDatagram& operator>>(IEcatDatagram &next) {
|
||||
more_ = ec_moredatagrams::EC_MOREDATAGRAMS_MORE;
|
||||
|
||||
queue_entity_.detach();
|
||||
queue_entity_ >> next.get_queue_entity();
|
||||
|
||||
return next;
|
||||
}
|
||||
|
||||
virtual uint8_t* pack(uint8_t *raw) = 0;
|
||||
@ -166,7 +168,7 @@ private:
|
||||
|
||||
for_each(data_tuple_, functor);
|
||||
|
||||
return functor.raw;
|
||||
return unpack_wkc(functor.raw);
|
||||
}
|
||||
|
||||
uint8_t* unpack_header(uint8_t *raw) {
|
||||
|
||||
@ -26,6 +26,8 @@ struct PackFunctorBase {
|
||||
(void)data_p;
|
||||
|
||||
raw += sizeof(DataT);
|
||||
|
||||
//DebugP_log((char*)"Data packed: %d\r\n", sizeof(DataT));
|
||||
}
|
||||
|
||||
void operator()() { }
|
||||
@ -62,6 +64,8 @@ struct UnpackFunctorBase {
|
||||
data = *p_data;
|
||||
|
||||
raw += sizeof(DataT);
|
||||
|
||||
//DebugP_log((char*)"Data unpacked: %d\r\n", sizeof(DataT));
|
||||
}
|
||||
|
||||
void operator()() { }
|
||||
|
||||
@ -32,17 +32,15 @@ public:
|
||||
return size_;
|
||||
}
|
||||
|
||||
void detach() {
|
||||
next_ = nullptr;
|
||||
first_ = this;
|
||||
last_ = this;
|
||||
QueueEntity& operator+(QueueEntity& next) {
|
||||
append(next);
|
||||
//set_next(next);
|
||||
|
||||
size_ = 1;
|
||||
return next;
|
||||
}
|
||||
|
||||
QueueEntity& operator+(QueueEntity& next) {
|
||||
QueueEntity& operator>>(QueueEntity& next) {
|
||||
attach(next);
|
||||
//set_next(next);
|
||||
|
||||
return next;
|
||||
}
|
||||
@ -68,16 +66,26 @@ private:
|
||||
first_ = first;
|
||||
}
|
||||
|
||||
QueueEntity* append(QueueEntity& next) {
|
||||
if(this != first_) {
|
||||
first_ = first_->append(next);
|
||||
}else{
|
||||
last_->set_next(next);
|
||||
last_ = next.get_last();
|
||||
|
||||
next.set_first(first_);
|
||||
|
||||
size_++;
|
||||
}
|
||||
|
||||
return first_;
|
||||
}
|
||||
|
||||
QueueEntity* attach(QueueEntity& next) {
|
||||
if(this != first_) {
|
||||
first_ = first_->attach(next);
|
||||
}else{
|
||||
next.set_first(first_);
|
||||
last_->set_next(next);
|
||||
//last_ = next.get_last();
|
||||
last_ = &next;
|
||||
|
||||
size_++;
|
||||
}
|
||||
|
||||
return first_;
|
||||
|
||||
@ -12,7 +12,18 @@ namespace free_rtos {
|
||||
namespace telegram {
|
||||
|
||||
int32_t EcatTelegram::Process(uint8_t *p_data, uint32_t len) {
|
||||
unpack(p_data);
|
||||
// TODO: Не забывать вычитать из указателя sizeof(TEthFrameHeader) !
|
||||
unpack(p_data - sizeof(TEthFrameHeader));
|
||||
|
||||
/*
|
||||
DebugP_log((char*)"Process started\r\n");
|
||||
|
||||
for(uint8_t *data = p_data; data < p_data + len; data++) {
|
||||
DebugP_log((char*)"0x%01x ", *data);
|
||||
}
|
||||
|
||||
DebugP_log((char*)"\r\n");
|
||||
*/
|
||||
|
||||
rx_sem_.post();
|
||||
|
||||
@ -22,6 +33,8 @@ int32_t EcatTelegram::Process(uint8_t *p_data, uint32_t len) {
|
||||
uint32_t EcatTelegram::Sender(uint8_t *p_data, size_t scatter_segment) {
|
||||
uint8_t *raw = pack(p_data);
|
||||
|
||||
//DebugP_log((char*)"Sender started\r\n");
|
||||
|
||||
return raw - p_data;
|
||||
}
|
||||
|
||||
@ -44,7 +57,6 @@ uint8_t* EcatTelegram::pack(uint8_t *raw) {
|
||||
}
|
||||
|
||||
p_hdr->bits.length = p_datagram_last - p_datagram_first;
|
||||
//buffer_out_.length = sizeof(TEthFrameHeader) + sizeof(TEcatFrameHeader) + p_hdr->bits.length;
|
||||
|
||||
return p_datagram_last;
|
||||
}
|
||||
@ -70,12 +82,14 @@ uint8_t* EcatTelegram::unpack(uint8_t *raw) {
|
||||
void EcatTelegram::transfer(datagram::IEcatDatagram& first) {
|
||||
datagram_queue_ = &first;
|
||||
|
||||
//pack();
|
||||
//bool stat = tx_flow_.send(port_id_, buffer_out_.data, buffer_out_.length);
|
||||
//uint8_t *raw = pack(buffer_out_.data);
|
||||
//bool stat = tx_flow_.send(port_id_, buffer_out_.data, raw - buffer_out_.data);
|
||||
|
||||
bool stat = eth_stack_.send_pkt(port_id_, ETH_PROT_ECAT_LE, 1);
|
||||
|
||||
if(stat == false) {
|
||||
DebugP_log((char*)"telegram transfer error !\r\n");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -43,8 +43,6 @@ private:
|
||||
|
||||
datagram::IEcatDatagram *datagram_queue_{nullptr};
|
||||
|
||||
//TEthPkt buffer_out_;
|
||||
|
||||
uint8_t* pack(uint8_t *raw);
|
||||
uint8_t* unpack(uint8_t *raw);
|
||||
};
|
||||
|
||||
@ -66,6 +66,8 @@ bool free_rtos::EthStack::send_pkt(TEthMacPorts port_id, uint16_t prot_id, uint3
|
||||
Handler* handler = rx_pkt_handler_.GetHandler(prot_id);
|
||||
|
||||
if(handler == nullptr) {
|
||||
DebugP_log((char*)"Error: can't find requested protocol !");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@ -70,7 +70,7 @@ Usage:
|
||||
runAfterLoad = true;
|
||||
|
||||
// Указать путь к текущей папке
|
||||
var script_path = "/home/sofdev/workspace_v11/sitara_depot/utils/ddr_init/ccs_files";
|
||||
var script_path = "/home/algin/workspace_v11/sitara_depot/utils/ddr_init/ccs_files";
|
||||
|
||||
print("script_path = " + script_path);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user