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();
|
mutex_write_.lock();
|
||||||
|
|
||||||
next = queue_write_.get_next();
|
next = queue_write_.get_next();
|
||||||
queue_write_.detach();
|
last_write_ = &queue_write_;
|
||||||
|
|
||||||
mutex_write_.unlock();
|
mutex_write_.unlock();
|
||||||
|
|
||||||
@ -81,7 +81,7 @@ void EthEcatPdoFMMU::process_read_queue(uint8_t* process_data, uint32_t len) {
|
|||||||
mutex_read_.lock();
|
mutex_read_.lock();
|
||||||
|
|
||||||
next = queue_read_.get_next();
|
next = queue_read_.get_next();
|
||||||
queue_read_.detach();
|
last_read_ = &queue_read_;
|
||||||
|
|
||||||
mutex_read_.unlock();
|
mutex_read_.unlock();
|
||||||
|
|
||||||
|
|||||||
@ -91,7 +91,8 @@ public:
|
|||||||
|
|
||||||
mutex_write_.lock();
|
mutex_write_.lock();
|
||||||
|
|
||||||
queue_write_ + promise;
|
custom_promise::IPromise& last_write = (*last_write_) >> promise;
|
||||||
|
last_write_ = &last_write;
|
||||||
|
|
||||||
mutex_write_.unlock();
|
mutex_write_.unlock();
|
||||||
|
|
||||||
@ -107,7 +108,8 @@ public:
|
|||||||
|
|
||||||
mutex_read_.lock();
|
mutex_read_.lock();
|
||||||
|
|
||||||
queue_read_ + promise;
|
custom_promise::IPromise& last_read = (*last_read_) >> promise;
|
||||||
|
last_read_ = &last_read;
|
||||||
|
|
||||||
mutex_read_.unlock();
|
mutex_read_.unlock();
|
||||||
|
|
||||||
@ -120,16 +122,17 @@ public:
|
|||||||
void pdo_write_async(custom_promise::IPromise& promise) {
|
void pdo_write_async(custom_promise::IPromise& promise) {
|
||||||
mutex_write_.lock();
|
mutex_write_.lock();
|
||||||
|
|
||||||
queue_write_ + promise;
|
custom_promise::IPromise& last_write = (*last_write_) >> promise;
|
||||||
|
last_write_ = &last_write;
|
||||||
|
|
||||||
mutex_write_.unlock();
|
mutex_write_.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void pdo_read_async(custom_promise::IPromise& promise) {
|
void pdo_read_async(custom_promise::IPromise& promise) {
|
||||||
mutex_read_.lock();
|
mutex_read_.lock();
|
||||||
|
|
||||||
queue_read_ + promise;
|
custom_promise::IPromise& last_read = (*last_read_) >> promise;
|
||||||
|
last_read_ = &last_read;
|
||||||
|
|
||||||
mutex_read_.unlock();
|
mutex_read_.unlock();
|
||||||
}
|
}
|
||||||
@ -145,6 +148,9 @@ private:
|
|||||||
custom_promise::WritePromise<> queue_write_{0};
|
custom_promise::WritePromise<> queue_write_{0};
|
||||||
custom_promise::ReadPromise<> queue_read_{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};
|
uint32_t pdo_counter_{0};
|
||||||
|
|
||||||
void wait_op();
|
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 };
|
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;
|
a + b + c + d + e + f + g + h + i + j + k + l + m;
|
||||||
|
|
||||||
|
do {
|
||||||
telegram_.transfer(a);
|
telegram_.transfer(a);
|
||||||
|
} while(a.get_all_wkc() < 0x0001);
|
||||||
|
|
||||||
//telegram_.transfer(b);
|
//telegram_.transfer(b);
|
||||||
//telegram_.transfer(c);
|
//telegram_.transfer(c);
|
||||||
//telegram_.transfer(d);
|
//telegram_.transfer(d);
|
||||||
|
|||||||
@ -136,8 +136,10 @@ public:
|
|||||||
return next;
|
return next;
|
||||||
}
|
}
|
||||||
|
|
||||||
void detach() {
|
IPromise& operator>>(IPromise &next) {
|
||||||
queue_entity_.detach();
|
queue_entity_ >> next.get_queue_entity();
|
||||||
|
|
||||||
|
return next;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void set_value(uint8_t* process_data, uint32_t len) = 0;
|
virtual void set_value(uint8_t* process_data, uint32_t len) = 0;
|
||||||
|
|||||||
@ -56,10 +56,12 @@ public:
|
|||||||
return next;
|
return next;
|
||||||
}
|
}
|
||||||
|
|
||||||
void detach() {
|
IEcatDatagram& operator>>(IEcatDatagram &next) {
|
||||||
more_ = ec_moredatagrams::EC_MOREDATAGRAMS_LAST;
|
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;
|
virtual uint8_t* pack(uint8_t *raw) = 0;
|
||||||
@ -166,7 +168,7 @@ private:
|
|||||||
|
|
||||||
for_each(data_tuple_, functor);
|
for_each(data_tuple_, functor);
|
||||||
|
|
||||||
return functor.raw;
|
return unpack_wkc(functor.raw);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t* unpack_header(uint8_t *raw) {
|
uint8_t* unpack_header(uint8_t *raw) {
|
||||||
|
|||||||
@ -26,6 +26,8 @@ struct PackFunctorBase {
|
|||||||
(void)data_p;
|
(void)data_p;
|
||||||
|
|
||||||
raw += sizeof(DataT);
|
raw += sizeof(DataT);
|
||||||
|
|
||||||
|
//DebugP_log((char*)"Data packed: %d\r\n", sizeof(DataT));
|
||||||
}
|
}
|
||||||
|
|
||||||
void operator()() { }
|
void operator()() { }
|
||||||
@ -62,6 +64,8 @@ struct UnpackFunctorBase {
|
|||||||
data = *p_data;
|
data = *p_data;
|
||||||
|
|
||||||
raw += sizeof(DataT);
|
raw += sizeof(DataT);
|
||||||
|
|
||||||
|
//DebugP_log((char*)"Data unpacked: %d\r\n", sizeof(DataT));
|
||||||
}
|
}
|
||||||
|
|
||||||
void operator()() { }
|
void operator()() { }
|
||||||
|
|||||||
@ -32,17 +32,15 @@ public:
|
|||||||
return size_;
|
return size_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void detach() {
|
QueueEntity& operator+(QueueEntity& next) {
|
||||||
next_ = nullptr;
|
append(next);
|
||||||
first_ = this;
|
//set_next(next);
|
||||||
last_ = this;
|
|
||||||
|
|
||||||
size_ = 1;
|
return next;
|
||||||
}
|
}
|
||||||
|
|
||||||
QueueEntity& operator+(QueueEntity& next) {
|
QueueEntity& operator>>(QueueEntity& next) {
|
||||||
attach(next);
|
attach(next);
|
||||||
//set_next(next);
|
|
||||||
|
|
||||||
return next;
|
return next;
|
||||||
}
|
}
|
||||||
@ -68,16 +66,26 @@ private:
|
|||||||
first_ = first;
|
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) {
|
QueueEntity* attach(QueueEntity& next) {
|
||||||
if(this != first_) {
|
if(this != first_) {
|
||||||
first_ = first_->attach(next);
|
first_ = first_->attach(next);
|
||||||
}else{
|
}else{
|
||||||
next.set_first(first_);
|
|
||||||
last_->set_next(next);
|
last_->set_next(next);
|
||||||
//last_ = next.get_last();
|
|
||||||
last_ = &next;
|
|
||||||
|
|
||||||
size_++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return first_;
|
return first_;
|
||||||
|
|||||||
@ -12,7 +12,18 @@ namespace free_rtos {
|
|||||||
namespace telegram {
|
namespace telegram {
|
||||||
|
|
||||||
int32_t EcatTelegram::Process(uint8_t *p_data, uint32_t len) {
|
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();
|
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) {
|
uint32_t EcatTelegram::Sender(uint8_t *p_data, size_t scatter_segment) {
|
||||||
uint8_t *raw = pack(p_data);
|
uint8_t *raw = pack(p_data);
|
||||||
|
|
||||||
|
//DebugP_log((char*)"Sender started\r\n");
|
||||||
|
|
||||||
return raw - p_data;
|
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;
|
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;
|
return p_datagram_last;
|
||||||
}
|
}
|
||||||
@ -70,12 +82,14 @@ uint8_t* EcatTelegram::unpack(uint8_t *raw) {
|
|||||||
void EcatTelegram::transfer(datagram::IEcatDatagram& first) {
|
void EcatTelegram::transfer(datagram::IEcatDatagram& first) {
|
||||||
datagram_queue_ = &first;
|
datagram_queue_ = &first;
|
||||||
|
|
||||||
//pack();
|
//uint8_t *raw = pack(buffer_out_.data);
|
||||||
//bool stat = tx_flow_.send(port_id_, buffer_out_.data, buffer_out_.length);
|
//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);
|
bool stat = eth_stack_.send_pkt(port_id_, ETH_PROT_ECAT_LE, 1);
|
||||||
|
|
||||||
if(stat == false) {
|
if(stat == false) {
|
||||||
|
DebugP_log((char*)"telegram transfer error !\r\n");
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -43,8 +43,6 @@ private:
|
|||||||
|
|
||||||
datagram::IEcatDatagram *datagram_queue_{nullptr};
|
datagram::IEcatDatagram *datagram_queue_{nullptr};
|
||||||
|
|
||||||
//TEthPkt buffer_out_;
|
|
||||||
|
|
||||||
uint8_t* pack(uint8_t *raw);
|
uint8_t* pack(uint8_t *raw);
|
||||||
uint8_t* unpack(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);
|
Handler* handler = rx_pkt_handler_.GetHandler(prot_id);
|
||||||
|
|
||||||
if(handler == nullptr) {
|
if(handler == nullptr) {
|
||||||
|
DebugP_log((char*)"Error: can't find requested protocol !");
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -70,7 +70,7 @@ Usage:
|
|||||||
runAfterLoad = true;
|
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);
|
print("script_path = " + script_path);
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user