mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-27 18:27:05 +08:00
Allowed parsing of floating point params from scripts
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
*
|
*
|
||||||
* Copyright (C) 2012 PX4 Development Team. All rights reserved.
|
* Copyright (c) 2012, 2013 PX4 Development Team. All rights reserved.
|
||||||
* Author: Lorenz Meier <lm@inf.ethz.ch>
|
* Author: Lorenz Meier <lm@inf.ethz.ch>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -34,6 +34,7 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @file param.c
|
* @file param.c
|
||||||
|
* @author Lorenz Meier <lm@inf.ethz.ch>
|
||||||
*
|
*
|
||||||
* Parameter tool.
|
* Parameter tool.
|
||||||
*/
|
*/
|
||||||
@@ -262,7 +263,7 @@ do_set(const char* name, const char* val)
|
|||||||
switch (param_type(param)) {
|
switch (param_type(param)) {
|
||||||
case PARAM_TYPE_INT32:
|
case PARAM_TYPE_INT32:
|
||||||
if (!param_get(param, &i)) {
|
if (!param_get(param, &i)) {
|
||||||
printf("old: %d", i);
|
printf("curr: %d", i);
|
||||||
|
|
||||||
/* convert string */
|
/* convert string */
|
||||||
char* end;
|
char* end;
|
||||||
@@ -276,14 +277,13 @@ do_set(const char* name, const char* val)
|
|||||||
|
|
||||||
case PARAM_TYPE_FLOAT:
|
case PARAM_TYPE_FLOAT:
|
||||||
if (!param_get(param, &f)) {
|
if (!param_get(param, &f)) {
|
||||||
printf("float values are not yet supported.");
|
printf("curr: %4.4f", (double)f);
|
||||||
// printf("old: %4.4f", (double)f);
|
|
||||||
|
|
||||||
// /* convert string */
|
/* convert string */
|
||||||
// char* end;
|
char* end;
|
||||||
// f = strtof(val,&end);
|
f = strtod(val,&end);
|
||||||
// param_set(param, &f);
|
param_set(param, &f);
|
||||||
// printf(" -> new: %4.4f\n", f);
|
printf(" -> new: %f\n", f);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user