better debug

This commit is contained in:
Shannon Sterz 2016-02-24 08:37:00 +01:00
parent 9ca0d595cf
commit 30b424eb26
2 changed files with 7 additions and 3 deletions

View file

@ -3,7 +3,7 @@ var events = require('events'),
util = require('util'), util = require('util'),
serial = require("serialport"); serial = require("serialport");
var Arduino = function (baudrate, debug) { var Arduino = function (debug, baudrate) {
this.baudrate = baudrate && baudrate || 9600; this.baudrate = baudrate && baudrate || 9600;
this.debug = debug && debug || false; this.debug = debug && debug || false;
this.writeBuffer = []; this.writeBuffer = [];
@ -18,7 +18,11 @@ Arduino.prototype.setup = function () {
var self = this; var self = this;
child.exec('cd ../arduino && ino build && ino upload', function(err, stdout, stderr){ child.exec('cd ../arduino && ino build && ino upload', function(err, stdout, stderr){
if(err){console.log('Please install the ino utility and connect arduino!\nIf there are other open programs that communicate with the arduino, close them!'); return;} if(err){
console.log('Please install the ino utility and connect arduino!\nIf there are other open programs that communicate with the arduino, close them!');
if(self.debug) {console.log(err.message);}
return;
}
var buff = stdout.slice(stdout.indexOf('Guessing serial port ... ')+25); var buff = stdout.slice(stdout.indexOf('Guessing serial port ... ')+25);
buff = buff.slice(0, buff.indexOf('\n')); buff = buff.slice(0, buff.indexOf('\n'));

View file

@ -12,7 +12,7 @@ var rc_db = new models.RCDB();
var users = new models.Users(); var users = new models.Users();
// Arduino communications // Arduino communications
var arduino = new arcom.Arduino(); var arduino = new arcom.Arduino(true);
var rc = new arcom.RC(arduino); var rc = new arcom.RC(arduino);
// Get arduino ready // Get arduino ready