mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-30 21:33:35 +08:00
systemcmds: Warning fixes
This commit is contained in:
@@ -237,8 +237,10 @@ void at24c_test(void)
|
|||||||
} else if (result != 1) {
|
} else if (result != 1) {
|
||||||
vdbg("unexpected %u\n", result);
|
vdbg("unexpected %u\n", result);
|
||||||
}
|
}
|
||||||
if ((count % 100) == 0)
|
|
||||||
|
if ((count % 100) == 0) {
|
||||||
vdbg("test %u errors %u\n", count, errors);
|
vdbg("test %u errors %u\n", count, errors);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -515,7 +515,8 @@ pwm_main(int argc, char *argv[])
|
|||||||
ret = poll(&fds, 1, 0);
|
ret = poll(&fds, 1, 0);
|
||||||
if (ret > 0) {
|
if (ret > 0) {
|
||||||
|
|
||||||
int ret = read(0, &c, 1);
|
ret = read(0, &c, 1);
|
||||||
|
|
||||||
if (ret > 0) {
|
if (ret > 0) {
|
||||||
/* reset output to the last value */
|
/* reset output to the last value */
|
||||||
for (unsigned i = 0; i < servo_count; i++) {
|
for (unsigned i = 0; i < servo_count; i++) {
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ int test_conv(int argc, char *argv[])
|
|||||||
float f = i/10000.0f;
|
float f = i/10000.0f;
|
||||||
float fres = REG_TO_FLOAT(FLOAT_TO_REG(f));
|
float fres = REG_TO_FLOAT(FLOAT_TO_REG(f));
|
||||||
if (fabsf(f - fres) > 0.0001f) {
|
if (fabsf(f - fres) > 0.0001f) {
|
||||||
warnx("conversion fail: input: %8.4f, intermediate: %d, result: %8.4f", f, REG_TO_SIGNED(FLOAT_TO_REG(f)), (double)fres);
|
warnx("conversion fail: input: %8.4f, intermediate: %d, result: %8.4f", (double)f, REG_TO_SIGNED(FLOAT_TO_REG(f)), (double)fres);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -149,6 +149,8 @@ test_file(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
end = hrt_absolute_time();
|
end = hrt_absolute_time();
|
||||||
|
|
||||||
|
warnx("write took %llu us", (end - start));
|
||||||
|
|
||||||
close(fd);
|
close(fd);
|
||||||
fd = open("/fs/microsd/testfile", O_RDONLY);
|
fd = open("/fs/microsd/testfile", O_RDONLY);
|
||||||
|
|
||||||
@@ -192,7 +194,6 @@ test_file(int argc, char *argv[])
|
|||||||
|
|
||||||
warnx("testing aligned writes - please wait.. (CTRL^C to abort)");
|
warnx("testing aligned writes - please wait.. (CTRL^C to abort)");
|
||||||
|
|
||||||
start = hrt_absolute_time();
|
|
||||||
for (unsigned i = 0; i < iterations; i++) {
|
for (unsigned i = 0; i < iterations; i++) {
|
||||||
int wret = write(fd, write_buf, chunk_sizes[c]);
|
int wret = write(fd, write_buf, chunk_sizes[c]);
|
||||||
|
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ int test_float(int argc, char *argv[])
|
|||||||
float sinf_one = sinf(1.0f);
|
float sinf_one = sinf(1.0f);
|
||||||
float sqrt_two = sqrt(2.0f);
|
float sqrt_two = sqrt(2.0f);
|
||||||
|
|
||||||
if (sinf_zero == 0.0f) {
|
if (fabsf(sinf_zero) < FLT_EPSILON) {
|
||||||
printf("\t success: sinf(0.0f) == 0.0f\n");
|
printf("\t success: sinf(0.0f) == 0.0f\n");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@@ -136,7 +136,7 @@ int test_float(int argc, char *argv[])
|
|||||||
ret = -2;
|
ret = -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sqrt_two == 1.41421356f) {
|
if (fabsf(sqrt_two - 1.41421356f) < FLT_EPSILON) {
|
||||||
printf("\t success: sqrt(2.0f) == 1.41421f\n");
|
printf("\t success: sqrt(2.0f) == 1.41421f\n");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@@ -188,7 +188,7 @@ int test_float(int argc, char *argv[])
|
|||||||
|
|
||||||
double d1d2 = d1 * d2;
|
double d1d2 = d1 * d2;
|
||||||
|
|
||||||
if (d1d2 == 2.022200000000000219557705349871) {
|
if (fabs(d1d2 - 2.022200000000000219557705349871) < DBL_EPSILON) {
|
||||||
printf("\t success: 1.0111 * 2.0 == 2.0222\n");
|
printf("\t success: 1.0111 * 2.0 == 2.0222\n");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@@ -201,7 +201,7 @@ int test_float(int argc, char *argv[])
|
|||||||
// Assign value of f1 to d1
|
// Assign value of f1 to d1
|
||||||
d1 = f1;
|
d1 = f1;
|
||||||
|
|
||||||
if (f1 == (float)d1) {
|
if (fabsf(f1 - (float)d1) < FLT_EPSILON) {
|
||||||
printf("\t success: (float) 1.55f == 1.55 (double)\n");
|
printf("\t success: (float) 1.55f == 1.55 (double)\n");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@@ -216,7 +216,7 @@ int test_float(int argc, char *argv[])
|
|||||||
double sin_one = sin(1.0);
|
double sin_one = sin(1.0);
|
||||||
double atan2_ones = atan2(1.0, 1.0);
|
double atan2_ones = atan2(1.0, 1.0);
|
||||||
|
|
||||||
if (sin_zero == 0.0) {
|
if (fabs(sin_zero - 0.0) < DBL_EPSILON) {
|
||||||
printf("\t success: sin(0.0) == 0.0\n");
|
printf("\t success: sin(0.0) == 0.0\n");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@@ -224,7 +224,7 @@ int test_float(int argc, char *argv[])
|
|||||||
ret = -9;
|
ret = -9;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sin_one == 0.841470984807896504875657228695) {
|
if (fabs(sin_one - 0.841470984807896504875657228695) < DBL_EPSILON) {
|
||||||
printf("\t success: sin(1.0) == 0.84147098480\n");
|
printf("\t success: sin(1.0) == 0.84147098480\n");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@@ -232,7 +232,7 @@ int test_float(int argc, char *argv[])
|
|||||||
ret = -10;
|
ret = -10;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (atan2_ones != 0.785398) {
|
if (fabs(atan2_ones - 0.785398) < DBL_EPSILON) {
|
||||||
printf("\t success: atan2(1.0, 1.0) == 0.785398\n");
|
printf("\t success: atan2(1.0, 1.0) == 0.785398\n");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -171,6 +171,8 @@ test_mtd(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
end = hrt_absolute_time();
|
end = hrt_absolute_time();
|
||||||
|
|
||||||
|
warnx("write took %llu us", (end - start));
|
||||||
|
|
||||||
close(fd);
|
close(fd);
|
||||||
fd = open(PARAM_FILE_NAME, O_RDONLY);
|
fd = open(PARAM_FILE_NAME, O_RDONLY);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user