Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Addec command.

  • Loading branch information...
commit e16ace2a2b8c4d6ebb5922dd19fa7bf52e3b35c3 1 parent 112d7d3
@edgarsilva edgarsilva authored
View
11 lib/cli/commands.js
@@ -0,0 +1,11 @@
+var cliCommands,
+ crazyflie = require('./crazyflie');
+
+cliCommands = {
+ crazyflie: {
+ setUdevRules: crazyflie.setUdevRules,
+ _copyUdev: crazyflie._copyUdev
+ }
+};
+
+module.exports = cliCommands;
View
32 lib/cli/crazyflie.js
@@ -0,0 +1,32 @@
+require("cylon");
+
+var crazyflie,
+ os = require('os'),
+ fs = require('fs'),
+ path = require('path');
+
+crazyflie = {
+ setUdevRules: function() {
+ this._copyUdev(true);
+ return true;
+ },
+
+ _copyUdev: function(force) {
+ var cylonProcess, udevBkpPath, udevSysPath;
+ if (force === null) {
+ force = false;
+ }
+ udevSysPath = '/etc/udev/rules.d/99-crazyradio.rules';
+ udevBkpPath = path.join("" + __dirname, "./deps/99-crazyradio.rules");
+ if (!fs.existsSync(udevSysPath) || force) {
+ cylonProcess = new Cylon.Process();
+ cylonProcess.spawn('sudo', ['cp', udevBkpPath, udevSysPath]);
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+};
+
+module.exports = crazyflie;
View
1  lib/cli/deps/99-crazyradio.rules
@@ -0,0 +1 @@
+SUBSYSTEM=="usb", ATTRS{idVendor}=="1915", ATTRS{idProduct}=="7777", MODE="0664", GROUP="plugdev"
View
30 lib/cylon-crazyflie.js
@@ -8,13 +8,14 @@
"use strict";
-var namespace = require('node-namespace');
-
require('cylon');
require('./commands');
require('./adaptor');
require('./driver');
+var namespace = require('node-namespace'),
+ CliCommands = require("./cli/commands");
+
module.exports = {
adaptor: function(opts) {
return new Cylon.Adaptors.Crazyflie(opts);
@@ -30,5 +31,30 @@ module.exports = {
Logger.info("Registering Crazyflie driver for " + robot.name);
return robot.registerDriver('cylon-crazyflie', 'crazyflie');
+ },
+
+ registerCommands: function() {
+ var commands;
+
+ commands = {
+ crazyflie: {
+ description: "Set udev rules for the crazyflie",
+ command: function(args) {
+ var subcmd;
+ subcmd = args[0];
+
+ switch (subcmd) {
+ case 'set-udev-rules':
+ CliCommands.crazyflie.setUdevRules();
+ break;
+ default:
+ console.log("cylon crazyflie argument not recognized, try:\n");
+ console.log("1.- cylon crazyflie set-udev-rules\n");
+ }
+ }
+ }
+ };
+
+ return commands;
}
};
Please sign in to comment.
Something went wrong with that request. Please try again.