dev(UML-1780): Добавлен тест соединения с помощью NOP пакетов. Относительно стабильный.
This commit is contained in:
parent
d2c09001a2
commit
d496671282
@ -50,18 +50,18 @@ bool EthEcat::set_slaves_to_default() {
|
|||||||
|
|
||||||
/* reset CRC counters */
|
/* reset CRC counters */
|
||||||
std::array<uint8_t, 8> c_data_out;
|
std::array<uint8_t, 8> c_data_out;
|
||||||
c_data_out.fill(0x00);
|
|
||||||
datagram::EcatDatagram<command::BWR, std::array<uint8_t, 8>> c{ {{broadcast, ECT_REG_RXERR}}, expected_wkc, c_data_out };
|
datagram::EcatDatagram<command::BWR, std::array<uint8_t, 8>> c{ {{broadcast, ECT_REG_RXERR}}, expected_wkc, c_data_out };
|
||||||
|
c_data_out.fill(0x00);
|
||||||
|
|
||||||
/* reset FMMU's */
|
/* reset FMMU's */
|
||||||
std::array<uint8_t, 16*3> d_data_out;
|
std::array<uint8_t, 16*3> d_data_out;
|
||||||
d_data_out.fill(0x00);
|
|
||||||
datagram::EcatDatagram<command::BWR, std::array<uint8_t, 16*3>> d{ {{broadcast, ECT_REG_FMMU0}}, expected_wkc, d_data_out };
|
datagram::EcatDatagram<command::BWR, std::array<uint8_t, 16*3>> d{ {{broadcast, ECT_REG_FMMU0}}, expected_wkc, d_data_out };
|
||||||
|
d_data_out.fill(0x00);
|
||||||
|
|
||||||
/* reset SyncM */
|
/* reset SyncM */
|
||||||
std::array<uint8_t, 8*4> e_data_out;
|
std::array<uint8_t, 8*4> e_data_out;
|
||||||
e_data_out.fill(0x00);
|
|
||||||
datagram::EcatDatagram<command::BWR, std::array<uint8_t, 8*4>> e{ {{broadcast, ECT_REG_SM0}}, expected_wkc, e_data_out };
|
datagram::EcatDatagram<command::BWR, std::array<uint8_t, 8*4>> e{ {{broadcast, ECT_REG_SM0}}, expected_wkc, e_data_out };
|
||||||
|
e_data_out.fill(0x00);
|
||||||
|
|
||||||
/* reset activation register */
|
/* reset activation register */
|
||||||
uint8_t f_data_out{0x00};
|
uint8_t f_data_out{0x00};
|
||||||
@ -69,8 +69,8 @@ bool EthEcat::set_slaves_to_default() {
|
|||||||
|
|
||||||
/* reset system time+ofs */
|
/* reset system time+ofs */
|
||||||
std::array<uint8_t, 4> g_data_out;
|
std::array<uint8_t, 4> g_data_out;
|
||||||
g_data_out.fill(0x00);
|
|
||||||
datagram::EcatDatagram<command::BWR, std::array<uint8_t, 4>> g{ {{broadcast, ECT_REG_DCSYSTIME}}, expected_wkc, g_data_out };
|
datagram::EcatDatagram<command::BWR, std::array<uint8_t, 4>> g{ {{broadcast, ECT_REG_DCSYSTIME}}, expected_wkc, g_data_out };
|
||||||
|
g_data_out.fill(0x00);
|
||||||
|
|
||||||
/* DC speedstart */
|
/* DC speedstart */
|
||||||
uint16_t h_data_out{0x1000};
|
uint16_t h_data_out{0x1000};
|
||||||
@ -214,6 +214,25 @@ bool EthEcat::get_addresses_of_slaves() {
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool EthEcat::connection_test() {
|
||||||
|
const datagram::TEcatWkc expected_wkc = 0;
|
||||||
|
bool status;
|
||||||
|
|
||||||
|
std::array<uint8_t, 110> test_data_out;
|
||||||
|
datagram::EcatDatagram<command::NOP, std::array<uint8_t, 110>> datagram{ {{0x0000, 0x0000}}, expected_wkc, test_data_out };
|
||||||
|
test_data_out.fill(0x00);
|
||||||
|
|
||||||
|
while(1) {
|
||||||
|
status = telegram_.transfer(datagram);
|
||||||
|
|
||||||
|
if(status != true) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
bool EthEcat::config_init(uint16_t address_base) {
|
bool EthEcat::config_init(uint16_t address_base) {
|
||||||
uint16_t number_of_slaves;
|
uint16_t number_of_slaves;
|
||||||
bool status;
|
bool status;
|
||||||
@ -247,7 +266,15 @@ bool EthEcat::config_init(uint16_t address_base) {
|
|||||||
if(status != true) {
|
if(status != true) {
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
DebugP_log((char*)"Starting connection test...\r\n");
|
||||||
|
|
||||||
|
status = connection_test();
|
||||||
|
|
||||||
|
if(status != true) {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
*/
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -295,8 +322,6 @@ bool EthEcat::safeop_to_op() {
|
|||||||
uint16_t zero{0x00000000};
|
uint16_t zero{0x00000000};
|
||||||
bool status;
|
bool status;
|
||||||
|
|
||||||
ecat_timer_.Start();
|
|
||||||
|
|
||||||
process_sem_.post();
|
process_sem_.post();
|
||||||
if(init_sem_.pend(process_timeout_ticks_) != SystemP_SUCCESS) {
|
if(init_sem_.pend(process_timeout_ticks_) != SystemP_SUCCESS) {
|
||||||
DebugP_log((char*)"Process task timeout !\r\n");
|
DebugP_log((char*)"Process task timeout !\r\n");
|
||||||
|
|||||||
@ -188,6 +188,7 @@ public:
|
|||||||
uint16_t slaves_detecting();
|
uint16_t slaves_detecting();
|
||||||
bool set_addresses_of_slaves(uint16_t number_of_slaves, uint16_t address_base);
|
bool set_addresses_of_slaves(uint16_t number_of_slaves, uint16_t address_base);
|
||||||
bool get_addresses_of_slaves();
|
bool get_addresses_of_slaves();
|
||||||
|
bool connection_test();
|
||||||
|
|
||||||
bool config_init(uint16_t address_base);
|
bool config_init(uint16_t address_base);
|
||||||
|
|
||||||
|
|||||||
@ -104,14 +104,15 @@ class EcatCommand : public EcatCommandBase {
|
|||||||
static_assert(std::is_base_of<DirBase, DirT>::value == true, "DirT should be derived from command::DirBase");
|
static_assert(std::is_base_of<DirBase, DirT>::value == true, "DirT should be derived from command::DirBase");
|
||||||
|
|
||||||
public:
|
public:
|
||||||
EcatCommand(typename TypeT::TAddress&& address)
|
using TType = TypeT;
|
||||||
|
using TDir = DirT;
|
||||||
|
using TAddress = typename TypeT::TAddress;
|
||||||
|
|
||||||
|
EcatCommand(TAddress&& address)
|
||||||
: address_{address} { }
|
: address_{address} { }
|
||||||
|
|
||||||
EcatCommand() { }
|
EcatCommand() { }
|
||||||
|
|
||||||
using TType = TypeT;
|
|
||||||
using TDir = DirT;
|
|
||||||
|
|
||||||
static constexpr uint8_t get_cmd() {
|
static constexpr uint8_t get_cmd() {
|
||||||
std::array<std::array<uint8_t, 4>, 4> commands = {{
|
std::array<std::array<uint8_t, 4>, 4> commands = {{
|
||||||
{{EC_CMD_APRD, EC_CMD_APWR, EC_CMD_APRW, EC_CMD_ARMW}},
|
{{EC_CMD_APRD, EC_CMD_APWR, EC_CMD_APRW, EC_CMD_ARMW}},
|
||||||
@ -137,7 +138,7 @@ public:
|
|||||||
static constexpr bool get_skip_unpack() {
|
static constexpr bool get_skip_unpack() {
|
||||||
std::array<std::array<bool, 4>, 4> commands = {{
|
std::array<std::array<bool, 4>, 4> commands = {{
|
||||||
{{false, true, false, false}},
|
{{false, true, false, false}},
|
||||||
{{false, false, false, true}},
|
{{false, false, false, true}},
|
||||||
{{false, true, false, false}},
|
{{false, true, false, false}},
|
||||||
{{false, true, false, true}}
|
{{false, true, false, true}}
|
||||||
}};
|
}};
|
||||||
@ -155,7 +156,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typename TypeT::TAddress address_;
|
TAddress address_;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@ -128,7 +128,7 @@ public:
|
|||||||
~EcatDatagram() { }
|
~EcatDatagram() { }
|
||||||
|
|
||||||
virtual uint8_t* pack(uint8_t *raw, uint8_t idx) override {
|
virtual uint8_t* pack(uint8_t *raw, uint8_t idx) override {
|
||||||
if(as_expected() == true) {
|
if((as_expected() == true) && (command_.get_cmd() != EC_CMD_NOP)) {
|
||||||
return raw;
|
return raw;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,7 +136,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
virtual uint8_t* unpack(uint8_t *raw, uint8_t idx) override {
|
virtual uint8_t* unpack(uint8_t *raw, uint8_t idx) override {
|
||||||
if(as_expected() == true) {
|
if((as_expected() == true) && (command_.get_cmd() != EC_CMD_NOP)) {
|
||||||
return raw;
|
return raw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -77,7 +77,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
static constexpr uint32_t connection_timeout_ticks_ = 70;
|
static constexpr uint32_t connection_timeout_ticks_ = 70;
|
||||||
static constexpr uint32_t max_transfer_attempts_ = 8;
|
static constexpr uint32_t max_transfer_attempts_ = 6;
|
||||||
|
|
||||||
Eth& eth_;
|
Eth& eth_;
|
||||||
Timer& ecat_timer_;
|
Timer& ecat_timer_;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user