TIMEOUT(50000, log.log("last msg: " + msg + "\n")); /* print last msg at timeout */

helloworld = new java.io.File("../../../examples/sky-shell-exec/hello-world.ce");
log.log("Running test on:  " + helloworld.getAbsolutePath() + "\n");
if (!helloworld.exists()) {
  log.log("hello-world.ce does not exist\n");
  log.testFailed();
}

log.log("Waiting for node startup\n");
WAIT_UNTIL(msg.contains('1.0: Contiki>'));

log.log("Preparing node for incoming data\n");
node.write("dec64 | write hello-world.ce | null");
GENERATE_MSG(1000, "continue");
YIELD_THEN_WAIT_UNTIL(msg.equals("continue"));

log.log("Uploading hello-world.ce:\n");
cmdarr = "sh -c xxx".split(" ");
cmdarr[2] = "../../tools/base64-encode < hello-world.ce";
process = new java.lang.Runtime.getRuntime().exec(cmdarr, null, helloworld.getParentFile());
stdIn = new java.io.BufferedReader(new java.io.InputStreamReader(process.getInputStream()));
while ((line = stdIn.readLine()) != null) {
  node.write(line + "\n");
  log.log(line + "\n");

  GENERATE_MSG(1000, "continue");
  YIELD_THEN_WAIT_UNTIL(msg.equals("continue"));
}
process.destroy();
GENERATE_MSG(500, "continue");
YIELD_THEN_WAIT_UNTIL(msg.equals("continue"));
node.write("~K\n");

log.log("Listing filesystem to make sure hello-world.ce exists\n");
GENERATE_MSG(500, "continue");
YIELD_THEN_WAIT_UNTIL(msg.equals("continue"));
node.write("ls\n");
WAIT_UNTIL(msg.contains("hello-world.ce"));

log.log("Starting hello world\n");
GENERATE_MSG(500, "continue");
YIELD_THEN_WAIT_UNTIL(msg.equals("continue"));
node.write("exec hello-world.ce\n");
WAIT_UNTIL(msg.contains("OK"));
log.log("> ELF loader returned OK\n");
WAIT_UNTIL(msg.contains("Hello, world"));
log.log("> Hello world process started\n");

log.log("Finished!\n");
log.testOK();

@@ -472,16 +472,8 @@
 te(%22
-dec64 %7C 
 writ
@@ -490,17 +490,11 @@
 rld.
-ce %7C null
+b64
 %22);%0A
@@ -604,18 +604,19 @@
 o-world.
-ce
+b64
 :%5Cn%22);%0Ac
@@ -966,35 +966,222 @@
 %22);%0A
-  log.log(line + %22%5Cn%22);%0A%0A  
+%0A  YIELD();%0A%0A  if (msg.startsWith(line)) %7B%0A    log.log(%22UPLOADED: %22 + line + %22%5Cn%22);%0A  %7D else %7B%0A    log.log(%22Serial port upload failed:%5Cn%22 + line + %22%5Cn%22 + msg + %22%5Cn%22);%0A    log.testFailed();%0A  %7D%0A%7D%0Aprocess.destroy();%0A
 GENE
@@ -1181,34 +1181,33 @@
 );%0AGENERATE_MSG(
-10
+5
 00, %22continue%22);
@@ -1207,18 +1207,16 @@
 inue%22);%0A
-  
 YIELD_TH
@@ -1254,34 +1254,33 @@
 nue%22));%0A
-%7D%0Aprocess.destroy(
+node.write(%22~K%5Cn%22
 );%0AGENER
@@ -1352,33 +1352,224 @@
 nue%22));%0A
-node.write(%22~K%5Cn%22
+%0Alog.log(%22Converting base64 to binary hello-world.ce%5Cn%22);%0Anode.write(%22read hello-world.b64 %7C dec64 %7C write hello-world.ce %7C null%22);%0AGENERATE_MSG(3000, %22continue%22);%0AYIELD_THEN_WAIT_UNTIL(msg.equals(%22continue%22)
 );%0A%0Alog.

test update: verify base64 data uploaded via serial port