[lib-result] #define "simple CSV" string sizes
owlps.h: #define the coordinate string size.
This commit is contained in:
parent
ee02f26d8a
commit
177bd6284c
|
@ -273,19 +273,19 @@ owl_algorithm_result_to_csv(char dst[OWL_CSV_ALGORITHM_RESULT_STRLEN],
|
|||
* Converts an owl_result back to a CSV string, in a simplified format.
|
||||
* Only the *first* algorithm in the result's algorithm list will be
|
||||
* included in the string.
|
||||
* 'dst' must be an allocated string of at least OWL_CSV_RESULT_STRLEN
|
||||
* characters.
|
||||
* 'dst' must be an allocated string of at least
|
||||
* OWL_CSV_RESULT_SIMPLE_STRLEN characters.
|
||||
*
|
||||
* CSV format:
|
||||
* Mobile_MAC;First_algorithm
|
||||
* First_algorithm is the first algorithm in src->results. Its format
|
||||
* is documented in owl_algorithm_result_to_csv_simple().
|
||||
*/
|
||||
void owl_result_to_csv_simple(char dst[OWL_CSV_RESULT_STRLEN],
|
||||
void owl_result_to_csv_simple(char dst[OWL_CSV_RESULT_SIMPLE_STRLEN],
|
||||
const owl_result *const src)
|
||||
{
|
||||
size_t dst_len ;
|
||||
char algo_str[OWL_CSV_ALGORITHM_RESULT_STRLEN] ;
|
||||
char algo_str[OWL_CSV_ALGORITHM_RESULT_SIMPLE_STRLEN] ;
|
||||
|
||||
assert(src) ;
|
||||
|
||||
|
@ -297,7 +297,8 @@ void owl_result_to_csv_simple(char dst[OWL_CSV_RESULT_STRLEN],
|
|||
return ;
|
||||
|
||||
owl_algorithm_result_to_csv_simple(algo_str, src->results) ;
|
||||
strncpy(dst + dst_len, algo_str, OWL_CSV_ALGORITHM_RESULT_STRLEN) ;
|
||||
strncpy(dst + dst_len, algo_str,
|
||||
OWL_CSV_ALGORITHM_RESULT_SIMPLE_STRLEN) ;
|
||||
}
|
||||
|
||||
|
||||
|
@ -305,7 +306,7 @@ void owl_result_to_csv_simple(char dst[OWL_CSV_RESULT_STRLEN],
|
|||
* Converts an owl_algorithm_result back to a CSV string, in a
|
||||
* simplified format.
|
||||
* 'dst' must be an allocated string of at least
|
||||
* OWL_CSV_ALGORITHM_RESULT_STRLEN characters.
|
||||
* OWL_CSV_ALGORITHM_RESULT_SIMPLE_STRLEN characters.
|
||||
*
|
||||
* CSV format:
|
||||
* X;Y;Z;Area_name
|
||||
|
@ -313,12 +314,12 @@ void owl_result_to_csv_simple(char dst[OWL_CSV_RESULT_STRLEN],
|
|||
* be empty).
|
||||
*/
|
||||
void owl_algorithm_result_to_csv_simple
|
||||
(char dst[OWL_CSV_ALGORITHM_RESULT_STRLEN],
|
||||
(char dst[OWL_CSV_ALGORITHM_RESULT_SIMPLE_STRLEN],
|
||||
const owl_algorithm_result *const src)
|
||||
{
|
||||
assert(src) ;
|
||||
|
||||
snprintf(dst, OWL_CSV_ALGORITHM_RESULT_STRLEN,
|
||||
snprintf(dst, OWL_CSV_ALGORITHM_RESULT_SIMPLE_STRLEN,
|
||||
"%f;%f;%f;%s",
|
||||
src->x,
|
||||
src->y,
|
||||
|
|
|
@ -15,15 +15,35 @@
|
|||
|
||||
/* Maximum size of a result CSV string sent by OwlPS Positioning.
|
||||
* Request's information:
|
||||
* = 18 (MAC) + 2 (type) + 22 (timestamp) = 42 + ';' = 43
|
||||
* Plus, for each algorithm, about 60 characters (say 100, as the length
|
||||
* of the algorithm and area names can vary, 101 with the ';').
|
||||
* Let's keep room for 10 algorithms :
|
||||
* 10×101 + 43 = 1053 characters.
|
||||
* MAC, request type (2 chars), timestamp, ';'
|
||||
* Plus, for each algorithm:
|
||||
* Name, three coordinates, error (we assume the same size as the
|
||||
* coordinates), area name, ';'
|
||||
* Let's define OWL_NB_ALGORITHMS as the number of implemented
|
||||
* algorithms (this is ugly).
|
||||
*/
|
||||
#define OWL_CSV_RESULT_REQUEST_STRLEN 43
|
||||
#define OWL_CSV_ALGORITHM_RESULT_STRLEN 101
|
||||
#define OWL_CSV_RESULT_STRLEN 1053
|
||||
#define OWL_NB_ALGORITHMS 10
|
||||
#define OWL_CSV_RESULT_REQUEST_STRLEN \
|
||||
(OWL_ETHER_ADDR_STRLEN + OWL_TIMESTAMP_STRLEN + 3)
|
||||
#define OWL_CSV_ALGORITHM_RESULT_STRLEN \
|
||||
(OWL_ALGORITHM_STRLEN + 4 * OWL_COORDINATE_STRLEN + \
|
||||
OWL_AREA_STRLEN + 1)
|
||||
#define OWL_CSV_RESULT_STRLEN \
|
||||
(OWL_CSV_RESULT_REQUEST_STRLEN + \
|
||||
OWL_NB_ALGORITHMS * OWL_CSV_ALGORITHM_RESULT_STRLEN + 1)
|
||||
|
||||
/* Same thing, but for the simplified CSV strings created by
|
||||
* *_to_csv_simple().
|
||||
* Request's information is only the MAC address.
|
||||
* For the algorithm:
|
||||
* = 12 characters per coordinate + OWL_AREA_STRLEN
|
||||
*/
|
||||
#define OWL_CSV_RESULT_REQUEST_SIMPLE_STRLEN OWL_ETHER_ADDR_STRLEN
|
||||
#define OWL_CSV_ALGORITHM_RESULT_SIMPLE_STRLEN \
|
||||
(3 * OWL_COORDINATE_STRLEN + OWL_AREA_STRLEN + 1)
|
||||
#define OWL_CSV_RESULT_SIMPLE_STRLEN \
|
||||
(OWL_CSV_RESULT_REQUEST_SIMPLE_STRLEN + \
|
||||
OWL_NB_ALGORITHMS * OWL_CSV_ALGORITHM_RESULT_SIMPLE_STRLEN + 1)
|
||||
|
||||
|
||||
/* Linked list of algorithms' results.
|
||||
|
@ -63,10 +83,10 @@ void owl_result_to_csv(char dst[OWL_CSV_RESULT_STRLEN],
|
|||
void
|
||||
owl_algorithm_result_to_csv(char dst[OWL_CSV_ALGORITHM_RESULT_STRLEN],
|
||||
const owl_algorithm_result *const src) ;
|
||||
void owl_result_to_csv_simple(char dst[OWL_CSV_RESULT_STRLEN],
|
||||
void owl_result_to_csv_simple(char dst[OWL_CSV_RESULT_SIMPLE_STRLEN],
|
||||
const owl_result *const src) ;
|
||||
void owl_algorithm_result_to_csv_simple
|
||||
(char dst[OWL_CSV_ALGORITHM_RESULT_STRLEN],
|
||||
(char dst[OWL_CSV_ALGORITHM_RESULT_SIMPLE_STRLEN],
|
||||
const owl_algorithm_result *const src) ;
|
||||
|
||||
void owl_fprint_result(FILE *stream, const owl_result *const src) ;
|
||||
|
|
|
@ -164,6 +164,8 @@ typedef struct _owl_autocalibration_order
|
|||
#define OWL_ALGORITHM_STRLEN 31
|
||||
// Maximum length of an area name (including '\0')
|
||||
#define OWL_AREA_STRLEN 31
|
||||
// Maximum length of a coordinate X, Y or Z (including '\0')
|
||||
#define OWL_COORDINATE_STRLEN 16
|
||||
|
||||
|
||||
/* Global variables */
|
||||
|
|
Loading…
Reference in New Issue