Firmware
Classes | Macros | Typedefs | Enumerations | Functions | Variables
dataman.cpp File Reference

DATAMANAGER driver. More...

#include <px4_config.h>
#include <px4_defines.h>
#include <px4_module.h>
#include <px4_posix.h>
#include <px4_tasks.h>
#include <px4_getopt.h>
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <errno.h>
#include <fcntl.h>
#include <systemlib/err.h>
#include <queue.h>
#include <string.h>
#include <semaphore.h>
#include <unistd.h>
#include <drivers/drv_hrt.h>
#include "dataman.h"
#include <parameters/param.h>

Classes

struct  dm_operations_t
 
struct  work_q_item_t
 Work task work item. More...
 
struct  work_q_t
 

Macros

#define DM_SECTOR_HDR_SIZE   4 /* data manager per item header overhead */
 

Typedefs

typedef struct dm_operations_t dm_operations_t
 

Enumerations

enum  dm_function_t {
  dm_write_func = 0, dm_read_func, dm_clear_func, dm_restart_func,
  dm_number_of_funcs
}
 Types of function calls supported by the worker task.
 
enum  { BACKEND_NONE = 0, BACKEND_FILE, BACKEND_RAM, BACKEND_LAST }
 

Functions

__BEGIN_DECLS __EXPORT int dataman_main (int argc, char *argv[])
 
__EXPORT ssize_t dm_write (dm_item_t item, unsigned index, dm_persitence_t persistence, const void *buf, size_t count)
 Write to the data manager file. More...
 
__EXPORT ssize_t dm_read (dm_item_t item, unsigned index, void *buf, size_t count)
 Retrieve from the data manager file. More...
 
__EXPORT int dm_clear (dm_item_t item)
 Clear a data Item. More...
 
__EXPORT int dm_lock (dm_item_t item)
 Lock all items of a type. More...
 
__EXPORT int dm_trylock (dm_item_t item)
 Try to lock all items of a type (. More...
 
__EXPORT void dm_unlock (dm_item_t item)
 Unlock a data Item. More...
 
__EXPORT int dm_restart (dm_reset_reason reason)
 Tell the data manager about the type of the last reset.
 

Variables

const size_t k_work_item_allocation_chunk_size = 8
 

Detailed Description

DATAMANAGER driver.

Author
Jean Cyr
Lorenz Meier
Julian Oes
Thomas Gubler
David Sidrane

Function Documentation

§ dm_clear()

__EXPORT int dm_clear ( dm_item_t  item)

Clear a data Item.

Erase all items of this type.

§ dm_lock()

__EXPORT int dm_lock ( dm_item_t  item)

Lock all items of a type.

Can be used for atomic updates of multiple items (single items are always updated atomically). Note that this lock is independent from dm_read & dm_write calls.

Returns
0 on success and lock taken, -1 on error (lock not taken, errno set)

§ dm_read()

__EXPORT ssize_t dm_read ( dm_item_t  item,
unsigned  index,
void *  buf,
size_t  count 
)

Retrieve from the data manager file.

Retrieve from the data manager store.

§ dm_trylock()

__EXPORT int dm_trylock ( dm_item_t  item)

Try to lock all items of a type (.

See also
sem_trywait()).
Returns
0 if lock is taken, -1 otherwise (on error or if already locked. errno is set accordingly)

§ dm_unlock()

__EXPORT void dm_unlock ( dm_item_t  item)

Unlock a data Item.

Unlock all items of a type.

§ dm_write()

__EXPORT ssize_t dm_write ( dm_item_t  item,
unsigned  index,
dm_persitence_t  persistence,
const void *  buf,
size_t  count 
)

Write to the data manager file.

write to the data manager store