fix(SF-33): Исправлены ошибки передачи
This commit is contained in:
parent
a1af37dfb5
commit
09fbc270bd
@ -36,7 +36,7 @@ void EthEcat::Init(TEthMacPorts port_id, uint32_t period_microsec = 250) {
|
||||
}
|
||||
|
||||
bool EthEcat::set_slaves_to_default() {
|
||||
const datagram::TEcatWkc expected_wkc = 0;
|
||||
const datagram::TEcatWkc expected_wkc = 1;
|
||||
address::Broadcast broadcast{0x0000};
|
||||
bool status;
|
||||
|
||||
|
||||
@ -14,6 +14,7 @@ namespace telegram {
|
||||
const char EcatTelegramStatus::SuccessString[] = "Success !";
|
||||
const char EcatTelegramStatus::BusyString[] = "Busy. Transfer in progress...";
|
||||
const char EcatTelegramStatus::WarningTransferErrorString[] = "Warning ! Transfer error. Check error counters";
|
||||
const char EcatTelegramStatus::WarningTimeoutErrorString[] = "Warning ! Connection timeout error. Check error counters";
|
||||
const char EcatTelegramStatus::WarningWkcErrorString[] = "Warning ! WKC error. Check error counters";
|
||||
const char EcatTelegramStatus::FatalErrorString[] = "Fatal error ! Transfer attempts exceeded";
|
||||
|
||||
@ -21,6 +22,7 @@ const EcatDescription EcatTelegramStatus::descriptions[] = {
|
||||
{EcatTelegramStatus::SuccessString, sizeof(EcatTelegramStatus::SuccessString)},
|
||||
{EcatTelegramStatus::BusyString, sizeof(EcatTelegramStatus::BusyString)},
|
||||
{EcatTelegramStatus::WarningTransferErrorString, sizeof(EcatTelegramStatus::WarningTransferErrorString)},
|
||||
{EcatTelegramStatus::WarningTimeoutErrorString, sizeof(EcatTelegramStatus::WarningTimeoutErrorString)},
|
||||
{EcatTelegramStatus::WarningWkcErrorString, sizeof(EcatTelegramStatus::WarningWkcErrorString)},
|
||||
{EcatTelegramStatus::FatalErrorString, sizeof(EcatTelegramStatus::FatalErrorString)}
|
||||
};
|
||||
@ -65,6 +67,10 @@ uint8_t* EcatTelegram::pack(uint8_t *raw) {
|
||||
(void)p_eth_hdr;
|
||||
(void)p_hdr;
|
||||
|
||||
if(first == nullptr) {
|
||||
return p_datagram_last;
|
||||
}
|
||||
|
||||
p_datagram_last = first->pack_all(p_datagram_first);
|
||||
|
||||
p_hdr->bits.length = p_datagram_last - p_datagram_first;
|
||||
@ -79,6 +85,10 @@ uint8_t* EcatTelegram::unpack(uint8_t *raw) {
|
||||
uint8_t *p_datagram_last = p_datagram_first;
|
||||
auto first = datagram_queue_.get_first();
|
||||
|
||||
if(first == nullptr) {
|
||||
return p_datagram_last;
|
||||
}
|
||||
|
||||
p_datagram_last = first->unpack_all(p_datagram_first);
|
||||
|
||||
return p_datagram_last;
|
||||
@ -89,6 +99,7 @@ bool EcatTelegram::transfer() {
|
||||
uint32_t transfer_attempts = 0;
|
||||
bool stat;
|
||||
bool as_expected;
|
||||
int status;
|
||||
|
||||
if(first == nullptr) {
|
||||
status_.result = EcatTelegramResult::SUCCESS;
|
||||
@ -96,7 +107,6 @@ bool EcatTelegram::transfer() {
|
||||
return true;
|
||||
}
|
||||
|
||||
datagram_queue_.clear();
|
||||
status_.result = EcatTelegramResult::BUSY;
|
||||
|
||||
first->reset_all_wkc();
|
||||
@ -125,7 +135,14 @@ bool EcatTelegram::transfer() {
|
||||
continue;
|
||||
}
|
||||
|
||||
rx_sem_.pend();
|
||||
status = rx_sem_.pend(connection_timeout_ticks_);
|
||||
|
||||
if(status != SystemP_SUCCESS) {
|
||||
status_.transfer_errors++;
|
||||
status_.result = EcatTelegramResult::WARNING_TIMEOUT_ERROR;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
as_expected = first->all_as_expected();
|
||||
|
||||
@ -143,6 +160,8 @@ bool EcatTelegram::transfer() {
|
||||
break;
|
||||
}
|
||||
|
||||
datagram_queue_.clear();
|
||||
|
||||
return (status_.result != EcatTelegramResult::FATAL_ERROR);
|
||||
}
|
||||
|
||||
|
||||
@ -20,6 +20,7 @@ enum class EcatTelegramResult : uint16_t {
|
||||
SUCCESS = 0,
|
||||
BUSY,
|
||||
WARNING_TRANSFER_ERROR,
|
||||
WARNING_TIMEOUT_ERROR,
|
||||
WARNING_WKC_ERROR,
|
||||
FATAL_ERROR
|
||||
};
|
||||
@ -33,7 +34,7 @@ struct EcatTelegramStatus {
|
||||
uint16_t transfer_errors;
|
||||
uint16_t expected_wkc_errors;
|
||||
uint16_t attempts_exceeded_errors;
|
||||
EcatTelegramResult result = EcatTelegramResult::SUCCESS;
|
||||
EcatTelegramResult result = EcatTelegramResult::BUSY;
|
||||
|
||||
const EcatDescription& get_description() {
|
||||
return descriptions[static_cast<size_t>(result)];
|
||||
@ -43,6 +44,7 @@ private:
|
||||
static const char SuccessString[];
|
||||
static const char BusyString[];
|
||||
static const char WarningTransferErrorString[];
|
||||
static const char WarningTimeoutErrorString[];
|
||||
static const char WarningWkcErrorString[];
|
||||
static const char FatalErrorString[];
|
||||
|
||||
@ -72,6 +74,7 @@ public:
|
||||
bool transfer(queue::Queue<datagram::IEcatDatagram>& next);
|
||||
|
||||
private:
|
||||
static constexpr uint32_t connection_timeout_ticks_ = 2;
|
||||
static constexpr uint32_t max_transfer_attempts_ = 3;
|
||||
|
||||
Eth& eth_;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user