save failed integration state
This commit is contained in:
@ -0,0 +1,15 @@
|
||||
#ifndef PARAM_PARAM_CLIENT_H
|
||||
#define PARAM_PARAM_CLIENT_H
|
||||
/* Copyright (c) 2013-2018 GomSpace A/S. All rights reserved. */
|
||||
/**
|
||||
@file
|
||||
|
||||
Legacy/deprecated include of header files for libparam client.
|
||||
*/
|
||||
|
||||
#include <param/param_serializer.h>
|
||||
#include <param/param_string.h>
|
||||
#include <param/param_lock.h>
|
||||
#include <param/rparam_client.h>
|
||||
|
||||
#endif
|
@ -0,0 +1,27 @@
|
||||
/* Copyright (c) 2013-2017 GomSpace A/S. All rights reserved. */
|
||||
/**
|
||||
* GomSpace Parameter System.
|
||||
*/
|
||||
#ifndef PARAM_PARAM_LOCK_H_
|
||||
#define PARAM_PARAM_LOCK_H_
|
||||
|
||||
#include <gs/param/table.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
static inline void param_lock(param_index_t * mem)
|
||||
{
|
||||
gs_param_table_lock((gs_param_table_instance_t *) mem);
|
||||
}
|
||||
|
||||
static inline void param_unlock(param_index_t * mem)
|
||||
{
|
||||
gs_param_table_unlock((gs_param_table_instance_t *) mem);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
@ -0,0 +1,55 @@
|
||||
#ifndef PARAM_PARAM_SERIALIZER_H
|
||||
#define PARAM_PARAM_SERIALIZER_H
|
||||
/* Copyright (c) 2013-2018 GomSpace A/S. All rights reserved. */
|
||||
/**
|
||||
* GomSpace Parameter System
|
||||
*/
|
||||
|
||||
#include <param/param_types.h>
|
||||
#include <gs/param/serialize.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef gs_param_serialize_flags_t param_serializer_flags;
|
||||
|
||||
static inline int param_betoh(param_type_t type, void * item)
|
||||
{
|
||||
return gs_param_betoh(type, item);
|
||||
}
|
||||
|
||||
static inline int param_htobe(param_type_t type, void * item)
|
||||
{
|
||||
return gs_param_htobe(type, item);
|
||||
}
|
||||
|
||||
static inline int param_serialize_full_table(param_index_t * mem, unsigned int *start, uint8_t * buf, unsigned int maxbuflen, param_serializer_flags flags)
|
||||
{
|
||||
unsigned int buf_pos = 0;
|
||||
gs_error_t error = gs_param_serialize_full_table((gs_param_table_instance_t *) mem, start, flags, buf, maxbuflen, &buf_pos);
|
||||
return (error == GS_OK) ? (int) buf_pos : -1;
|
||||
}
|
||||
|
||||
static inline gs_error_t param_serialize_item(const param_table_t * param, uint16_t addr, uint8_t * buf, uint16_t * pos, unsigned int maxlen, void * item, param_serializer_flags flags)
|
||||
{
|
||||
unsigned int tmp_pos = *pos;
|
||||
gs_error_t error = gs_param_serialize_item((const gs_param_table_row_t*) param, addr, item, flags, buf, maxlen, &tmp_pos);
|
||||
*pos = tmp_pos;
|
||||
return (error == GS_OK) ? 0 : -1;
|
||||
}
|
||||
|
||||
static inline gs_error_t param_deserialize(param_index_t * mem, uint8_t * buf, int len, param_serializer_flags flags)
|
||||
{
|
||||
return (gs_param_deserialize((gs_param_table_instance_t *) mem, buf, len, flags) == GS_OK) ? 0 : -1;
|
||||
}
|
||||
|
||||
static inline gs_error_t param_deserialize_item(const param_table_t * param, uint16_t addr, param_index_t * mem, void * item, param_serializer_flags flags)
|
||||
{
|
||||
return (gs_param_deserialize_item((gs_param_table_instance_t *) mem, (const gs_param_table_row_t*)param, addr, item, flags) == GS_OK) ? 0 : -1;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
@ -0,0 +1,74 @@
|
||||
#ifndef PARAM_PARAM_STRING_H
|
||||
#define PARAM_PARAM_STRING_H
|
||||
/* Copyright (c) 2013-2018 GomSpace A/S. All rights reserved. */
|
||||
/**
|
||||
* GomSpace Parameter System
|
||||
*/
|
||||
|
||||
#include <param/param_types.h>
|
||||
#include <gs/param/table.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef union {
|
||||
const param_table_t * row3;
|
||||
const gs_param_table_row_t * row4;
|
||||
} gs_param_row_align_t;
|
||||
|
||||
static inline const param_table_t * param_find_name(const param_table_t rows[], size_t row_count, const char * name)
|
||||
{
|
||||
gs_param_row_align_t row_in = {.row3 = rows};
|
||||
gs_param_row_align_t row_out = {.row4 = gs_param_row_by_name(name, row_in.row4, row_count)};
|
||||
return row_out.row3;
|
||||
}
|
||||
|
||||
static inline const param_table_t * param_find_addr(const param_table_t rows[], size_t row_count, uint16_t addr)
|
||||
{
|
||||
gs_param_row_align_t row_in = {.row3 = rows};
|
||||
gs_param_row_align_t row_out = {.row4 = gs_param_row_by_address(addr, row_in.row4, row_count)};
|
||||
return row_out.row3;
|
||||
}
|
||||
|
||||
static inline void param_list_single(param_table_t * param, param_index_t * mem, int do_read)
|
||||
{
|
||||
gs_param_list_single((gs_param_table_instance_t *) mem, (const gs_param_table_row_t *) param, (do_read != 0));
|
||||
}
|
||||
|
||||
static inline void param_list(param_index_t * mem, int do_read)
|
||||
{
|
||||
gs_param_list((gs_param_table_instance_t *) mem, (do_read != 0));
|
||||
}
|
||||
|
||||
static inline gs_error_t param_from_string(const param_table_t * param , const char * string, void * value)
|
||||
{
|
||||
return gs_param_from_string((const gs_param_table_row_t *)param , string, value);
|
||||
}
|
||||
|
||||
static inline int param_to_string(const param_table_t * param, char * buf, int pos, const void * value, int with_type, int max_size)
|
||||
{
|
||||
unsigned int written = 0;
|
||||
gs_param_to_string((const gs_param_table_row_t *)param, value, with_type, buf, max_size, pos, &written);
|
||||
return (int) written;
|
||||
}
|
||||
|
||||
static inline const char * param_type_to_string(param_type_t type)
|
||||
{
|
||||
return gs_param_type_to_string(type);
|
||||
}
|
||||
|
||||
static inline uint16_t param_index_chksum(param_index_t * mem)
|
||||
{
|
||||
return gs_param_table_checksum((gs_param_table_instance_t*)mem);
|
||||
}
|
||||
|
||||
static inline uint16_t param_index_chksum2(param_index_t * mem)
|
||||
{
|
||||
return gs_param_table_checksum2((gs_param_table_instance_t*)mem);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
@ -0,0 +1,92 @@
|
||||
#ifndef PARAM_PARAM_TYPES_H
|
||||
#define PARAM_PARAM_TYPES_H
|
||||
/* Copyright (c) 2013-2018 GomSpace A/S. All rights reserved. */
|
||||
/**
|
||||
@file
|
||||
|
||||
Legacy/deprecated parameter types and definitions - use <gs/param/types.h>.
|
||||
*/
|
||||
|
||||
#include <gs/param/table.h>
|
||||
#include <gs/param/rparam.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define MAX_PARAM_NAME_LEN GS_PARAM_MAX_NAME
|
||||
|
||||
/*
|
||||
Legacy parameter type definition - matches gs_param_type_t exactly.
|
||||
*/
|
||||
typedef gs_param_type_t param_type_t;
|
||||
|
||||
/*
|
||||
Legacy table row definition - matches gs_param_table_row_t exactly.
|
||||
*/
|
||||
typedef struct param_table_s {
|
||||
uint16_t addr;
|
||||
param_type_t type;
|
||||
uint8_t size;
|
||||
uint8_t count; // -> array_size
|
||||
uint8_t flags;
|
||||
char name[MAX_PARAM_NAME_LEN];
|
||||
} param_table_t;
|
||||
|
||||
#define PARAM_COUNT gs_max(GS_PGM_UINT8((param)->count), 1)
|
||||
#define PARAM_SIZE GS_PARAM_SIZE(param)
|
||||
#define PARAM_TYPE GS_PARAM_TYPE(param)
|
||||
#define PARAM_ADDR GS_PARAM_ADDR(param)
|
||||
#define PARAM_FLAGS GS_PARAM_FLAGS(param)
|
||||
|
||||
#define RPARAM_QUERY_MAX_LEN GS_RPARAM_MAX_QUERY
|
||||
|
||||
#define PARAM_MAX_FILESIZE 0x400
|
||||
|
||||
struct param_index_s;
|
||||
|
||||
/*
|
||||
Legacy callback - matches gs_param_callback_func_t exactly.
|
||||
*/
|
||||
typedef void (*param_callback_func)(uint16_t addr, struct param_index_s * index);
|
||||
|
||||
typedef gs_param_table_id_t param_mem;
|
||||
|
||||
/*
|
||||
Legacy table instance definition - matches gs_param_table_instance_t exactly.
|
||||
*/
|
||||
typedef struct param_index_s {
|
||||
const char * name;
|
||||
param_mem mem_id;
|
||||
const param_table_t * table;
|
||||
unsigned int count;
|
||||
void * physaddr;
|
||||
unsigned int size;
|
||||
const gs_param_function_interface_t function_interface;
|
||||
const uint16_t table_chksum;
|
||||
const uint16_t chksum2;
|
||||
const uint16_t checksum_le;
|
||||
const gs_mutex_t lock;
|
||||
param_callback_func callback;
|
||||
const char * const var1;
|
||||
const char * const var2;
|
||||
const void * const var3;
|
||||
const void * const var4;
|
||||
const void * const var5;
|
||||
const void * const var6;
|
||||
const void * const var7;
|
||||
const uint32_t var8;
|
||||
} param_index_t;
|
||||
|
||||
/**
|
||||
Return base size of a parameter type.
|
||||
*/
|
||||
static inline uint8_t param_type_size(param_type_t type)
|
||||
{
|
||||
return gs_param_type_size(type);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
@ -0,0 +1,208 @@
|
||||
#ifndef PARAM_RPARAM_CLIENT_H
|
||||
#define PARAM_RPARAM_CLIENT_H
|
||||
/* Copyright (c) 2013-2018 GomSpace A/S. All rights reserved. */
|
||||
/**
|
||||
* GomSpace Parameter System
|
||||
*/
|
||||
|
||||
#include <param/param_types.h>
|
||||
#include <gs/param/rparam.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
Legacy magic checksum.
|
||||
@deprecated use #GS_RPARAM_MAGIC_CHECKSUM (if remote products supports it).
|
||||
*/
|
||||
#define GS_RPARAM_LEGACY_MAGIC_CHECKSUM 0xb00b
|
||||
|
||||
static inline int rparam_get_full_table(param_index_t* idx, int node, int port, int index_id, uint32_t timeout_ms)
|
||||
{
|
||||
return (gs_rparam_get_full_table((gs_param_table_instance_t *) idx,
|
||||
node,
|
||||
index_id,
|
||||
GS_RPARAM_LEGACY_MAGIC_CHECKSUM,
|
||||
timeout_ms) == GS_OK) ? 0 : -1;
|
||||
}
|
||||
|
||||
static inline int rparam_download_table_spec_from_remote_and_save_to_file2(const char* fname, uint8_t node, uint8_t port, param_index_t* idx, uint16_t* return_checksum, uint32_t timeout_ms)
|
||||
{
|
||||
return (gs_rparam_download_table_spec((gs_param_table_instance_t *) idx,
|
||||
fname,
|
||||
node,
|
||||
idx->mem_id,
|
||||
timeout_ms,
|
||||
return_checksum) == GS_OK) ? 0 : -1;
|
||||
}
|
||||
|
||||
static inline int rparam_download_table_spec_from_remote_and_save_to_file(const char* fname, uint8_t node, uint8_t port, param_index_t* idx, uint16_t* checksum)
|
||||
{
|
||||
return rparam_download_table_spec_from_remote_and_save_to_file2(fname, node, port, idx, checksum, 10000);
|
||||
}
|
||||
|
||||
static inline int rparam_load_table_spec_from_file(const char* fname, param_index_t* idx, uint16_t* return_checksum)
|
||||
{
|
||||
return (gs_rparam_load_table_spec((gs_param_table_instance_t *) idx, fname, return_checksum) == GS_OK) ? 0 : -1;
|
||||
}
|
||||
|
||||
static inline int rparam_get_single(void * out, uint16_t addr, param_type_t type, int size, int mem_id, int node, int port, uint32_t timeout_ms)
|
||||
{
|
||||
return (gs_rparam_get(node, mem_id, addr, type, GS_RPARAM_LEGACY_MAGIC_CHECKSUM, timeout_ms, out, size) == GS_OK) ? size : -1;
|
||||
}
|
||||
|
||||
static inline int rparam_set_single(const void * in, uint16_t addr, param_type_t type, int size, int mem_id, int node, int port, uint32_t timeout_ms)
|
||||
{
|
||||
return (gs_rparam_set(node, mem_id, addr, type, GS_RPARAM_LEGACY_MAGIC_CHECKSUM, timeout_ms, in, size) == GS_OK) ? size : -1;
|
||||
}
|
||||
|
||||
static inline int rparam_copy(uint8_t node, uint8_t port, uint32_t timeout_ms, uint8_t from, uint8_t to)
|
||||
{
|
||||
return (gs_rparam_copy(node, timeout_ms, from, to) == GS_OK) ? 1 : 0;
|
||||
}
|
||||
|
||||
static inline int rparam_save(uint8_t node, uint8_t port, uint32_t timeout_ms, uint8_t from, uint8_t to)
|
||||
{
|
||||
return (gs_rparam_save(node, timeout_ms, from, to) == GS_OK) ? 1 : 0;
|
||||
}
|
||||
|
||||
static inline int rparam_load(uint8_t node, uint8_t port, uint32_t timeout_ms, uint8_t from, uint8_t to)
|
||||
{
|
||||
return (gs_rparam_load(node, timeout_ms, from, to) == GS_OK) ? 1 : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remote getters for parameters.
|
||||
* @param out pointer to the output buffer/parameter
|
||||
* @param outlen length of the supplied out-buffer, only applies to rparam_get_string()
|
||||
* @param addr local address of the parameter
|
||||
* @param node CSP address of the node to query
|
||||
* @param port CSP port of the parameter server
|
||||
* @param timeout timeout on remote CSP calls
|
||||
* @returns <0 on error in which case the contents of out is invalid, >0 on success
|
||||
*/
|
||||
static inline int rparam_get_string(char *out, int outlen, uint16_t addr, int index_id, int node, int port, uint32_t timeout_ms)
|
||||
{
|
||||
return rparam_get_single(out, addr, PARAM_STRING, outlen, index_id, node, port, timeout_ms);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remote setters for parameters.
|
||||
* @param in pointer to the buffer/parameter value to set
|
||||
* @param inlen length of the supplied in-buffer, only applies to rparam_set_string()
|
||||
* @param addr local address of the parameter
|
||||
* @param node CSP address of the node to query
|
||||
* @param port CSP port of the parameter server
|
||||
* @param timeout timeout on remote CSP calls
|
||||
* @returns <0 on error in which case the contents of out is invalid, >0 on success
|
||||
*/
|
||||
static inline int rparam_set_string(const char *in, int inlen, uint16_t addr, int index_id, int node, int port, uint32_t timeout_ms)
|
||||
{
|
||||
return rparam_set_single(in, addr, PARAM_STRING, inlen, index_id, node, port, timeout_ms);
|
||||
}
|
||||
|
||||
static inline int rparam_get_uint8(uint8_t * out, uint16_t addr, int tinst_id, int node, int port, uint32_t timeout_ms)
|
||||
{
|
||||
return rparam_get_single(out, addr, PARAM_UINT8, sizeof(uint8_t), tinst_id, node, port, timeout_ms);
|
||||
}
|
||||
|
||||
static inline int rparam_set_uint8(const uint8_t * in, uint16_t addr, int index_id, int node, int port, uint32_t timeout_ms)
|
||||
{
|
||||
return rparam_set_single(in, addr, PARAM_UINT8, sizeof(uint8_t), index_id, node, port, timeout_ms);
|
||||
}
|
||||
|
||||
static inline int rparam_get_uint16(uint16_t * out, uint16_t addr, int index_id, int node, int port, uint32_t timeout_ms)
|
||||
{
|
||||
return rparam_get_single(out, addr, PARAM_UINT16, sizeof(uint16_t), index_id, node, port, timeout_ms);
|
||||
}
|
||||
|
||||
static inline int rparam_set_uint16(const uint16_t * in, uint16_t addr, int index_id, int node, int port, uint32_t timeout_ms)
|
||||
{
|
||||
return rparam_set_single(in, addr, PARAM_UINT16, sizeof(uint16_t), index_id, node, port, timeout_ms);
|
||||
}
|
||||
|
||||
static inline int rparam_get_uint32(uint32_t * out, uint16_t addr, int index_id, int node, int port, uint32_t timeout_ms)
|
||||
{
|
||||
return rparam_get_single(out, addr, PARAM_UINT32, sizeof(uint32_t), index_id, node, port, timeout_ms);
|
||||
}
|
||||
|
||||
static inline int rparam_set_uint32(const uint32_t * in, uint16_t addr, int index_id, int node, int port, uint32_t timeout_ms)
|
||||
{
|
||||
return rparam_set_single(in, addr, PARAM_UINT32, sizeof(uint32_t), index_id, node, port, timeout_ms);
|
||||
}
|
||||
|
||||
static inline int rparam_get_uint64(uint64_t * out, uint16_t addr, int index_id, int node, int port, uint32_t timeout_ms)
|
||||
{
|
||||
return rparam_get_single(out, addr, PARAM_UINT64, sizeof(uint64_t), index_id, node, port, timeout_ms);
|
||||
}
|
||||
|
||||
static inline int rparam_set_uint64(const uint64_t * in, uint16_t addr, int index_id, int node, int port, uint32_t timeout_ms)
|
||||
{
|
||||
return rparam_set_single(in, addr, PARAM_UINT64, sizeof(uint64_t), index_id, node, port, timeout_ms);
|
||||
}
|
||||
|
||||
static inline int rparam_get_int8(int8_t * out, uint16_t addr, int index_id, int node, int port, uint32_t timeout_ms)
|
||||
{
|
||||
return rparam_get_single(out, addr, PARAM_INT8, sizeof(int8_t), index_id, node, port, timeout_ms);
|
||||
}
|
||||
|
||||
static inline int rparam_set_int8(const int8_t * in, uint16_t addr, int index_id, int node, int port, uint32_t timeout_ms)
|
||||
{
|
||||
return rparam_set_single(in, addr, PARAM_INT8, sizeof(int8_t), index_id, node, port, timeout_ms);
|
||||
}
|
||||
|
||||
static inline int rparam_get_int16(int16_t * out, uint16_t addr, int index_id, int node, int port, uint32_t timeout_ms)
|
||||
{
|
||||
return rparam_get_single(out, addr, PARAM_INT16, sizeof(int16_t), index_id, node, port, timeout_ms);
|
||||
}
|
||||
|
||||
static inline int rparam_set_int16(const int16_t * in, uint16_t addr, int index_id, int node, int port, uint32_t timeout_ms)
|
||||
{
|
||||
return rparam_set_single(in, addr, PARAM_INT16, sizeof(int16_t), index_id, node, port, timeout_ms);
|
||||
}
|
||||
|
||||
static inline int rparam_get_int32(int32_t * out, uint16_t addr, int index_id, int node, int port, uint32_t timeout_ms)
|
||||
{
|
||||
return rparam_get_single(out, addr, PARAM_INT32, sizeof(int32_t), index_id, node, port, timeout_ms);
|
||||
}
|
||||
|
||||
static inline int rparam_set_int32(const int32_t * in, uint16_t addr, int index_id, int node, int port, uint32_t timeout_ms)
|
||||
{
|
||||
return rparam_set_single(in, addr, PARAM_INT32, sizeof(int32_t), index_id, node, port, timeout_ms);
|
||||
}
|
||||
|
||||
static inline int rparam_get_int64(int64_t * out, uint16_t addr, int index_id, int node, int port, uint32_t timeout_ms)
|
||||
{
|
||||
return rparam_get_single(out, addr, PARAM_INT64, sizeof(int64_t), index_id, node, port, timeout_ms);
|
||||
}
|
||||
|
||||
static inline int rparam_set_int64(const int64_t * in, uint16_t addr, int index_id, int node, int port, uint32_t timeout_ms)
|
||||
{
|
||||
return rparam_set_single(in, addr, PARAM_INT64, sizeof(int64_t), index_id, node, port, timeout_ms);
|
||||
}
|
||||
|
||||
static inline int rparam_get_float(float * out, uint16_t addr, int index_id, int node, int port, uint32_t timeout_ms)
|
||||
{
|
||||
return rparam_get_single(out, addr, PARAM_FLOAT, sizeof(float), index_id, node, port, timeout_ms);
|
||||
}
|
||||
|
||||
static inline int rparam_set_float(const float * in, uint16_t addr, int index_id, int node, int port, uint32_t timeout_ms)
|
||||
{
|
||||
return rparam_set_single(in, addr, PARAM_FLOAT, sizeof(float), index_id, node, port, timeout_ms);
|
||||
}
|
||||
|
||||
static inline int rparam_get_double(double * out, uint16_t addr, int index_id, int node, int port, uint32_t timeout_ms)
|
||||
{
|
||||
return rparam_get_single(out, addr, PARAM_DOUBLE, sizeof(double), index_id, node, port, timeout_ms);
|
||||
}
|
||||
|
||||
static inline int rparam_set_double(const double * in, uint16_t addr, int index_id, int node, int port, uint32_t timeout_ms)
|
||||
{
|
||||
return rparam_set_single(in, addr, PARAM_DOUBLE, sizeof(double), index_id, node, port, timeout_ms);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
Reference in New Issue
Block a user