Did you recompile the java file?
There's some likelihood that executing the following from the
/opt/tinyos-2.x/support/sdk/java directory will do the trick :
javac -cp . net/tinyos/tools/Listen.java
MS
gaurav mathur wrote:
Hi,
I am using tinyos-2.x on xubuntu. To store received packets in a table
(table name: blinkToRadio) in mysql data base, I made some changes in
Listen.java
(/opt/tinyos-2.x/support/sdk/java/net/tinyos/tools/Listen.java) and run
the command
java net.tinyos.tools.Listen -comm serial@/dev/ttyUSB0:tmote
on command line.
this is giving output same as earlier Listen.java (before modification).
my java code is:
package net.tinyos.tools;
import java.io.*;
import net.tinyos.packet.*;
import net.tinyos.util.*;
import net.tinyos.message.*;
import java.sql.*;
public class Listen {
public static void main(String args[]) throws Exception {
Connection con = null;
int reading[];
try {
Class.forName("com.mysql.jdbc.Driver");
con =
DriverManager.getConnection("jdbc:mysql://localhost:3306/mysql?","sensor","sensor");
System.out.println("grv");
System.out.println(con);
} catch (Exception e)
{
System.out.println("Error getting connection to " + "mysql");
e.printStackTrace();
}
PreparedStatement pst=null;
String source = null;
PacketSource reader;
if (args.length == 2 && args[0].equals("-comm")) {
source = args[1];
}
else if (args.length > 0) {
System.err.println("usage: java net.tinyos.tools.Listen
[-comm PACKETSOURCE]");
System.err.println(" (default packet source from
MOTECOM environment variable)");
System.exit(2);
}
if (source == null) {
reader = BuildSource.makePacketSource();
}
else {
reader = BuildSource.makePacketSource(source);
}
if (reader == null) {
System.err.println("Invalid packet source (check your
MOTECOM environment variable)");
System.exit(2);
}
try {
reader.open(PrintStreamMessenger.err);
for (;;) {
reading = new int[12];
int ii=0;
byte[] packet = reader.readPacket();
for(ii=0;ii<12;ii++)//convert byte to integer
{
reading[ii]=packet[ii];
}
pst=con.prepareStatement("insert into blinkToRadio
values(?,?,?)");
pst.setInt(1,reading[9]);//mote id
pst.setInt(2,reading[10]);//count 1
pst.setInt(3,reading[11]);//count 2
pst.executeUpdate();
Dump.printPacket(System.out, packet);
System.out.println();
System.out.flush();
}
}
catch (IOException e) {
System.err.println("Error on " + reader.getName() + ": " + e);
}
}
}
There is no problem with data base because I can read and write data in
same table by other java programs.
So please suggest me how can I save incomming packets in a table in
mysql database.
Thanks.
------------------------------------------------------------------------
Never miss a thing. Make Yahoo your homepage.
<http://us.rd.yahoo.com/evt=51438/*http://www.yahoo.com/r/hs>
------------------------------------------------------------------------
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
--
Platform: WinXP/Cygwin
TinyOS version: 1.x, Boomerang
Programmer: MIB510
Device(s): Mica2, MicaZ, Tmote
Sensor board: homebrew
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help