diff --git a/tools/cooja/config/scripts/log_all.js b/tools/cooja/config/scripts/log_all.js new file mode 100644 index 000000000..d4eb6233f --- /dev/null +++ b/tools/cooja/config/scripts/log_all.js @@ -0,0 +1,13 @@ +/* + * Example Contiki test script (JavaScript). + * A Contiki test script acts on mote output, such as via printf()'s. + * The script may operate on the following variables: + * Mote mote, int id, String msg + */ + +TIMEOUT(60000); + +while (true) { + log.log(time + ":" + id + ":" + msg + "\n"); + YIELD(); +} diff --git a/tools/cooja/config/scripts/shell.js b/tools/cooja/config/scripts/shell.js new file mode 100644 index 000000000..6590aa481 --- /dev/null +++ b/tools/cooja/config/scripts/shell.js @@ -0,0 +1,27 @@ +/* + * Example Contiki test script (JavaScript). + * A Contiki test script acts on mote output, such as via printf()'s. + * The script may operate on the following variables: + * Mote mote, int id, String msg + */ + +/* Wait until node has booted */ +WAIT_UNTIL(msg.startsWith('Starting')); +log.log("Mote started\n"); +mymote = mote; /* store mote reference */ + +/* Wait 3 seconds (3000ms) */ +GENERATE_MSG(3000, "continue"); +YIELD_THEN_WAIT_UNTIL(msg.equals("continue")); + +/* Write command to serial port */ +log.log("Writing 'ls' to mote serial port\n"); +write(mymote, "ls"); + +/* Read replies */ +while (true) { + YIELD(); + if (mote == mymote) { + log.log("Mote replied: " + msg + "\n"); + } +} \ No newline at end of file diff --git a/tools/cooja/java/se/sics/cooja/plugins/ScriptRunner.java b/tools/cooja/java/se/sics/cooja/plugins/ScriptRunner.java index e050c8868..51205ad41 100644 --- a/tools/cooja/java/se/sics/cooja/plugins/ScriptRunner.java +++ b/tools/cooja/java/se/sics/cooja/plugins/ScriptRunner.java @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: ScriptRunner.java,v 1.23 2009/10/23 11:55:53 fros4943 Exp $ + * $Id: ScriptRunner.java,v 1.24 2009/10/29 14:39:08 fros4943 Exp $ */ package se.sics.cooja.plugins; @@ -66,8 +66,10 @@ public class ScriptRunner extends VisPlugin { private static Logger logger = Logger.getLogger(ScriptRunner.class); final String[] EXAMPLE_SCRIPTS = new String[] { - "basic.js", "Basic example script", + "basic.js", "Various commands", "helloworld.js", "Wait for 'Hello, world'", + "log_all.js", "Just log all printf()'s and timeout", + "shell.js", "Basic shell interaction", }; private Simulation simulation;