aboutsummaryrefslogtreecommitdiff
path: root/apps/drivers/px4io/px4io.cpp
diff options
context:
space:
mode:
authorpx4dev <px4@purgatory.org>2012-12-29 00:01:04 -0800
committerpx4dev <px4@purgatory.org>2012-12-29 00:01:04 -0800
commit35c82ff2fc63ab823770f9776e6b6a0f81cd4452 (patch)
tree86956f9f00f1270eafc921748ac024a7daa92f80 /apps/drivers/px4io/px4io.cpp
parentf0da789626c32695e670b55dab29283eed4a05c6 (diff)
downloadpx4-firmware-35c82ff2fc63ab823770f9776e6b6a0f81cd4452.tar.gz
px4-firmware-35c82ff2fc63ab823770f9776e6b6a0f81cd4452.tar.bz2
px4-firmware-35c82ff2fc63ab823770f9776e6b6a0f81cd4452.zip
Make mixer ioctls load from a memory buffer rather than a file. This is prep for uploading the memory buffer to IO to be processed there.
Diffstat (limited to 'apps/drivers/px4io/px4io.cpp')
-rw-r--r--apps/drivers/px4io/px4io.cpp32
1 files changed, 17 insertions, 15 deletions
diff --git a/apps/drivers/px4io/px4io.cpp b/apps/drivers/px4io/px4io.cpp
index d185a1ac4..cb69856c8 100644
--- a/apps/drivers/px4io/px4io.cpp
+++ b/apps/drivers/px4io/px4io.cpp
@@ -609,27 +609,29 @@ PX4IO::ioctl(file *filep, int cmd, unsigned long arg)
}
break;
- case MIXERIOCLOADFILE: {
- MixerGroup *newmixers;
- const char *path = (const char *)arg;
+ case MIXERIOCLOADBUF: {
+ const char *buf = (const char *)arg;
+ unsigned buflen = strnlen(buf, 1024);
- /* allocate a new mixer group and load it from the file */
- newmixers = new MixerGroup(control_callback, (uintptr_t)&_controls);
+ if (_mixers == nullptr)
+ _mixers = new MixerGroup(control_callback, (uintptr_t)&_controls);
- if (newmixers->load_from_file(path) != 0) {
- delete newmixers;
- ret = -EINVAL;
- }
+ if (_mixers == nullptr) {
+ ret = -ENOMEM;
- /* swap the new mixers in for the old */
- if (_mixers != nullptr) {
- delete _mixers;
- }
+ } else {
- _mixers = newmixers;
+ ret = _mixers->load_from_buf(buf, buflen);
+ if (ret != 0) {
+ debug("mixer load failed with %d", ret);
+ delete _mixers;
+ _mixers = nullptr;
+ ret = -EINVAL;
+ }
+ }
+ break;
}
- break;
default:
/* not a recognised value */