summaryrefslogtreecommitdiffstats
path: root/actuators
diff options
context:
space:
mode:
authorSebastian Reichel <sre@ring0.de>2012-06-28 19:59:55 +0200
committerSebastian Reichel <sre@ring0.de>2012-06-28 19:59:55 +0200
commit1e123c3670209132fa82cf02e95b8425a0c070aa (patch)
treef424d4f26191ac0fedbfd5416f0835ea6453cf93 /actuators
parent8a08b9dce9cfc161494ddb07a1c979c7796780ff (diff)
downloadmicrocopterd-1e123c3670209132fa82cf02e95b8425a0c070aa.tar.bz2
implement atmostripe motor controller
Diffstat (limited to 'actuators')
-rw-r--r--actuators/motor-controller.vala4
-rw-r--r--actuators/motor/atmostripe.vala34
2 files changed, 31 insertions, 7 deletions
diff --git a/actuators/motor-controller.vala b/actuators/motor-controller.vala
index d348e53..b638e06 100644
--- a/actuators/motor-controller.vala
+++ b/actuators/motor-controller.vala
@@ -18,6 +18,6 @@ public interface MotorController : Device {
public abstract uint8 max { get ; }
public abstract void init(KeyFile cfg) throws Error;
- public abstract void set_single(uint8 m, uint8 v);
- public abstract void set_all(uint8 v);
+ public abstract bool set_single(uint8 m, uint8 v);
+ public abstract bool set_all(uint8 v);
}
diff --git a/actuators/motor/atmostripe.vala b/actuators/motor/atmostripe.vala
index ad996e7..23f0fda 100644
--- a/actuators/motor/atmostripe.vala
+++ b/actuators/motor/atmostripe.vala
@@ -23,15 +23,39 @@ public class AtmostripeMotorController : SerialDevice, MotorController {
}
public void init(KeyFile cfg) throws Error {
- /* */
+ var device = cfg.get_string("AtmostripeMotorController", "device");
+ setup(device);
}
- public void set_single(uint8 m, uint8 v) {
- /* */
+ public bool set_single(uint8 engine, uint8 speed) {
+ uint8[2] buf = new uint8[2];
+ buf[0] = engine;
+ buf[1] = speed;
+
+ if(engine > 5)
+ return false;
+
+ write(buf, 2);
+ read(buf, 2);
+
+ if(buf[0] == '.')
+ return true;
+ else
+ return false;
}
- public void set_all(uint8 v) {
- /* */
+ public bool set_all(uint8 speed) {
+ uint8[2] buf = new uint8[2];
+ buf[0] = 6;
+ buf[1] = speed;
+
+ write(buf, 2);
+ read(buf, 2);
+
+ if(buf[0] == '.')
+ return true;
+ else
+ return false;
}
}