Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
Firmware
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alberto Ruiz Garcia
Firmware
Commits
5481b91e
Commit
5481b91e
authored
11 years ago
by
Lorenz Meier
Browse files
Options
Downloads
Plain Diff
Merge pull request #854 from jean-m-cyr/master
Reduce data manager SD card wear and tear
parents
af336603
bf4558c3
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/modules/dataman/dataman.c
+17
-2
17 additions, 2 deletions
src/modules/dataman/dataman.c
src/modules/dataman/dataman.h
+1
-1
1 addition, 1 deletion
src/modules/dataman/dataman.h
with
18 additions
and
3 deletions
src/modules/dataman/dataman.c
+
17
−
2
View file @
5481b91e
...
...
@@ -44,7 +44,9 @@
#include
<stdlib.h>
#include
<fcntl.h>
#include
<systemlib/systemlib.h>
#include
<systemlib/err.h>
#include
<queue.h>
#include
<string.h>
#include
"dataman.h"
...
...
@@ -594,6 +596,20 @@ task_main(int argc, char *argv[])
sem_init
(
&
g_work_queued_sema
,
1
,
0
);
/* See if the data manage file exists and is a multiple of the sector size */
g_task_fd
=
open
(
k_data_manager_device_path
,
O_RDONLY
|
O_BINARY
);
if
(
g_task_fd
>=
0
)
{
/* File exists, check its size */
int
file_size
=
lseek
(
g_task_fd
,
0
,
SEEK_END
);
if
((
file_size
%
k_sector_size
)
!=
0
)
{
warnx
(
"Incompatible data manager file %s, resetting it"
,
k_data_manager_device_path
);
close
(
g_task_fd
);
unlink
(
k_data_manager_device_path
);
}
else
close
(
g_task_fd
);
}
/* Open or create the data manager file */
g_task_fd
=
open
(
k_data_manager_device_path
,
O_RDWR
|
O_CREAT
|
O_BINARY
);
...
...
@@ -603,7 +619,7 @@ task_main(int argc, char *argv[])
return
-
1
;
}
if
(
lseek
(
g_task_fd
,
max_offset
,
SEEK_SET
)
!=
max_offset
)
{
if
(
(
unsigned
)
lseek
(
g_task_fd
,
max_offset
,
SEEK_SET
)
!=
max_offset
)
{
close
(
g_task_fd
);
warnx
(
"Could not seek data manager file %s"
,
k_data_manager_device_path
);
sem_post
(
&
g_init_sema
);
/* Don't want to hang startup */
...
...
@@ -776,4 +792,3 @@ dataman_main(int argc, char *argv[])
exit
(
1
);
}
This diff is collapsed.
Click to expand it.
src/modules/dataman/dataman.h
+
1
−
1
View file @
5481b91e
...
...
@@ -79,7 +79,7 @@ extern "C" {
}
dm_reset_reason
;
/* Maximum size in bytes of a single item instance */
#define DM_MAX_DATA_SIZE 12
6
#define DM_MAX_DATA_SIZE 12
4
/* Retrieve from the data manager store */
__EXPORT
ssize_t
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment