Skip to content
Snippets Groups Projects
Commit c666e757 authored by Nicolò Caruso's avatar Nicolò Caruso
Browse files

[ARP] EthernetSniffing fix due to deferenced shared pointer

Fix hardfault: The ethernet sniffer by using the std::move for the Wiz5500 was deferencing the pointer and threfore in the recvfrom an HardFault occured.
Debug: Removed and changed some TRACE strings
Fix UDP socket: The sniffing socket was initialized opend correctly but then the init had switched arguments. This surely impacted on the recvfrom.
parent cbfe1918
No related branches found
No related tags found
No related merge requests found
Pipeline #10954 passed
......@@ -67,7 +67,7 @@ Boardcore::Wiz5500::PhyState EthernetBase::getState()
bool EthernetBase::start(std::shared_ptr<Boardcore::Wiz5500> wiz5500)
{
this->wiz5500 = std::move(wiz5500);
this->wiz5500 = wiz5500;
// Reset the device
this->wiz5500->reset();
......@@ -103,12 +103,6 @@ bool EthernetBase::start(std::shared_ptr<Boardcore::Wiz5500> wiz5500)
return false;
}
if (!this->wiz5500->openUdp(1, SEND_PORT, {255, 255, 255, 255}, RECV_PORT,
500))
{
return false;
}
auto mav_handler = [this](EthernetMavDriver* channel,
const mavlink_message_t& msg) { handleMsg(msg); };
......@@ -116,17 +110,16 @@ bool EthernetBase::start(std::shared_ptr<Boardcore::Wiz5500> wiz5500)
if (!mav_driver->start())
return false;
TRACE("[info] mavlink driver started correctly\n");
// Create and start a second mavlink driver to sniff the ethernet port
// In case of sniffing mode initialize and start the EthernetSniffer
if (sniffOtherGs)
{
getModule<EthernetSniffer>()->init(1, RECV_PORT, SEND_PORT);
getModule<EthernetSniffer>()->init(1, SEND_PORT, RECV_PORT);
if (!getModule<EthernetSniffer>()->start(wiz5500))
return false;
}
TRACE("[info] Ethernet sniffing started correctly\n");
TRACE("[info] Ethernet module started correctly\n");
return true;
}
......
......@@ -58,31 +58,25 @@ void EthernetSniffer::init(uint16_t portNumber, uint16_t srcPort,
bool EthernetSniffer::start(std::shared_ptr<Boardcore::Wiz5500> wiz5500)
{
TRACE("Movin\n");
this->wiz5500 = std::move(wiz5500);
this->wiz5500 = wiz5500;
TRACE("Opening\n");
// We open the port for sniffing using the port we specified
// if (!this->wiz5500->openUdp(portNr, srcPort, {255, 255, 255, 255},
// dstPort,
// 500))
// {
// return false;
// }
TRACE("Mavlinker\n");
TRACE("[info] Opening sniffing UDP socket\n");
// We open the UDP socket for sniffing
if (!this->wiz5500->openUdp(1, SEND_PORT, {255, 255, 255, 255}, RECV_PORT,
500))
{
return false;
}
auto mav_handler = [this](EthernetMavDriver* channel,
const mavlink_message_t& msg) { handleMsg(msg); };
mav_driver = std::make_unique<EthernetMavDriver>(this, mav_handler, 1, 10);
TRACE("Starting\n");
mav_driver = std::make_unique<EthernetMavDriver>(this, mav_handler, 0, 10);
if (!mav_driver->start())
return false;
TRACE("Start ok\n");
TRACE("[info] EthernetSniffer start ok\n");
return true;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment