Skip to content
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

UARTDriver: add option to create uart connection to file #14234

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions libraries/AP_HAL_SITL/UARTDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
#include "SITL_State.h"
#include <AP_HAL/utility/packetise.h>

#include <AP_Filesystem/AP_Filesystem.h>

extern const AP_HAL::HAL& hal;

using namespace HALSITL;
Expand Down Expand Up @@ -126,6 +128,15 @@ void UARTDriver::begin(uint32_t baud, uint16_t rxSpace, uint16_t txSpace)
::printf("UDP multicast connection %s:%u\n", ip, port);
_udp_start_multicast(ip, port);
}
} else if (strcmp(devtype, "file") == 0) {
if (!_connected) {
::printf("FILE connection %s\n", args1);
_fd = AP::FS().open(args1, O_RDONLY);
if (_fd == -1) {
AP_HAL::panic("Failed to open (%s): %m", args1);
}
_connected = true;
}
} else {
AP_HAL::panic("Invalid device path: %s", path);
}
Expand Down