From 3fea43d0eaf77a1833f8a920e2fc0fe236accde5 Mon Sep 17 00:00:00 2001 From: Matt Date: Tue, 12 Apr 2016 23:14:27 -0400 Subject: [PATCH] Retool arduino module --- app/lib/mcopy-arduino.js | 8 ++++---- app/main.js | 18 ++++++++++-------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/app/lib/mcopy-arduino.js b/app/lib/mcopy-arduino.js index 7f83160..bfc4971 100644 --- a/app/lib/mcopy-arduino.js +++ b/app/lib/mcopy-arduino.js @@ -37,14 +37,14 @@ mcopy.arduino.init = function (callback) { } } if (matches.length === 0) { - console.log('No devices found.'); - if (callback) { callback(false); } + //console.log('No USB devices found.'); + if (callback) { callback('No USB devices found'); } } else if (matches.length > 0) { - console.log('Found ' + matches[0]); + //console.log('Found ' + matches[0]); mcopy.arduino.path = matches[0]; //once connected to the arduino //start user interface - if (callback) { callback(true); } + if (callback) { callback(null, mcopy.arduino.path); } } }); }; diff --git a/app/main.js b/app/main.js index ff60f08..43a56d6 100644 --- a/app/main.js +++ b/app/main.js @@ -15,17 +15,18 @@ mcopy.arduino = require('./lib/mcopy-arduino.js')(mcopy.cfg); var mainWindow; var init = function () { + 'use strict'; createWindow(); log.init(); - mcopy.arduino.init(function (err, success) { - /*if (success) { - log.info('Found devices', 'SERIAL', true); - mcopy.arduino.connect(function () { - // - }); + mcopy.arduino.init(function (err, device) { + if (err) { + log.info(err, 'SERIAL', false, true); } else { - log.info('Connected', 'SERIAL', true); - }*/ + log.info('Found device ' + device, 'SERIAL', true, true); + mcopy.arduino.connect(function () { + log.info('Connected to device ' + device, 'SERIAL', true, true); + }); + } }); }; @@ -34,6 +35,7 @@ var createMenu = function () { }; var createWindow = function () { + 'use strict'; mainWindow = new BrowserWindow({width: 800, height: 600}); mainWindow.loadURL('file://' + __dirname + '/index.html'); //mainWindow.webContents.openDevTools();