Programming
Workshop

Spring 2007
course
navigation

apr 25

lego robots ?

lejos API
... actually go upstairs and try to run something from, say, http://lejos.sourceforge.net/tutorial/communication/rcxcomm.html :
Things to try:
/// Send a number. import josx.rcxcomm.*; import josx.platform.rcx.*; // includes Sound object import java.io.*; public class TestRCXComm { public static RCXPort port = new RCXPort(); public static int magicNumber = 7; public static void nBeeps(int n){ for (int i=0; i<n; i++)}{ Sound.beep(); } wait(1.0); } public static void wait(double seconds){ try { Thread.sleep((long)(seconds/1000.0)); } catch (InterruptedException ie){ } } public static void send(int data){ nBeeps(1); // getting ready to send try { OutputStream os = port.getOutputStream(); os.write(data); os.flush(); } catch (IOException ioe) { Sound.buzz(); // something bad happened } nBeeps(2); // sent. } public static void receive(int expected){ InputStream is = port.getInputStream(); int data = is.read(); if (data == expected){ Sound.beepSequence(); } else { nBeeps(1); } } public static void main(String [] args) { while (true){ if (Button.VIEW.isPressed()){ Sound.beepSequence(); // yes, I'm alive } else if (Button.PRGM.isPressed()){ // send or recieve // Comment one of these two lines out, // depending on whether you're loading it into // the sender or reciever. // Timing? Is receive a blocking call?? send(magicNumber); // beep <sending> beep beep receive(magicNumber); // success: melody; failure: one beep } }

Smart::Comments and some perl goodies

http://search.cpan.org/dist/Smart-Comments/lib/Smart/Comments.pm
CPAN
perlmonks.org
http://search.cpan.org/~alian/Filesys-SmbClient-3.1/SmbClient.pm

TeRK

fablab

http://www.fabathome.org/wiki/index.php?title=Main_Page
http://cs.marlboro.edu/ courses/ spring2007/programming_workshop/ notes/ apr_25
last modified Thursday April 26 2007 1:40 am EDT