added two example scripts
This commit is contained in:
parent
62c8535678
commit
54ac5bc64e
13
tools/cooja/config/scripts/log_all.js
Normal file
13
tools/cooja/config/scripts/log_all.js
Normal file
|
@ -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();
|
||||
}
|
27
tools/cooja/config/scripts/shell.js
Normal file
27
tools/cooja/config/scripts/shell.js
Normal file
|
@ -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");
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue