mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-05-26 16:30:07 +08:00
[arch/linux] implement persistent settings
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2009-2013 The Paparazzi Team
|
||||
* Copyright (C) 2009-2015 The Paparazzi Team
|
||||
*
|
||||
* This file is part of paparazzi.
|
||||
*
|
||||
@@ -23,21 +23,37 @@
|
||||
* @file arch/linux/subsystems/settings_arch.c
|
||||
* linux arch Persistent settings.
|
||||
*
|
||||
* Unimplemented.
|
||||
* Saves the PersistentSettings struct to a binary file.
|
||||
*/
|
||||
|
||||
#include "subsystems/settings.h"
|
||||
#include <stdio.h>
|
||||
|
||||
/** Default file used to store persistent settings */
|
||||
#ifndef PERSISTENT_SETTINGS_FILE
|
||||
#define PERSISTENT_SETTINGS_FILE "pprz_persistent_settings.binary"
|
||||
#endif
|
||||
|
||||
int32_t persistent_write(uint32_t ptr, uint32_t size)
|
||||
{
|
||||
ptr = ptr;
|
||||
size = size;
|
||||
FILE *file= fopen(PERSISTENT_SETTINGS_FILE, "wb");
|
||||
if (file != NULL) {
|
||||
fwrite(ptr, size, 1, file);
|
||||
fclose(file);
|
||||
return 0;
|
||||
}
|
||||
printf("Could not open settings file %s to write!\n", PERSISTENT_SETTINGS_FILE);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int32_t persistent_read(uint32_t ptr, uint32_t size)
|
||||
{
|
||||
ptr = ptr;
|
||||
size = size;
|
||||
FILE *file= fopen(PERSISTENT_SETTINGS_FILE, "rb");
|
||||
if (file != NULL) {
|
||||
fread(ptr, size, 1, file);
|
||||
fclose(file);
|
||||
return 0;
|
||||
}
|
||||
printf("Could not open settings file %s to read!\n", PERSISTENT_SETTINGS_FILE);
|
||||
return -1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user