Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AI Script: Align With Compass #224

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Added Hardware Shutdown Promise
TekuConcept committed Mar 22, 2017
commit f833736dd6675ade030006872c4be93cf9ce1281
2 changes: 1 addition & 1 deletion BoneCentral/Brain/CppInterface/Factory.js
Original file line number Diff line number Diff line change
@@ -30,7 +30,7 @@ module.exports = (function() {
};

Factory.prototype.createPowerManager = function () {
return new PowerManager(dispatcherSocket.Input);
return new PowerManager(this.dispatcherSocket.Input, this.dispatcherSocket.OnExit);
};

Factory.prototype.createThrustController = function () {
4 changes: 3 additions & 1 deletion BoneCentral/Brain/CppInterface/PowerManager.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
module.exports = (function(){

function PowerManager(cmdOut) {
function PowerManager(cmdOut, onExit) {
this._cmdOut = cmdOut;
this._onExit = onExit;
}

PowerManager.prototype.turnOnEscs = function(){
@@ -22,6 +23,7 @@ module.exports = (function(){

PowerManager.prototype.exit = function () {
this._cmdOut.write("exit\n");
return this._onExit;
};

return PowerManager;
15 changes: 12 additions & 3 deletions BoneCentral/Brain/Sockets/index.js
Original file line number Diff line number Diff line change
@@ -3,15 +3,24 @@
*/

var Streams = require('stream');
var Net = require('net');
var Net = require('net');
var $ = require('../Utilities').Promises

module.exports.createSocket = function (port) {
var input = new Streams.PassThrough();
var input = new Streams.PassThrough();
var output = new Streams.PassThrough();
var onExit = $.Deferred();
Net.createServer(function (socket) {
_handleClient(socket, input, output);
socket.on("close", function() {
onExit.resolve();
});
}).listen(port);
return {Input: input, Output: output};
return {
Input: input,
Output: output,
OnExit: onExit.promise()
};
};

var _handleClient = function (socket, input, output) {