I'm going to guess that dataGet() returns the "data" portion of the TOS message as a byte[]. You will need to convert the bytes in that array into a set of 32bit ints. Fundamentally the nesc ints have been marshaled into a byte stream and need to be un-marshaled into java types. Look at classes generated by MIG for some (probably confusing) examples. Or look at my posted code: http://www.etantdonnes.com/Motes/robocode.tar.gz I think in RoboMessage.java there are methods ti() and fi() to convert byte streams to and from 2 byte java ints, which are (probably even more) confusing...
MS Jordi Soucheiron wrote: > Hello, > The problem seems to be the return type of the dataGet function. You > should check it. > You should be careful when you convert uint32_t to ints in java, > because you may have overflows (java doesn't allow unsigned types) > that aren't easy to find. > Good luck > > 2010/2/16 Sam Azarro <[email protected]>: >> Thanks for your reply. >> i tried that. >> in fact, in TestSerialc.nc i did : uint8_t matrix[2][2] = { {0,1}, {2,3} }; >> in TestSerial.h : nx_uint32_t matrix[2][2]; >> and in Testserial.java : >> public void messageReceived(int to, Message message) { >> int [][] matrix = new int [2][2]; >> int i,j; >> TestSerialMsg msg = (TestSerialMsg)message; >> for(i=0; i<2 ; i++) >> for (j=0; j<2; j++) >> { >> System.out.println("Received packet sequence number " + >> msg.dataGet()[0][0] + msg.dataGet()[0][1] + msg.dataGet()[1][0] + + >> msg.dataGet()[1][1]); >> } >> } >> >> >> i know that i'm using dataGet() method badly in this case but i don't know >> how to fix it!!!! i get this error: >> >> $ make telosb install >> mkdir -p build/telosb >> javac -target 1.4 -source 1.4 *.java >> TestSerial.java:74: array required, but byte found >> System.out.println("Received packet sequence number " + >> msg.dataGet()[0][0] + msg.dataGet()[0][1] + msg.dataGet()[1][0] + + msg.data >> Get()[1][1]); >> >> ^ >> TestSerial.java:74: array required, but byte found >> System.out.println("Received packet sequence number " + >> msg.dataGet()[0][0] + msg.dataGet()[0][1] + msg.dataGet()[1][0] + + msg.data >> Get()[1][1]); >> >> ^ >> TestSerial.java:74: array required, but byte found >> System.out.println("Received packet sequence number " + >> msg.dataGet()[0][0] + msg.dataGet()[0][1] + msg.dataGet()[1][0] + + msg.data >> Get()[1][1]); >> >> ^ >> TestSerial.java:74: array required, but byte found >> System.out.println("Received packet sequence number " + >> msg.dataGet()[0][0] + msg.dataGet()[0][1] + msg.dataGet()[1][0] + + msg.data >> Get()[1][1]); >> >> ^ >> 4 errors >> make: *** [TestSerial.class] Error 1 >> >> >> even when i change byte [][] matrix = new byte [2][2]; i get the same error >> >> can you help me please?? >> >> Regards, >> >> ________________________________ >> Votre messagerie et bien plus où que vous soyez. Passez à Windows Live >> Hotmail, c'est gratuit ! Inscrivez-vous > > > _______________________________________________ Tinyos-help mailing list [email protected] https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
