better debugging output when compiling and cleaning for msp motes

This commit is contained in:
fros4943 2009-03-03 15:01:14 +00:00
parent ba12b6ec00
commit 7a54a0b8eb

View file

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* $Id: MspMoteType.java,v 1.23 2009/03/03 13:52:35 fros4943 Exp $ * $Id: MspMoteType.java,v 1.24 2009/03/03 15:01:14 fros4943 Exp $
*/ */
package se.sics.cooja.mspmote; package se.sics.cooja.mspmote;
@ -404,29 +404,30 @@ public abstract class MspMoteType implements MoteType {
} }
public void cleanTempFiles(final MessageList taskOutput, final File parentDir, boolean synch) { public void cleanTempFiles(final MessageList taskOutput, final File parentDir, boolean synch) {
Thread t = new Thread(new Runnable() { Runnable clean = new Runnable() {
public void run() { public void run() {
try { try {
logger.info("Cleaning temporary files in: " + parentDir.getPath());
compileFirmware( compileFirmware(
"make clean TARGET=" + target, "make clean TARGET=" + target,
null, null /* No source file */,
null, null /* No firmware output */,
parentDir, parentDir,
null, null,
null, null,
taskOutput, taskOutput,
true); true);
} catch (Exception e2) { } catch (Exception e2) {
logger.info("Exception: " + e2.getMessage());
e2.printStackTrace();
} }
} }
}); };
t.start();
if (synch) { if (synch) {
try { clean.run();
t.join(); } else {
} catch (InterruptedException e) { new Thread(clean).start();
e.printStackTrace();
}
} }
} }
@ -514,7 +515,8 @@ public abstract class MspMoteType implements MoteType {
final String command = getCompileCommand(filenameNoExtension); final String command = getCompileCommand(filenameNoExtension);
logger.info("-- Compiling MSP430 Firmware --"); logger.info("-- Compiling MSP430 Firmware --");
compileFirmware(command, sourceFile, filenameNoExtension + getTargetFileExtension(target), compileFirmware(command, sourceFile,
new File(parentDirectory, filenameNoExtension + getTargetFileExtension(target)),
parentDirectory, parentDirectory,
successAction, failAction, successAction, failAction,
compilationOutput, synchronous); compilationOutput, synchronous);
@ -522,7 +524,7 @@ public abstract class MspMoteType implements MoteType {
protected void compileFirmware( protected void compileFirmware(
final String command, final File sourceFile, final String command, final File sourceFile,
final String firmware, final File parentDirectory, final File firmwareFile, final File parentDirectory,
final Action successAction, final Action failAction, final Action successAction, final Action failAction,
final MessageList compilationOutput, boolean synchronous) throws Exception { final MessageList compilationOutput, boolean synchronous) throws Exception {
@ -543,20 +545,18 @@ public abstract class MspMoteType implements MoteType {
final BufferedReader processError = new BufferedReader( final BufferedReader processError = new BufferedReader(
new InputStreamReader(compileProcess.getErrorStream())); new InputStreamReader(compileProcess.getErrorStream()));
final File ELFFile = new File(parentDirectory, firmware); if (firmwareFile != null) {
if (firmware != null) { if (firmwareFile.exists()) {
if (ELFFile.exists()) { firmwareFile.delete();
ELFFile.delete(); }
if (ELFFile.exists()) { if (firmwareFile.exists()) {
if (compilationOutput != null) { if (compilationOutput != null) {
compilationOutput.addMessage("Error when deleting old " + ELFFile.getName(), MessageList.ERROR); compilationOutput.addMessage("Error when deleting old " + firmwareFile.getName(), MessageList.ERROR);
}
if (failAction != null) {
failAction.actionPerformed(null);
}
throw new MoteTypeCreationException("Error when deleting old "
+ ELFFile.getName());
} }
if (failAction != null) {
failAction.actionPerformed(null);
}
throw new MoteTypeCreationException("Error when deleting old " + firmwareFile.getName());
} }
} }
@ -620,13 +620,14 @@ public abstract class MspMoteType implements MoteType {
return; return;
} }
if (firmware == null) { if (firmwareFile == null) {
/* No firmware to generate: OK */
return; return;
} }
if (!ELFFile.exists()) { if (!firmwareFile.exists()) {
if (compilationOutput != null) { if (compilationOutput != null) {
compilationOutput.addMessage("Can't locate output file " + ELFFile, MessageList.ERROR); compilationOutput.addMessage("No firmware file: " + firmwareFile, MessageList.ERROR);
} }
if (failAction != null) { if (failAction != null) {
failAction.actionPerformed(null); failAction.actionPerformed(null);
@ -642,7 +643,7 @@ public abstract class MspMoteType implements MoteType {
} }
MspELFCompiler.this.lastCompileCommand = command; MspELFCompiler.this.lastCompileCommand = command;
MspELFCompiler.this.sourceFile = sourceFile; MspELFCompiler.this.sourceFile = sourceFile;
MspELFCompiler.this.ELFFile = ELFFile; MspELFCompiler.this.ELFFile = firmwareFile;
if (successAction != null) { if (successAction != null) {
successAction.actionPerformed(null); successAction.actionPerformed(null);
} }
@ -667,9 +668,6 @@ public abstract class MspMoteType implements MoteType {
"Bad return value").initCause(syncException); "Bad return value").initCause(syncException);
} }
} }
else {
}
} catch (IOException ex) { } catch (IOException ex) {
if (failAction != null) { if (failAction != null) {
failAction.actionPerformed(null); failAction.actionPerformed(null);