mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-29 16:33:33 +08:00
Reworked file naming and use ROM fs as fall back
The server will now attempt to provide files from the primary
path RootPath and then the alternate AltRootPath. This alows
a layered approch to file service.
Setting the RootPath to an SD card and the AltRootPath to a
ROM FS will allow a user to provide an updated uavcan firware
file that will be used instead of the baked in one without
any copying.
The path as been removed from the interactions with nodes.
There by supporting Non-compliant nodes that could not
handle the specified path length.
The vitrual pathing has been moved into the FDCache.
This commit is contained in:
committed by
Daniel Agar
parent
04377cc270
commit
29e1aa6c12
@@ -25,11 +25,15 @@ namespace uavcan
|
||||
*/
|
||||
class UAVCAN_EXPORT IFileServerBackend
|
||||
{
|
||||
|
||||
public:
|
||||
typedef protocol::file::Path::FieldTypes::path Path;
|
||||
typedef protocol::file::EntryType EntryType;
|
||||
typedef protocol::file::Error Error;
|
||||
|
||||
IFileServerBackend::Path root_path_;
|
||||
IFileServerBackend::Path alt_root_path_;
|
||||
|
||||
/**
|
||||
* All read operations must return this number of bytes, unless end of file is reached.
|
||||
*/
|
||||
@@ -40,6 +44,51 @@ public:
|
||||
*/
|
||||
static char getPathSeparator() { return static_cast<char>(protocol::file::Path::SEPARATOR); }
|
||||
|
||||
/**
|
||||
* Set a base path to the files.
|
||||
*/
|
||||
void setRootPath(const char * path)
|
||||
{
|
||||
if (path)
|
||||
{
|
||||
root_path_.clear();
|
||||
root_path_ = path;
|
||||
if (root_path_.back() != getPathSeparator())
|
||||
{
|
||||
root_path_.push_back(getPathSeparator());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void setAltRootPath(const char * path)
|
||||
{
|
||||
if (path)
|
||||
{
|
||||
alt_root_path_.clear();
|
||||
alt_root_path_ = path;
|
||||
if (alt_root_path_.back() != getPathSeparator())
|
||||
{
|
||||
alt_root_path_.push_back(getPathSeparator());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a base path to the files.
|
||||
*/
|
||||
Path& getRootPath()
|
||||
{
|
||||
return root_path_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a base path to the files.
|
||||
*/
|
||||
Path& getAltRootPath()
|
||||
{
|
||||
return alt_root_path_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Backend for uavcan.protocol.file.GetInfo.
|
||||
* Refer to uavcan.protocol.file.EntryType for the list of available bit flags.
|
||||
@@ -161,8 +210,11 @@ public:
|
||||
, backend_(backend)
|
||||
{ }
|
||||
|
||||
int start()
|
||||
int start(const char* server_root = UAVCAN_NULLPTR, const char* server_alt_root = UAVCAN_NULLPTR)
|
||||
{
|
||||
backend_.setRootPath(server_root);
|
||||
backend_.setAltRootPath(server_alt_root);
|
||||
|
||||
int res = get_info_srv_.start(GetInfoCallback(this, &BasicFileServer::handleGetInfo));
|
||||
if (res < 0)
|
||||
{
|
||||
@@ -224,6 +276,7 @@ class FileServer : protected BasicFileServer
|
||||
resp.entry_type, resp.entry_full_path.path);
|
||||
}
|
||||
|
||||
|
||||
public:
|
||||
FileServer(INode& node, IFileServerBackend& backend)
|
||||
: BasicFileServer(node, backend)
|
||||
|
||||
@@ -345,12 +345,7 @@ class FirmwareUpdateTrigger : public INodeInfoListener,
|
||||
protocol::file::BeginFirmwareUpdate::Request req;
|
||||
|
||||
req.source_node_id = getNode().getNodeID().get();
|
||||
if (!common_path_prefix_.empty())
|
||||
{
|
||||
req.image_file_remote_path.path += common_path_prefix_.c_str();
|
||||
req.image_file_remote_path.path.push_back(protocol::file::Path::SEPARATOR);
|
||||
}
|
||||
req.image_file_remote_path.path += path->c_str();
|
||||
req.image_file_remote_path.path = path->c_str();
|
||||
|
||||
UAVCAN_TRACE("FirmwareUpdateTrigger", "Request to %d with path: %s",
|
||||
int(node_id.get()), req.image_file_remote_path.path.c_str());
|
||||
@@ -396,6 +391,7 @@ public:
|
||||
*/
|
||||
int start(NodeInfoRetriever& node_info_retriever,
|
||||
const FirmwareFilePath& arg_common_path_prefix = FirmwareFilePath(),
|
||||
const FirmwareFilePath& arg_alt_path_prefix = FirmwareFilePath(),
|
||||
const TransferPriority priority = TransferPriority::OneHigherThanLowest)
|
||||
{
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user