Skip to content

Commit

Permalink
mavlink: shell expand locking (#19308)
Browse files Browse the repository at this point in the history
 - on some H7 boards (cuav x7pro tested) there's an occasional hard fault when starting the mavlink shell that is no longer reproducible with the slightly expanded locking
 - this is likely just changing the timing (holding the sched lock for longer), but this should be harmless for now until we can identify the root cause
  • Loading branch information
dagar authored Apr 25, 2022
1 parent af839c8 commit 6359c8c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
14 changes: 8 additions & 6 deletions src/modules/mavlink/mavlink_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1334,18 +1334,20 @@ MavlinkShell *
Mavlink::get_shell()
{
if (!_mavlink_shell) {
_mavlink_shell = new MavlinkShell();
MavlinkShell *shell = new MavlinkShell();

if (!_mavlink_shell) {
if (!shell) {
PX4_ERR("Failed to allocate a shell");

} else {
int ret = _mavlink_shell->start();
int ret = shell->start();

if (ret != 0) {
if (ret == 0) {
_mavlink_shell = shell;

} else {
PX4_ERR("Failed to start shell (%i)", ret);
delete _mavlink_shell;
_mavlink_shell = nullptr;
delete shell;
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/modules/mavlink/mavlink_shell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,14 +148,14 @@ int MavlinkShell::start()
close(fd_backups[i]);
}

#ifdef __PX4_NUTTX
sched_unlock();
#endif /* __PX4_NUTTX */

//close unused pipe fd's
close(_shell_fds[0]);
close(_shell_fds[1]);

#ifdef __PX4_NUTTX
sched_unlock();
#endif /* __PX4_NUTTX */

return ret;
}

Expand Down

0 comments on commit 6359c8c

Please # to comment.