From 3d551593adaf545379bc271a3a45d3faa4832e96 Mon Sep 17 00:00:00 2001 From: fros4943 Date: Mon, 6 Nov 2006 22:21:57 +0000 Subject: [PATCH] bug fix: no nm arguments (tested on linux) --- .../cooja/contikimote/ContikiMoteType.java | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/tools/cooja/java/se/sics/cooja/contikimote/ContikiMoteType.java b/tools/cooja/java/se/sics/cooja/contikimote/ContikiMoteType.java index 3f231a68f..c02a44f56 100644 --- a/tools/cooja/java/se/sics/cooja/contikimote/ContikiMoteType.java +++ b/tools/cooja/java/se/sics/cooja/contikimote/ContikiMoteType.java @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: ContikiMoteType.java,v 1.4 2006/11/06 18:01:56 fros4943 Exp $ + * $Id: ContikiMoteType.java,v 1.5 2006/11/06 22:21:57 fros4943 Exp $ */ package se.sics.cooja.contikimote; @@ -582,12 +582,21 @@ public class ContikiMoteType implements MoteType { if (nmPath == null || nmPath.equals("")) return null; - String[] splittedNmArgs = nmArgs.split(" "); - String[] nmExecArray = new String[1 + splittedNmArgs.length + 1]; + String[] nmExecArray; + if (!nmArgs.trim().equals("")) { + // Arguments need to be passed to program + String[] splittedNmArgs = nmArgs.split(" "); + nmExecArray = new String[1 + splittedNmArgs.length + 1]; - nmExecArray[0] = nmPath.trim(); - nmExecArray[nmExecArray.length-1] = libraryFile.getAbsolutePath(); - System.arraycopy(splittedNmArgs, 0, nmExecArray, 1, splittedNmArgs.length); + nmExecArray[0] = nmPath.trim(); + + nmExecArray[nmExecArray.length-1] = libraryFile.getAbsolutePath(); + System.arraycopy(splittedNmArgs, 0, nmExecArray, 1, splittedNmArgs.length); + } else { + nmExecArray = new String[2]; + nmExecArray[0] = nmPath.trim(); + nmExecArray[1] = libraryFile.getAbsolutePath(); + } String line; Process p = Runtime.getRuntime().exec(nmExecArray); @@ -607,6 +616,7 @@ public class ContikiMoteType implements MoteType { if (nmData == null || nmData.size() == 0) return null; + logger.debug("#4"); return nmData; }