-
Notifications
You must be signed in to change notification settings - Fork 17.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for Connector loopback testing for Ethernet #28073
Add support for Connector loopback testing for Ethernet #28073
Conversation
SocketAPM::inet_addr_to_str(get_ip_active(), ipstr, sizeof(ipstr)); | ||
if (!listen_sock->bind(ipstr, 9)) { | ||
GCS_SEND_TEXT(MAV_SEVERITY_ERROR, "connector_loopback: failed to bind"); | ||
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leaking listen_sock
here. Similarly elsewhere; use a fail:
pattern?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
} | ||
GCS_SEND_TEXT(MAV_SEVERITY_INFO, "connector_loopback: listening"); | ||
// create discard client | ||
auto *client = new SocketAPM(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is also leaked
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
uint32_t last_report_ms = AP_HAL::millis(); | ||
uint32_t total_rx = 0; | ||
while (true) { | ||
if ((param.tests & TEST_CONNECTOR_LOOPBACK) == 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A test_enabled(Test::CONNECTOR_LOOPBACK
)` thing would be a nice cleanup
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
hal.scheduler->delay(1); | ||
continue; | ||
} | ||
client->send(buf, 1024); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm pretty sure Valgrind would not like this; maybe just zero it on the stack.
I'd actually suggest something non-zero in case there's some ridiculous optimisation somewhere. Perhaps:
for (uint8_t i=0; i<ARRAY_SIZE(buf); i++) {
buf[i] = i;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed to using memset to set all the values to 0xab
882b33f
to
d473aae
Compare
c7c6e4d
to
cb6dec6
Compare
Tested working on CubePilot PPPGW