mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-27 06:23:34 +08:00
file paths: add PX4_STORAGEDIR & use it where appropriate
This commit is contained in:
@@ -246,11 +246,7 @@ static px4_sem_t g_sys_state_mutex_mission;
|
|||||||
static px4_sem_t g_sys_state_mutex_fence;
|
static px4_sem_t g_sys_state_mutex_fence;
|
||||||
|
|
||||||
/* The data manager store file handle and file name */
|
/* The data manager store file handle and file name */
|
||||||
#ifdef __PX4_POSIX
|
static const char *default_device_path = PX4_STORAGEDIR "/dataman";
|
||||||
static const char *default_device_path = PX4_ROOTFSDIR"/dataman";
|
|
||||||
#else
|
|
||||||
static const char *default_device_path = PX4_ROOTFSDIR"/fs/microsd/dataman";
|
|
||||||
#endif
|
|
||||||
static char *k_data_manager_device_path = nullptr;
|
static char *k_data_manager_device_path = nullptr;
|
||||||
|
|
||||||
#if defined(FLASH_BASED_DATAMAN)
|
#if defined(FLASH_BASED_DATAMAN)
|
||||||
|
|||||||
@@ -830,11 +830,7 @@ void Logger::run()
|
|||||||
orb_set_interval(log_message_sub, 20);
|
orb_set_interval(log_message_sub, 20);
|
||||||
|
|
||||||
|
|
||||||
#if __PX4_POSIX
|
int ntopics = add_topics_from_file(PX4_STORAGEDIR "/etc/logging/logger_topics.txt");
|
||||||
int ntopics = add_topics_from_file(PX4_ROOTFSDIR "/etc/logging/logger_topics.txt");
|
|
||||||
#else
|
|
||||||
int ntopics = add_topics_from_file(PX4_ROOTFSDIR "/fs/microsd/etc/logging/logger_topics.txt");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (ntopics > 0) {
|
if (ntopics > 0) {
|
||||||
PX4_INFO("logging %d topics from logger_topics.txt", ntopics);
|
PX4_INFO("logging %d topics from logger_topics.txt", ntopics);
|
||||||
|
|||||||
@@ -313,11 +313,7 @@ private:
|
|||||||
|
|
||||||
static constexpr size_t MAX_TOPICS_NUM = 64; /**< Maximum number of logged topics */
|
static constexpr size_t MAX_TOPICS_NUM = 64; /**< Maximum number of logged topics */
|
||||||
static constexpr unsigned MAX_NO_LOGFILE = 999; /**< Maximum number of log files */
|
static constexpr unsigned MAX_NO_LOGFILE = 999; /**< Maximum number of log files */
|
||||||
#ifdef __PX4_POSIX
|
static constexpr const char *LOG_ROOT = PX4_STORAGEDIR "/log";
|
||||||
static constexpr const char *LOG_ROOT = PX4_ROOTFSDIR"/log";
|
|
||||||
#else
|
|
||||||
static constexpr const char *LOG_ROOT = PX4_ROOTFSDIR"/fs/microsd/log";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
uint8_t *_msg_buffer{nullptr};
|
uint8_t *_msg_buffer{nullptr};
|
||||||
int _msg_buffer_len{0};
|
int _msg_buffer_len{0};
|
||||||
|
|||||||
@@ -663,7 +663,7 @@ MavlinkFTP::_workTruncateFile(PayloadHeader *payload)
|
|||||||
|
|
||||||
// emulate truncate(_work_buffer1, payload->offset) by
|
// emulate truncate(_work_buffer1, payload->offset) by
|
||||||
// copying to temp and overwrite with O_TRUNC flag (NuttX does not support truncate()).
|
// copying to temp and overwrite with O_TRUNC flag (NuttX does not support truncate()).
|
||||||
const char temp_file[] = PX4_ROOTFSDIR"/fs/microsd/.trunc.tmp";
|
const char temp_file[] = PX4_STORAGEDIR"/.trunc.tmp";
|
||||||
|
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,7 @@
|
|||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
#define MOUNTPOINT PX4_ROOTFSDIR "/fs/microsd"
|
#define MOUNTPOINT PX4_STORAGEDIR
|
||||||
|
|
||||||
static const char *kLogRoot = MOUNTPOINT "/log";
|
static const char *kLogRoot = MOUNTPOINT "/log";
|
||||||
static const char *kLogData = MOUNTPOINT "/logdata.txt";
|
static const char *kLogData = MOUNTPOINT "/logdata.txt";
|
||||||
|
|||||||
@@ -443,7 +443,7 @@ void
|
|||||||
MavlinkReceiver::send_storage_information(int storage_id)
|
MavlinkReceiver::send_storage_information(int storage_id)
|
||||||
{
|
{
|
||||||
mavlink_storage_information_t storage_info{};
|
mavlink_storage_information_t storage_info{};
|
||||||
const char *microsd_dir = PX4_ROOTFSDIR"/fs/microsd";
|
const char *microsd_dir = PX4_STORAGEDIR;
|
||||||
|
|
||||||
if (storage_id == 0 || storage_id == 1) { // request is for all or the first storage
|
if (storage_id == 0 || storage_id == 1) { // request is for all or the first storage
|
||||||
storage_info.storage_id = 1;
|
storage_info.storage_id = 1;
|
||||||
|
|||||||
@@ -55,8 +55,8 @@ const MavlinkFtpTest::DownloadTestCase MavlinkFtpTest::_rgDownloadTestCases[] =
|
|||||||
{ PX4_MAVLINK_TEST_DATA_DIR "/unit_test_data/mavlink_tests/test_240.data", MAVLINK_MSG_FILE_TRANSFER_PROTOCOL_FIELD_PAYLOAD_LEN - sizeof(MavlinkFTP::PayloadHeader) + 1, false, false }, // Read take two packets
|
{ PX4_MAVLINK_TEST_DATA_DIR "/unit_test_data/mavlink_tests/test_240.data", MAVLINK_MSG_FILE_TRANSFER_PROTOCOL_FIELD_PAYLOAD_LEN - sizeof(MavlinkFTP::PayloadHeader) + 1, false, false }, // Read take two packets
|
||||||
};
|
};
|
||||||
|
|
||||||
const char MavlinkFtpTest::_unittest_microsd_dir[] = PX4_ROOTFSDIR "/fs/microsd/ftp_unit_test_dir";
|
const char MavlinkFtpTest::_unittest_microsd_dir[] = PX4_STORAGEDIR "/ftp_unit_test_dir";
|
||||||
const char MavlinkFtpTest::_unittest_microsd_file[] = PX4_ROOTFSDIR "/fs/microsd/ftp_unit_test_dir/file";
|
const char MavlinkFtpTest::_unittest_microsd_file[] = PX4_STORAGEDIR "/ftp_unit_test_dir/file";
|
||||||
|
|
||||||
MavlinkFtpTest::MavlinkFtpTest() :
|
MavlinkFtpTest::MavlinkFtpTest() :
|
||||||
_ftp_server(nullptr),
|
_ftp_server(nullptr),
|
||||||
|
|||||||
@@ -52,7 +52,7 @@
|
|||||||
#include <uORB/topics/vehicle_gps_position.h>
|
#include <uORB/topics/vehicle_gps_position.h>
|
||||||
#include <uORB/topics/vehicle_air_data.h>
|
#include <uORB/topics/vehicle_air_data.h>
|
||||||
|
|
||||||
#define GEOFENCE_FILENAME PX4_ROOTFSDIR"/fs/microsd/etc/geofence.txt"
|
#define GEOFENCE_FILENAME PX4_STORAGEDIR"/etc/geofence.txt"
|
||||||
|
|
||||||
class Navigator;
|
class Navigator;
|
||||||
|
|
||||||
|
|||||||
@@ -191,11 +191,7 @@ static void write_debug_log(const char *msg, float dt, float x_est[2], float y_e
|
|||||||
float acc[3], float corr_gps[3][2], float w_xy_gps_p, float w_xy_gps_v, float corr_mocap[3][1], float w_mocap_p,
|
float acc[3], float corr_gps[3][2], float w_xy_gps_p, float w_xy_gps_v, float corr_mocap[3][1], float w_mocap_p,
|
||||||
float corr_vision[3][2], float w_xy_vision_p, float w_z_vision_p, float w_xy_vision_v)
|
float corr_vision[3][2], float w_xy_vision_p, float w_z_vision_p, float w_xy_vision_v)
|
||||||
{
|
{
|
||||||
#ifdef __PX4_POSIX
|
FILE *f = fopen(PX4_STORAGEDIR"/inav.log", "a");
|
||||||
FILE *f = fopen(PX4_ROOTFSDIR"/inav.log", "a");
|
|
||||||
#else
|
|
||||||
FILE *f = fopen(PX4_ROOTFSDIR"/fs/microsd/inav.log", "a");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (f) {
|
if (f) {
|
||||||
char *s = malloc(256);
|
char *s = malloc(256);
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ bool uORB::Manager::initialize()
|
|||||||
uORB::Manager::Manager()
|
uORB::Manager::Manager()
|
||||||
{
|
{
|
||||||
#ifdef ORB_USE_PUBLISHER_RULES
|
#ifdef ORB_USE_PUBLISHER_RULES
|
||||||
const char *file_name = "./rootfs/orb_publisher.rules";
|
const char *file_name = PX4_STORAGEDIR"/orb_publisher.rules";
|
||||||
int ret = readPublisherRulesFromFile(file_name, _publisher_rule);
|
int ret = readPublisherRulesFromFile(file_name, _publisher_rule);
|
||||||
|
|
||||||
if (ret == PX4_OK) {
|
if (ret == PX4_OK) {
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ int uORBTest::UnitTest::pubsublatency_main()
|
|||||||
|
|
||||||
if (pubsubtest_print) {
|
if (pubsubtest_print) {
|
||||||
char fname[32];
|
char fname[32];
|
||||||
sprintf(fname, PX4_ROOTFSDIR"/fs/microsd/timings%u.txt", timingsgroup);
|
sprintf(fname, PX4_STORAGEDIR"/uorb_timings%u.txt", timingsgroup);
|
||||||
FILE *f = fopen(fname, "w");
|
FILE *f = fopen(fname, "w");
|
||||||
|
|
||||||
if (f == nullptr) {
|
if (f == nullptr) {
|
||||||
|
|||||||
@@ -110,7 +110,8 @@ typedef param_t px4_param_t;
|
|||||||
* NuttX specific defines.
|
* NuttX specific defines.
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#define PX4_ROOTFSDIR "."
|
#define PX4_ROOTFSDIR ""
|
||||||
|
#define PX4_STORAGEDIR PX4_ROOTFSDIR "/fs/microsd"
|
||||||
#define _PX4_IOC(x,y) _IOC(x,y)
|
#define _PX4_IOC(x,y) _IOC(x,y)
|
||||||
|
|
||||||
// mode for open with O_CREAT
|
// mode for open with O_CREAT
|
||||||
@@ -200,6 +201,8 @@ __END_DECLS
|
|||||||
# endif
|
# endif
|
||||||
|
|
||||||
#endif // __PX4_QURT
|
#endif // __PX4_QURT
|
||||||
|
|
||||||
|
#define PX4_STORAGEDIR PX4_ROOTFSDIR
|
||||||
#endif // __PX4_POSIX
|
#endif // __PX4_POSIX
|
||||||
|
|
||||||
#if defined(__PX4_ROS) || defined(__PX4_POSIX)
|
#if defined(__PX4_ROS) || defined(__PX4_POSIX)
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ static inline unsigned int time_fsync(int fd);
|
|||||||
|
|
||||||
__EXPORT int sd_bench_main(int argc, char *argv[]);
|
__EXPORT int sd_bench_main(int argc, char *argv[]);
|
||||||
|
|
||||||
static const char *BENCHMARK_FILE = PX4_ROOTFSDIR"/fs/microsd/benchmark.tmp";
|
static const char *BENCHMARK_FILE = PX4_STORAGEDIR"/benchmark.tmp";
|
||||||
|
|
||||||
static int num_runs; ///< number of runs
|
static int num_runs; ///< number of runs
|
||||||
static int run_duration; ///< duration of a single run [ms]
|
static int run_duration; ///< duration of a single run [ms]
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ test_file(int argc, char *argv[])
|
|||||||
/* check if microSD card is mounted */
|
/* check if microSD card is mounted */
|
||||||
struct stat buffer;
|
struct stat buffer;
|
||||||
|
|
||||||
if (stat(PX4_ROOTFSDIR "/fs/microsd/", &buffer)) {
|
if (stat(PX4_STORAGEDIR "/", &buffer)) {
|
||||||
warnx("no microSD card mounted, aborting file test");
|
warnx("no microSD card mounted, aborting file test");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -126,7 +126,7 @@ test_file(int argc, char *argv[])
|
|||||||
uint8_t read_buf[chunk_sizes[c] + alignments] __attribute__((aligned(64)));
|
uint8_t read_buf[chunk_sizes[c] + alignments] __attribute__((aligned(64)));
|
||||||
hrt_abstime start, end;
|
hrt_abstime start, end;
|
||||||
|
|
||||||
int fd = px4_open(PX4_ROOTFSDIR "/fs/microsd/testfile", O_TRUNC | O_WRONLY | O_CREAT);
|
int fd = px4_open(PX4_STORAGEDIR "/testfile", O_TRUNC | O_WRONLY | O_CREAT);
|
||||||
|
|
||||||
warnx("testing unaligned writes - please wait..");
|
warnx("testing unaligned writes - please wait..");
|
||||||
|
|
||||||
@@ -158,7 +158,7 @@ test_file(int argc, char *argv[])
|
|||||||
warnx("write took %" PRIu64 " us", (end - start));
|
warnx("write took %" PRIu64 " us", (end - start));
|
||||||
|
|
||||||
px4_close(fd);
|
px4_close(fd);
|
||||||
fd = open(PX4_ROOTFSDIR "/fs/microsd/testfile", O_RDONLY);
|
fd = open(PX4_STORAGEDIR "/testfile", O_RDONLY);
|
||||||
|
|
||||||
/* read back data for validation */
|
/* read back data for validation */
|
||||||
for (unsigned i = 0; i < iterations; i++) {
|
for (unsigned i = 0; i < iterations; i++) {
|
||||||
@@ -196,8 +196,8 @@ test_file(int argc, char *argv[])
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
close(fd);
|
close(fd);
|
||||||
int ret = unlink(PX4_ROOTFSDIR "/fs/microsd/testfile");
|
int ret = unlink(PX4_STORAGEDIR "/testfile");
|
||||||
fd = px4_open(PX4_ROOTFSDIR "/fs/microsd/testfile", O_TRUNC | O_WRONLY | O_CREAT);
|
fd = px4_open(PX4_STORAGEDIR "/testfile", O_TRUNC | O_WRONLY | O_CREAT);
|
||||||
|
|
||||||
warnx("testing aligned writes - please wait.. (CTRL^C to abort)");
|
warnx("testing aligned writes - please wait.. (CTRL^C to abort)");
|
||||||
|
|
||||||
@@ -220,7 +220,7 @@ test_file(int argc, char *argv[])
|
|||||||
warnx("reading data aligned..");
|
warnx("reading data aligned..");
|
||||||
|
|
||||||
px4_close(fd);
|
px4_close(fd);
|
||||||
fd = open(PX4_ROOTFSDIR "/fs/microsd/testfile", O_RDONLY);
|
fd = open(PX4_STORAGEDIR "/testfile", O_RDONLY);
|
||||||
|
|
||||||
bool align_read_ok = true;
|
bool align_read_ok = true;
|
||||||
|
|
||||||
@@ -257,7 +257,7 @@ test_file(int argc, char *argv[])
|
|||||||
warnx("reading data unaligned..");
|
warnx("reading data unaligned..");
|
||||||
|
|
||||||
close(fd);
|
close(fd);
|
||||||
fd = open(PX4_ROOTFSDIR "/fs/microsd/testfile", O_RDONLY);
|
fd = open(PX4_STORAGEDIR "/testfile", O_RDONLY);
|
||||||
|
|
||||||
bool unalign_read_ok = true;
|
bool unalign_read_ok = true;
|
||||||
int unalign_read_err_count = 0;
|
int unalign_read_err_count = 0;
|
||||||
@@ -298,7 +298,7 @@ test_file(int argc, char *argv[])
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = unlink(PX4_ROOTFSDIR "/fs/microsd/testfile");
|
ret = unlink(PX4_STORAGEDIR "/testfile");
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
@@ -311,7 +311,7 @@ test_file(int argc, char *argv[])
|
|||||||
/* list directory */
|
/* list directory */
|
||||||
DIR *d;
|
DIR *d;
|
||||||
struct dirent *dir;
|
struct dirent *dir;
|
||||||
d = opendir(PX4_ROOTFSDIR "/fs/microsd");
|
d = opendir(PX4_STORAGEDIR);
|
||||||
|
|
||||||
if (d) {
|
if (d) {
|
||||||
|
|
||||||
|
|||||||
@@ -54,11 +54,7 @@
|
|||||||
#define FLAG_FSYNC 1
|
#define FLAG_FSYNC 1
|
||||||
#define FLAG_LSEEK 2
|
#define FLAG_LSEEK 2
|
||||||
|
|
||||||
#ifdef __PX4_POSIX
|
#define LOG_PATH PX4_STORAGEDIR
|
||||||
#define LOG_PATH PX4_ROOTFSDIR "/log/"
|
|
||||||
#else
|
|
||||||
#define LOG_PATH PX4_ROOTFSDIR "/fs/microsd/"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
return a predictable value for any file offset to allow detection of corruption
|
return a predictable value for any file offset to allow detection of corruption
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ test_mount(int argc, char *argv[])
|
|||||||
/* check if microSD card is mounted */
|
/* check if microSD card is mounted */
|
||||||
struct stat buffer;
|
struct stat buffer;
|
||||||
|
|
||||||
if (stat(PX4_ROOTFSDIR "/fs/microsd/", &buffer)) {
|
if (stat(PX4_STORAGEDIR "/", &buffer)) {
|
||||||
PX4_ERR("no microSD card mounted, aborting file test");
|
PX4_ERR("no microSD card mounted, aborting file test");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -78,7 +78,7 @@ test_mount(int argc, char *argv[])
|
|||||||
/* list directory */
|
/* list directory */
|
||||||
DIR *d;
|
DIR *d;
|
||||||
struct dirent *dir;
|
struct dirent *dir;
|
||||||
d = opendir(PX4_ROOTFSDIR "/fs/microsd");
|
d = opendir(PX4_STORAGEDIR);
|
||||||
|
|
||||||
if (d) {
|
if (d) {
|
||||||
|
|
||||||
@@ -202,7 +202,7 @@ test_mount(int argc, char *argv[])
|
|||||||
|
|
||||||
uint8_t read_buf[chunk_sizes[c] + alignments] __attribute__((aligned(64)));
|
uint8_t read_buf[chunk_sizes[c] + alignments] __attribute__((aligned(64)));
|
||||||
|
|
||||||
int fd = px4_open(PX4_ROOTFSDIR "/fs/microsd/testfile", O_TRUNC | O_WRONLY | O_CREAT);
|
int fd = px4_open(PX4_STORAGEDIR "/testfile", O_TRUNC | O_WRONLY | O_CREAT);
|
||||||
|
|
||||||
for (unsigned i = 0; i < iterations; i++) {
|
for (unsigned i = 0; i < iterations; i++) {
|
||||||
|
|
||||||
@@ -239,7 +239,7 @@ test_mount(int argc, char *argv[])
|
|||||||
usleep(200000);
|
usleep(200000);
|
||||||
|
|
||||||
px4_close(fd);
|
px4_close(fd);
|
||||||
fd = px4_open(PX4_ROOTFSDIR "/fs/microsd/testfile", O_RDONLY);
|
fd = px4_open(PX4_STORAGEDIR "/testfile", O_RDONLY);
|
||||||
|
|
||||||
/* read back data for validation */
|
/* read back data for validation */
|
||||||
for (unsigned i = 0; i < iterations; i++) {
|
for (unsigned i = 0; i < iterations; i++) {
|
||||||
@@ -268,7 +268,7 @@ test_mount(int argc, char *argv[])
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int ret = unlink(PX4_ROOTFSDIR "/fs/microsd/testfile");
|
int ret = unlink(PX4_STORAGEDIR "/testfile");
|
||||||
px4_close(fd);
|
px4_close(fd);
|
||||||
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
|
|||||||
@@ -312,7 +312,7 @@ bool ParameterTest::exportImportAll()
|
|||||||
static constexpr float MAGIC_FLOAT_VAL = 0.217828f;
|
static constexpr float MAGIC_FLOAT_VAL = 0.217828f;
|
||||||
|
|
||||||
// backup current parameters
|
// backup current parameters
|
||||||
const char *param_file_name = PX4_ROOTFSDIR "/fs/microsd/param_backup";
|
const char *param_file_name = PX4_STORAGEDIR "/param_backup";
|
||||||
int fd = open(param_file_name, O_WRONLY | O_CREAT, PX4_O_MODE_666);
|
int fd = open(param_file_name, O_WRONLY | O_CREAT, PX4_O_MODE_666);
|
||||||
|
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user