40 #include <px4_platform_common/px4_config.h> 41 #include <px4_platform_common/module.h> 42 #include <px4_platform_common/posix.h> 63 static void usage(
const char *reason);
64 static int load(
const char *devname,
const char *fname,
bool append);
70 usage(
"missing command");
74 if (!strcmp(argv[1],
"load")) {
76 usage(
"missing device or filename");
80 int ret =
load(argv[2], argv[3],
false);
83 PX4_ERR(
"failed to load mixer");
87 }
else if (!strcmp(argv[1],
"append")) {
89 usage(
"missing device or filename");
93 int ret =
load(argv[2], argv[3],
true);
96 PX4_ERR(
"failed to append mixer");
101 usage(
"Unknown command");
111 if (reason && *reason) {
112 PX4_INFO(
"%s", reason);
115 PRINT_MODULE_DESCRIPTION(
118 Load or append mixer files to the ESC driver. 120 Note that the driver must support the used ioctl's, which is the case on NuttX, but for example not on RPi. 124 PRINT_MODULE_USAGE_NAME("mixer",
"command");
126 PRINT_MODULE_USAGE_COMMAND(
"load");
127 PRINT_MODULE_USAGE_ARG(
"<file:dev> <file>",
"Output device (eg. /dev/pwm_output0) and mixer file",
false);
128 PRINT_MODULE_USAGE_COMMAND(
"append");
129 PRINT_MODULE_USAGE_ARG(
"<file:dev> <file>",
"Output device (eg. /dev/pwm_output0) and mixer file",
false);
133 load(
const char *devname,
const char *fname,
bool append)
141 if ((dev =
px4_open(devname, 0)) < 0) {
142 PX4_ERR(
"can't open %s\n", devname);
149 PX4_ERR(
"can't reset mixers on %s", devname);
157 PX4_ERR(
"can't load mixer file: %s", fname);
165 PX4_ERR(
"failed to load mixers from %s", fname);
#define MIXERIOCLOADBUF
Add mixer(s) from the buffer in (const char *)arg.
__EXPORT int mixer_main(int argc, char *argv[])
Mixer utility for loading mixer files to devices.
int load_mixer_file(const char *fname, char *buf, unsigned maxlen)
#define MIXERIOCRESET
reset (clear) the mixer configuration
static void usage(const char *reason)
static int load(const char *devname, const char *fname, bool append)