diff --git a/src/systemcmds/tune_control/tune_control.cpp b/src/systemcmds/tune_control/tune_control.cpp index 4244eb4076..bdbe84ad2c 100644 --- a/src/systemcmds/tune_control/tune_control.cpp +++ b/src/systemcmds/tune_control/tune_control.cpp @@ -63,6 +63,13 @@ usage() { PX4_INFO( "External tune control for testing. Usage:\n" + "tune_control play [-t ] [-f ] [-d ] [-s ] [-m < melody>]\n" + "\n" + "\t-t \tPlay the default (1...15) (default=1)\n" + "\t-f \t\tFrequency from 0-20kHz\n" + "\t-d \t\tDuration of the tone in us\n" + "\t-s \t\tStrenght of the tone between 0-100\n" + "\t-m \t\tMelody in a string form ex: \"MFT200e8a8a\"\n" ); } @@ -71,7 +78,7 @@ static void publish_tune_control(tune_control_s &tune_control) tune_control.timestamp = hrt_absolute_time(); if (tune_control_pub == nullptr) { - tune_control_pub = orb_advertise_queue(ORB_ID(tune_control), &tune_control, 1); + tune_control_pub = orb_advertise(ORB_ID(tune_control), &tune_control); } else { orb_publish(ORB_ID(tune_control), tune_control_pub, &tune_control); @@ -92,7 +99,7 @@ tune_control_main(int argc, char *argv[]) tune_control.tune_id = 0; tune_control.strength = 40; - while ((ch = px4_getopt(argc, argv, "f:d:t:s:", &myoptind, &myoptarg)) != EOF) { + while ((ch = px4_getopt(argc, argv, "f:d:t:m:s:", &myoptind, &myoptarg)) != EOF) { switch (ch) { case 'f': if ((uint16_t)(strtol(myoptarg, NULL, 0)) > 0 && (uint16_t)(strtol(myoptarg, NULL, 0)) < 22000) { @@ -106,7 +113,7 @@ tune_control_main(int argc, char *argv[]) break; case 'd': - tune_control.duration = (uint16_t)(strtol(myoptarg, NULL, 0)); + tune_control.duration = (uint32_t)(strtol(myoptarg, NULL, 0)); break; case 't': @@ -122,20 +129,22 @@ tune_control_main(int argc, char *argv[]) break; - case 's': + case 'm': string_input = true; + tune_string = myoptarg; - // TODO: check if the string is a valid tune sequence - if (1) { - tune_string = myoptarg; - - } else { + // check if string is a valid melody string + if (tune_string[0] != 'M') { usage(); return 1; } break; + case 's': + tune_control.strength = (uint16_t)(strtol(myoptarg, NULL, 0)); + break; + default: usage(); return -1;