summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Reichel <sre@ring0.de>2012-08-12 20:37:54 +0200
committerSebastian Reichel <sre@ring0.de>2012-08-12 20:37:54 +0200
commitd7c0a3b482ca0b564412a4f622876802cf571bd1 (patch)
tree7221dc7ae189805d0df5b6901ce201e5cf8947ca
parent42b897076f533a6ffc925763e4dfdfe1493e9c89 (diff)
downloadmicrocopterd-d7c0a3b482ca0b564412a4f622876802cf571bd1.tar.bz2
new atmostripe protocol
-rw-r--r--actuators/motor-controller.vala2
-rw-r--r--actuators/motor/atmostripe.vala52
2 files changed, 52 insertions, 2 deletions
diff --git a/actuators/motor-controller.vala b/actuators/motor-controller.vala
index b638e06..9fe0040 100644
--- a/actuators/motor-controller.vala
+++ b/actuators/motor-controller.vala
@@ -20,4 +20,6 @@ public interface MotorController : Device {
public abstract void init(KeyFile cfg) throws Error;
public abstract bool set_single(uint8 m, uint8 v);
public abstract bool set_all(uint8 v);
+ public abstract bool disable();
+ public abstract bool enable();
}
diff --git a/actuators/motor/atmostripe.vala b/actuators/motor/atmostripe.vala
index 7cc9146..b20cc44 100644
--- a/actuators/motor/atmostripe.vala
+++ b/actuators/motor/atmostripe.vala
@@ -25,11 +25,59 @@ public class AtmostripeMotorController : SerialDevice, MotorController {
public void init(KeyFile cfg) throws Error {
var device = cfg.get_string("AtmostripeMotorController", "device");
setup(device, 9600, 8, 1);
+ nop();
+ nop();
+ nop();
+ }
+
+ public bool disable() {
+ uint8[4] buf = new uint8[4];
+ buf[0] = 0xDE;
+ buf[1] = 0xAD;
+ buf[2] = 0xBA;
+ buf[3] = 0xBE;
+
+ write(buf, 4);
+ read(buf, 1);
+
+ if(buf[0] == '.')
+ return true;
+ else
+ return false;
+ }
+
+ public bool enable() {
+ uint8[4] buf = new uint8[4];
+ buf[0] = 0xCA;
+ buf[1] = 0xFE;
+ buf[2] = 0xBA;
+ buf[3] = 0xBE;
+
+ write(buf, 4);
+ read(buf, 1);
+
+ if(buf[0] == '.')
+ return true;
+ else
+ return false;
+ }
+
+ public bool nop() {
+ uint8[1] buf = new uint8[1];
+ buf[0] = 0x00;
+
+ write(buf, 1);
+ read(buf, 1);
+
+ if(buf[0] == '.')
+ return true;
+ else
+ return false;
}
public bool set_single(uint8 engine, uint8 speed) {
uint8[2] buf = new uint8[2];
- buf[0] = engine;
+ buf[0] = engine+1;
buf[1] = speed;
if(engine > 5)
@@ -46,7 +94,7 @@ public class AtmostripeMotorController : SerialDevice, MotorController {
public bool set_all(uint8 speed) {
uint8[2] buf = new uint8[2];
- buf[0] = 6;
+ buf[0] = 0xff;
buf[1] = speed;
write(buf, 2);