fix(SF-60): Попытка повысить стабильность соединения
This commit is contained in:
parent
d860453bae
commit
12f93c8ddc
@ -13,7 +13,7 @@
|
||||
#include "free_rtos/task/task.hpp"
|
||||
|
||||
namespace free_rtos {
|
||||
static constexpr uint32_t LINK_TASK_PRIORITY = tskIDLE_PRIORITY + 22;
|
||||
static constexpr uint32_t LINK_TASK_PRIORITY = tskIDLE_PRIORITY + 2;
|
||||
static constexpr uint32_t LINK_TASK_STACK_SIZE = 0x2000 / sizeof(StackType_t);
|
||||
}
|
||||
|
||||
|
||||
@ -155,7 +155,7 @@ bool EcatTelegram::transfer() {
|
||||
|
||||
tick_counter_diff = diff(tick_counter_start, ecat_timer_.GetTickCounter());
|
||||
|
||||
if((sts != SystemP_SUCCESS) && (tick_counter_diff < counter_timeout_ticks_)) {
|
||||
if((sts != SystemP_SUCCESS) && (tick_counter_diff < counter_timeout_ticks_ - 1)) {
|
||||
//DebugP_log((char*)"rx_sem_ fake timeout detected !\r\n", );
|
||||
|
||||
continue;
|
||||
|
||||
@ -102,7 +102,7 @@ private:
|
||||
TEthMacPorts port_id_;
|
||||
uint32_t period_microsec_{250};
|
||||
uint32_t counter_timeout_ticks_{8};
|
||||
uint32_t max_transfer_attempts_{6};
|
||||
uint32_t max_transfer_attempts_{4};
|
||||
|
||||
free_rtos::Semaphore rx_sem_;
|
||||
uint8_t idx_{0x00};
|
||||
|
||||
@ -23,8 +23,7 @@ free_rtos::EthUpdClient::EthUpdClient(EthIpIface& ip_iface, TEthMacPorts port_id
|
||||
use_checksum_{use_chksum},
|
||||
ip_iface_{ip_iface},
|
||||
port_id_{port_id}
|
||||
{
|
||||
}
|
||||
{ }
|
||||
|
||||
void free_rtos::EthUpdClient::put_data(uint32_t src_ip, uint8_t * p_data, uint32_t len)
|
||||
{
|
||||
@ -32,16 +31,18 @@ void free_rtos::EthUpdClient::put_data(uint32_t src_ip, uint8_t * p_data, uint32
|
||||
return;
|
||||
}
|
||||
|
||||
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD>
|
||||
{
|
||||
LockGuard lock(rx_mut_); /// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
LockGuard lock(rx_mut_);
|
||||
|
||||
if(buff_.size() + len > max_buf_size) {
|
||||
uint32_t new_size = buff_.size() + len;
|
||||
|
||||
if(new_size > max_buf_size) {
|
||||
DebugP_log((char *)"Warning ! UDP client buffer overflow !\r\n");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
buff_.reserve(new_size);
|
||||
buff_.insert(buff_.end(), p_data, p_data + len);
|
||||
}
|
||||
|
||||
@ -52,20 +53,21 @@ void free_rtos::EthUpdClient::put_data(uint32_t src_ip, uint8_t * p_data, uint32
|
||||
|
||||
int32_t free_rtos::EthUpdClient::get_data(uint8_t * p_data, uint32_t len)
|
||||
{
|
||||
uint32_t size = buff_.size();
|
||||
|
||||
if (size > len) {
|
||||
size = len;
|
||||
}
|
||||
uint32_t size;
|
||||
|
||||
{
|
||||
LockGuard lock(rx_mut_); /// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
LockGuard lock(rx_mut_);
|
||||
|
||||
size = buff_.size();
|
||||
|
||||
if (size > len) {
|
||||
size = len;
|
||||
}
|
||||
|
||||
auto item_begin = buff_.begin();
|
||||
auto item_end = item_begin + size;
|
||||
|
||||
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
std::copy(item_begin, item_end, p_data);
|
||||
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
buff_.erase(item_begin, item_end);
|
||||
}
|
||||
|
||||
@ -106,7 +108,7 @@ void free_rtos::EthUpdClient::clear()
|
||||
buff_.clear();
|
||||
}
|
||||
|
||||
int32_t free_rtos::EthUpdClient::write(uint32_t ip_dst_be, uint8_t * p_data, uint32_t len)
|
||||
bool free_rtos::EthUpdClient::write(uint32_t ip_dst_be, uint8_t * p_data, uint32_t len)
|
||||
{
|
||||
TUdpHeader * hdr = (TUdpHeader *)(eth_pkt_.data + sizeof(TIpHeader) + sizeof(TEthFrameHeader));
|
||||
uint8_t * p_udp_data = (uint8_t *)(eth_pkt_.data + sizeof(TIpHeader) + sizeof(TEthFrameHeader) + sizeof(TUdpHeader));
|
||||
|
||||
@ -46,10 +46,10 @@ public:
|
||||
return get_data(data, len);
|
||||
}
|
||||
|
||||
int32_t write(uint32_t ip_dst_be, uint8_t * p_data, uint32_t len);
|
||||
bool write(uint32_t ip_dst_be, uint8_t * p_data, uint32_t len);
|
||||
|
||||
template<class T, class Allocator>
|
||||
int32_t write(uint32_t ip_dst_be, std::vector<T, Allocator>& data)
|
||||
bool write(uint32_t ip_dst_be, std::vector<T, Allocator>& data)
|
||||
{
|
||||
return write(ip_dst_be, data.data(), data.size() * sizeof(T));
|
||||
}
|
||||
@ -63,19 +63,21 @@ private:
|
||||
template<class T, class Allocator>
|
||||
int32_t get_data(std::vector<T, Allocator>& data, uint32_t len)
|
||||
{
|
||||
uint32_t size = buff_.size();
|
||||
|
||||
if (size > len) {
|
||||
size = len;
|
||||
}
|
||||
uint32_t size;
|
||||
|
||||
{
|
||||
LockGuard lock(rx_mut_);
|
||||
|
||||
size = buff_.size();
|
||||
|
||||
if (size > len) {
|
||||
size = len;
|
||||
}
|
||||
|
||||
auto item_begin = buff_.begin();
|
||||
auto item_end = item_begin + size;
|
||||
|
||||
std::copy(item_begin, item_end, std::back_inserter(data));
|
||||
data.insert(data.end(), item_begin, item_end);
|
||||
buff_.erase(item_begin, item_end);
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user