Hello, The main problem you have here it's that you're defining functions inside another function (you can't do that in java). This causes the compiler errors you're receiving. Once you've solved this you'll have to solve the other issues you have (usually you'll have to modify various files from the ones you mention, but you should NEVER change BaseStation except you know what you're doing). Good luck,
PD: Please don't send emails only to me, send them to the mailing list. There's more people there who can help you 2010/2/9 Asmouchka Pink <[email protected]>: > Hello, > > Sorry to be a little nervous, i'm beginner and i did not found some help. > Actually, i want to send an array of bytes between mote and pc then display > it. > i read the source code from TestSerial.java and even the .nc code of the > other applications in that tutorials. > but here is the problem: files are to much and i was confused where should i > change the code (in Testserial.java, TestSerialC.nc,BlinkToRadio.nc, > BaseStation...)!!!!! > i tried in TestSerial.java cause i know it's the GUI that display data. > i defined an array of 5 bytes , and here is my code : > > import java.io.IOException; > import net.tinyos.message.*; > import net.tinyos.packet.*; > import net.tinyos.util.*; > public class TestSerial implements MessageListener { > private MoteIF moteIF; > public TestSerial(MoteIF moteIF) { > uint16_t i=0; > //int counter =0; > byte [] tab = new tab [5]; > payload = new TestSerialMsg(); > this.moteIF = moteIF; > this.moteIF.registerListener(new TestSerialMsg(), this); > } > public void sendPackets() { > try { > while (true) { > for(i=0; i< tab.lenght ;i++) > { > tab[i]= i+ 2; // just to set values in the tab > System.out.println("Sending packet " + i); > //payload.set_counter(counter); > payload.set_tab(i); > moteIF.send(0, payload); > System.out.println("Sending value " + tab[i]); > //counter++; > } > > try {Thread.sleep(1000);} > catch (InterruptedException exception) {} > } > } > catch (IOException exception) { > System.err.println("Exception thrown when sending packets. Exiting."); > System.err.println(exception); > } > } > public void messageReceived(int to, Message message) { > TestSerialMsg msg = (TestSerialMsg)message; > System.out.println("Received packet sequence number " + msg.get_tab()); > System.out.println("Received value " + msg.dataGet()); > } > > private static void usage() { > System.err.println("usage: TestSerial [-comm <source>]"); > } > > public static void main(String[] args) throws Exception { > String source = null; > if (args.length == 2) { > if (!args[0].equals("-comm")) { > usage(); > System.exit(1); > } > source = args[1]; > } > else if (args.length != 0) { > usage(); > System.exit(1); > } > > PhoenixSource phoenix; > > if (source == null) { > phoenix = BuildSource.makePhoenix(PrintStreamMessenger.err); > } > else { > phoenix = BuildSource.makePhoenix(source, PrintStreamMessenger.err); > } > /** > * here i defined a method to Set the value of the filed tab[i]' > */ > void set_tab (int i) { > setUIntBEElement(offsetBits_tab (), 16, value); > } > /** > * Return the value (as a int) of the field 'tab[i]' > */ > int get_tab () { > return (int)getUIntBEElement(offsetBits_tab (), 16); > } > MoteIF mif = new MoteIF(phoenix); > TestSerial serial = new TestSerial(mif); > serial.sendPackets(); > > } > } > > when i installed the application in telosb mote i get this : > > administrat...@v8fmk15ebx5la4b /opt/tinyos-2.x/apps/TestSerial > $ make telosb install > mkdir -p build/telosb > javac -target 1.4 -source 1.4 *.java > TestSerial.java:113: illegal start of expression > void set_tab (int i) { > ^ > TestSerial.java:113: ';' expected > void set_tab (int i) { > ^ > TestSerial.java:113: ';' expected > void set_tab (int i) { > ^ > TestSerial.java:119: ';' expected > int get_tab () { > ^ > 4 errors > make: *** [TestSerial.class] Error 1 > > So, for this, i want to know first if my way of thinking true ? and how can > i correct this code. > note: i work in Tinyos 2.1 on WinXp > > thanks in advance > > > ________________________________ > Hotmail : une messagerie performante et gratuite avec une sécurité signée > Microsoft Profitez-en -- Jordi Soucheiron Software Engineer DEXMA Parc Tecnològic la Salle Sant Joan de la Salle, 42 08022 Barcelona t/f: [+34] 93 181 01 95 www.dexmatech.com [email protected] _______________________________________________ Tinyos-help mailing list [email protected] https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
