forked from Archive/PX4-Autopilot
sdlog2: Fix command handling / interpretation of command parameters
This commit is contained in:
parent
83fdb9931a
commit
fa12a61765
|
@ -286,7 +286,7 @@ sdlog2_usage(const char *reason)
|
||||||
fprintf(stderr, "%s\n", reason);
|
fprintf(stderr, "%s\n", reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
errx(1, "usage: sdlog2 {start|stop|status} [-r <log rate>] [-b <buffer size>] -e -a -t -x\n"
|
errx(1, "usage: sdlog2 {start|stop|status|on|off} [-r <log rate>] [-b <buffer size>] -e -a -t -x\n"
|
||||||
"\t-r\tLog rate in Hz, 0 means unlimited rate\n"
|
"\t-r\tLog rate in Hz, 0 means unlimited rate\n"
|
||||||
"\t-b\tLog buffer size in KiB, default is 8\n"
|
"\t-b\tLog buffer size in KiB, default is 8\n"
|
||||||
"\t-e\tEnable logging by default (if not, can be started by command)\n"
|
"\t-e\tEnable logging by default (if not, can be started by command)\n"
|
||||||
|
@ -349,6 +349,8 @@ int sdlog2_main(int argc, char *argv[])
|
||||||
if (!strcmp(argv[1], "on")) {
|
if (!strcmp(argv[1], "on")) {
|
||||||
struct vehicle_command_s cmd;
|
struct vehicle_command_s cmd;
|
||||||
cmd.command = VEHICLE_CMD_PREFLIGHT_STORAGE;
|
cmd.command = VEHICLE_CMD_PREFLIGHT_STORAGE;
|
||||||
|
cmd.param1 = -1;
|
||||||
|
cmd.param2 = -1;
|
||||||
cmd.param3 = 1;
|
cmd.param3 = 1;
|
||||||
int fd = orb_advertise(ORB_ID(vehicle_command), &cmd);
|
int fd = orb_advertise(ORB_ID(vehicle_command), &cmd);
|
||||||
close(fd);
|
close(fd);
|
||||||
|
@ -358,7 +360,9 @@ int sdlog2_main(int argc, char *argv[])
|
||||||
if (!strcmp(argv[1], "off")) {
|
if (!strcmp(argv[1], "off")) {
|
||||||
struct vehicle_command_s cmd;
|
struct vehicle_command_s cmd;
|
||||||
cmd.command = VEHICLE_CMD_PREFLIGHT_STORAGE;
|
cmd.command = VEHICLE_CMD_PREFLIGHT_STORAGE;
|
||||||
cmd.param3 = 0;
|
cmd.param1 = -1;
|
||||||
|
cmd.param2 = -1;
|
||||||
|
cmd.param3 = 2;
|
||||||
int fd = orb_advertise(ORB_ID(vehicle_command), &cmd);
|
int fd = orb_advertise(ORB_ID(vehicle_command), &cmd);
|
||||||
close(fd);
|
close(fd);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1873,7 +1877,7 @@ void sdlog2_status()
|
||||||
{
|
{
|
||||||
warnx("extended logging: %s", (_extended_logging) ? "ON" : "OFF");
|
warnx("extended logging: %s", (_extended_logging) ? "ON" : "OFF");
|
||||||
if (!logging_enabled) {
|
if (!logging_enabled) {
|
||||||
warnx("standing by");
|
warnx("not logging");
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
float kibibytes = log_bytes_written / 1024.0f;
|
float kibibytes = log_bytes_written / 1024.0f;
|
||||||
|
@ -1975,7 +1979,7 @@ void handle_command(struct vehicle_command_s *cmd)
|
||||||
if (param == 1) {
|
if (param == 1) {
|
||||||
sdlog2_start_log();
|
sdlog2_start_log();
|
||||||
|
|
||||||
} else if (param == -1) {
|
} else if (param == 2) {
|
||||||
sdlog2_stop_log();
|
sdlog2_stop_log();
|
||||||
} else {
|
} else {
|
||||||
// Silently ignore non-matching command values, as they could be for params.
|
// Silently ignore non-matching command values, as they could be for params.
|
||||||
|
|
Loading…
Reference in New Issue