[Tinyos-contrib-commits]
CVS: tinyos-1.x/contrib/rincon/tools/java/com/rincon/blackbook/bfiledir
BFileDirEvents.java, NONE, 1.1 BFileDirArgParser.java, NONE,
1.1 BFileDirArgParser.class, NONE, 1.1 BFileDirCommands.java,
NONE, 1.1 BFileDirCommands.class, NONE, 1.1 BFileDir.java,
NONE, 1.1 BFileDirEvents.class, NONE, 1.1 BFileDir.class, NONE, 1.1
dmm
rincon at users.sourceforge.net
Thu Apr 20 16:02:54 PDT 2006
- Previous message: [Tinyos-contrib-commits]
CVS: tinyos-1.x/contrib/rincon/tools/java/com/rincon/flashbridgeviewer/receive
FlashViewerEvents.java, NONE, 1.1 FlashViewerEvents.class,
NONE, 1.1 FlashViewerReceiver.java, NONE,
1.1 FlashViewerReceiver.class, NONE, 1.1
- Next message: [Tinyos-contrib-commits]
CVS: tinyos-1.x/contrib/rincon/tools/java/com/rincon/blackbook/bclean
BClean.java, NONE, 1.1 BClean.class, NONE,
1.1 BCleanEvents.java, NONE, 1.1 todo.txt, NONE,
1.1 BCleanEvents.class, NONE, 1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/tinyos/tinyos-1.x/contrib/rincon/tools/java/com/rincon/blackbook/bfiledir
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15414/contrib/rincon/tools/java/com/rincon/blackbook/bfiledir
Added Files:
BFileDirEvents.java BFileDirArgParser.java
BFileDirArgParser.class BFileDirCommands.java
BFileDirCommands.class BFileDir.java BFileDirEvents.class
BFileDir.class
Log Message:
Fixed the java/com directory, and added in two more packages: Blackbook, and EavesLogger.
--- NEW FILE: BFileDirEvents.java ---
package com.rincon.blackbook.bfiledir;
/*
* Copyright (c) 2004-2006 Rincon Research Corporation.
* All rights reserved.
*
* Rincon Research will permit distribution and use by others subject to
* the restrictions of a licensing agreement which contains (among other things)
* the following restrictions:
*
* 1. No credit will be taken for the Work of others.
* 2. It will not be resold for a price in excess of reproduction and
* distribution costs.
* 3. Others are not restricted from copying it or using it except as
* set forward in the licensing agreement.
* 4. Commented source code of any modifications or additions will be
* made available to Rincon Research on the same terms.
* 5. This notice will remain intact and displayed prominently.
*
* Copies of the complete licensing agreement may be obtained by contacting
* Rincon Research, 101 N. Wilmot, Suite 101, Tucson, AZ 85711.
*
* There is no warranty with this product, either expressed or implied.
* Use at your own risk. Rincon Research is not liable or responsible for
* damage or loss incurred or resulting from the use or misuse of this software.
*/
public interface BFileDirEvents {
/**
* The corruption check on a file is complete
* @param fileName - the name of the file that was checked
* @param isCorrupt - TRUE if the file's actual data does not match its CRC
* @param result - SUCCESS if this information is valid.
*/
public void corruptionCheckDone(boolean isCorrupt, boolean result);
/**
* The check to see if a file exists is complete
* @param fileName - the name of the file
* @param doesExist - TRUE if the file exists
* @param result - SUCCESS if this information is valid
*/
public void existsCheckDone(boolean doesExist, boolean result);
/**
* This is the next file in the file system after the given
* present file.
* @param fileName - name of the next file
* @param result - SUCCESS if this is actually the next file,
* FAIL if the given present file is not valid or there is no
* next file.
*/
public void nextFile(String fileName, boolean result);
}
--- NEW FILE: BFileDirArgParser.java ---
package com.rincon.blackbook.bfiledir;
/*
* Copyright (c) 2004-2006 Rincon Research Corporation.
* All rights reserved.
*
* Rincon Research will permit distribution and use by others subject to
* the restrictions of a licensing agreement which contains (among other things)
* the following restrictions:
*
* 1. No credit will be taken for the Work of others.
* 2. It will not be resold for a price in excess of reproduction and
* distribution costs.
* 3. Others are not restricted from copying it or using it except as
* set forward in the licensing agreement.
* 4. Commented source code of any modifications or additions will be
* made available to Rincon Research on the same terms.
* 5. This notice will remain intact and displayed prominently.
*
* Copies of the complete licensing agreement may be obtained by contacting
* Rincon Research, 101 N. Wilmot, Suite 101, Tucson, AZ 85711.
*
* There is no warranty with this product, either expressed or implied.
* Use at your own risk. Rincon Research is not liable or responsible for
* damage or loss incurred or resulting from the use or misuse of this software.
*/
public class BFileDirArgParser implements BFileDirEvents {
/** Transceiver communication with the mote */
private BFileDir bFileDir;
/**
* Constructor
* @param args
*/
public BFileDirArgParser(String[] args) {
bFileDir = new BFileDir();
bFileDir.addListener(this);
if(args.length < 1) {
reportError("Not enough arguments");
}
if(args[0].toLowerCase().matches("-gettotalfiles")) {
System.out.println(bFileDir.getTotalFiles() + " total files");
System.exit(0);
} else if(args[0].toLowerCase().matches("-gettotalnodes")) {
System.out.println(bFileDir.getTotalNodes() + " total nodes");
System.exit(0);
} else if(args[0].toLowerCase().matches("-checkexists")) {
if (args.length > 1) {
bFileDir.checkExists(args[1]);
} else {
reportError("Missing parameter(s)");
}
} else if(args[0].toLowerCase().matches("-readfirst")) {
bFileDir.readFirst();
} else if(args[0].toLowerCase().matches("-readnext")) {
if (args.length > 1) {
bFileDir.readNext(args[1]);
} else {
reportError("Missing parameter(s)");
}
} else if(args[0].toLowerCase().matches("-getreservedlength")) {
if (args.length > 1) {
System.out.println(bFileDir.getReservedLength(args[1]) + " bytes reserved");
System.exit(0);
} else {
reportError("Missing parameter(s)");
}
} else if(args[0].toLowerCase().matches("-getdatalength")) {
if (args.length > 1) {
System.out.println(bFileDir.getDataLength(args[1]) + " bytes");
System.exit(0);
} else {
reportError("Missing parameter(s)");
}
} else if(args[0].toLowerCase().matches("-checkcorruption")) {
if (args.length > 1) {
bFileDir.checkCorruption(args[1]);
} else {
reportError("Missing parameter(s)");
}
} else if(args[0].toLowerCase().matches("-getfreespace")) {
System.out.println(bFileDir.getFreeSpace() + " bytes available");
System.exit(0);
} else {
System.err.println("Unknown argument: " + args[0]);
System.err.println(getUsage());
System.exit(1);
}
}
private void reportError(String error) {
System.err.println(error);
System.err.println(getUsage());
System.exit(1);
}
public static String getUsage() {
String usage = "";
usage += " BFileDir\n";
usage += "\t-getTotalFiles\n";
usage += "\t-getTotalNodes\n";
usage += "\t-getFreeSpace\n";
usage += "\t-checkExists <filename>\n";
usage += "\t-readFirst\n";
usage += "\t-readNext <current filename>\n";
usage += "\t-getReservedLength <filename>\n";
usage += "\t-getDataLength <filename>\n";
usage += "\t-checkCorruption <filename>\n";
return usage;
}
/***************** BFileDir Events ****************/
public void corruptionCheckDone(boolean isCorrupt, boolean result) {
System.out.print("BFileDir corruption check ");
if(result) {
System.out.print("SUCCESS: ");
if(isCorrupt) {
System.out.println("Corrupted!");
} else {
System.out.println("File OK");
}
} else {
System.out.println("FAIL");
}
System.exit(0);
}
public void existsCheckDone(boolean doesExist, boolean result) {
System.out.print("BFileDir exists check ");
if(result) {
System.out.print("SUCCESS: ");
if(doesExist) {
System.out.println("File Exists");
} else {
System.out.println("File does not exist");
}
} else {
System.out.println("FAIL");
}
System.exit(0);
}
public void nextFile(String fileName, boolean result) {
System.out.print("BFileDir next file ");
if(result) {
System.out.println("SUCCESS: " + fileName);
} else {
System.out.println("FAIL: No next file");
}
System.exit(0);
}
}
--- NEW FILE: BFileDirArgParser.class ---
Êþº¾
-readfirst
Corrupted!
SourceFile
--- NEW FILE: BFileDirCommands.java ---
package com.rincon.blackbook.bfiledir;
/*
* Copyright (c) 2004-2006 Rincon Research Corporation.
* All rights reserved.
*
* Rincon Research will permit distribution and use by others subject to
* the restrictions of a licensing agreement which contains (among other things)
* the following restrictions:
*
* 1. No credit will be taken for the Work of others.
* 2. It will not be resold for a price in excess of reproduction and
* distribution costs.
* 3. Others are not restricted from copying it or using it except as
* set forward in the licensing agreement.
* 4. Commented source code of any modifications or additions will be
* made available to Rincon Research on the same terms.
* 5. This notice will remain intact and displayed prominently.
*
* Copies of the complete licensing agreement may be obtained by contacting
* Rincon Research, 101 N. Wilmot, Suite 101, Tucson, AZ 85711.
*
* There is no warranty with this product, either expressed or implied.
* Use at your own risk. Rincon Research is not liable or responsible for
* damage or loss incurred or resulting from the use or misuse of this software.
*/
public interface BFileDirCommands {
/**
* @return the total number of files in the file system
*/
public short getTotalFiles();
/**
* @return the total number of nodes in the file system
*/
public int getTotalNodes();
/**
* @return the approximate free space on flash
*/
public long getFreeSpace();
/**
* Returns TRUE if the file exists, FALSE if it doesn't
*/
public void checkExists(String fileName);
/**
* An optional way to read the first filename from
* the system. This is the same as calling
* BFileDir.readNext(NULL)
*/
public void readFirst();
/**
* Read the next file in the file system, based on the
* current filename.If you want to find the first
* file in the file system, pass in NULL.
*
* If the next file exists, it will be returned in the
* nextFile event with result SUCCESS
*
* If there is no next file, the nextFile event will
* signal with the filename passed in and FAIL.
*
* If the present filename passed in doesn't exist,
* then this public returns FAIL and no signal is given.
*
* @param presentFilename - the name of the current file,
* of which you want to find the next valid file after.
*/
public void readNext(String presentFilename);
/**
* Get the total reserved bytes of an existing file
* @param fileName - the name of the file to pull the reservedLength from.
* @return the reservedLength of the file, 0 if it doesn't exist
*/
public long getReservedLength(String fileName);
/**
* Get the total amount of data written to the file with
* the given fileName.
* @param fileName - name of the file to pull the dataLength from.
* @return the dataLength of the file, 0 if it doesn't exist
*/
public long getDataLength(String fileName);
/**
* Find if a file is corrupt. This will read each node
* from the file and verify it against its dataCrc.
* If the calculated data CRC from a node does
* not match the node's recorded CRC, the file is corrupt.
* @return SUCCESS if the corrupt check will proceed.
*/
public void checkCorruption(String fileName);
}
--- NEW FILE: BFileDirCommands.class ---
Êþº¾
SourceFile
--- NEW FILE: BFileDir.java ---
package com.rincon.blackbook.bfiledir;
/*
* Copyright (c) 2004-2006 Rincon Research Corporation.
* All rights reserved.
*
* Rincon Research will permit distribution and use by others subject to
* the restrictions of a licensing agreement which contains (among other things)
* the following restrictions:
*
* 1. No credit will be taken for the Work of others.
* 2. It will not be resold for a price in excess of reproduction and
* distribution costs.
* 3. Others are not restricted from copying it or using it except as
* set forward in the licensing agreement.
* 4. Commented source code of any modifications or additions will be
* made available to Rincon Research on the same terms.
* 5. This notice will remain intact and displayed prominently.
*
* Copies of the complete licensing agreement may be obtained by contacting
* Rincon Research, 101 N. Wilmot, Suite 101, Tucson, AZ 85711.
*
* There is no warranty with this product, either expressed or implied.
* Use at your own risk. Rincon Research is not liable or responsible for
* damage or loss incurred or resulting from the use or misuse of this software.
*/
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import com.rincon.blackbook.Commands;
import com.rincon.blackbook.Util;
import com.rincon.blackbook.messages.BlackbookConnectMsg;
import net.tinyos.message.Message;
import net.tinyos.message.MessageListener;
import net.tinyos.message.MoteIF;
import net.tinyos.util.Messenger;
public class BFileDir implements BFileDirCommands, MessageListener {
/** Communication with the mote */
private MoteIF comm = new MoteIF((Messenger) null);
/** Command to send */
private BlackbookConnectMsg command = new BlackbookConnectMsg();
/** List of FileTransferEvents listeners */
private static List listeners = new ArrayList();
/** Current destination address */
private int dest = Commands.TOS_BCAST_ADDR;
/** Return value for inline commands */
private long returnAmount = 0;
/**
* Set the destination address of the next send command
* @param destination
*/
public void setDestination(int destination) {
dest = destination;
}
/**
* Constructor
*
*/
public BFileDir() {
comm.registerListener(new BlackbookConnectMsg(), this);
}
/**
* Send a message
* @param dest
* @param m
*/
private synchronized void send(Message m) {
try {
comm.send(dest, m);
} catch (IOException e) {
System.err.println("Couldn't contact the mote");
}
}
/**
* Add a FileTransferEvents listener
* @param listener
*/
public void addListener(BFileDirEvents listener) {
if(!listeners.contains(listener)) {
listeners.add(listener);
}
}
/**
* Remove a FileTransferEvents listener
* @param listener
*/
public void removeListener(BFileDirEvents listener) {
listeners.remove(listener);
}
public synchronized void messageReceived(int to, Message m) {
BlackbookConnectMsg inMsg = (BlackbookConnectMsg) m;
switch(inMsg.get_cmd()) {
case Commands.REPLY_BFILEDIR_TOTALFILES:
returnAmount = inMsg.get_length();
notify();
break;
case Commands.REPLY_BFILEDIR_TOTALNODES:
returnAmount = inMsg.get_length();
notify();
break;
case Commands.REPLY_BFILEDIR_EXISTS:
for(Iterator it = listeners.iterator(); it.hasNext(); ) {
((BFileDirEvents) it.next()).existsCheckDone(inMsg.get_length() == 1, inMsg.get_result() == Commands.SUCCESS);
}
break;
case Commands.REPLY_BFILEDIR_READNEXT:
for(Iterator it = listeners.iterator(); it.hasNext(); ) {
((BFileDirEvents) it.next()).nextFile(Util.dataToFilename(inMsg.get_data()), inMsg.get_result() == Commands.SUCCESS);
}
break;
case Commands.REPLY_BFILEDIR_RESERVEDLENGTH:
returnAmount = inMsg.get_length();
notify();
break;
case Commands.REPLY_BFILEDIR_DATALENGTH:
returnAmount = inMsg.get_length();
notify();
break;
case Commands.REPLY_BFILEDIR_GETFREESPACE:
returnAmount = inMsg.get_length();
notify();
break;
case Commands.REPLY_BFILEDIR_CHECKCORRUPTION:
for(Iterator it = listeners.iterator(); it.hasNext(); ) {
((BFileDirEvents) it.next()).corruptionCheckDone(inMsg.get_length() == 1, inMsg.get_result() == Commands.SUCCESS);
}
break;
case Commands.ERROR_BFILEDIR_TOTALFILES:
case Commands.ERROR_BFILEDIR_TOTALNODES:
case Commands.ERROR_BFILEDIR_EXISTS:
case Commands.ERROR_BFILEDIR_READNEXT:
case Commands.ERROR_BFILEDIR_RESERVEDLENGTH:
case Commands.ERROR_BFILEDIR_DATALENGTH:
case Commands.ERROR_BFILEDIR_CHECKCORRUPTION:
case Commands.ERROR_BFILEDIR_READFIRST:
case Commands.ERROR_BFILEDIR_GETFREESPACE:
System.err.println("Command immediately failed");
System.exit(1);
default:
}
}
public synchronized short getTotalFiles() {
command.set_cmd(Commands.CMD_BFILEDIR_TOTALFILES);
send(command);
try {
wait(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return (short) returnAmount;
}
public synchronized int getTotalNodes() {
command.set_cmd(Commands.CMD_BFILEDIR_TOTALNODES);
send(command);
try {
wait(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return (int) returnAmount;
}
public synchronized long getFreeSpace() {
command.set_cmd(Commands.CMD_BFILEDIR_GETFREESPACE);
send(command);
try {
wait(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
return returnAmount;
}
public void checkExists(String fileName) {
command.set_cmd(Commands.CMD_BFILEDIR_EXISTS);
command.set_data(Util.filenameToData(fileName));
send(command);
}
public void readFirst() {
command.set_cmd(Commands.CMD_BFILEDIR_READFIRST);
send(command);
}
public void readNext(String presentFilename) {
command.set_cmd(Commands.CMD_BFILEDIR_READNEXT);
command.set_data(Util.filenameToData(presentFilename));
send(command);
}
public synchronized long getReservedLength(String fileName) {
command.set_cmd(Commands.CMD_BFILEDIR_RESERVEDLENGTH);
command.set_data(Util.filenameToData(fileName));
send(command);
try {
wait(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return returnAmount;
}
public synchronized long getDataLength(String fileName) {
command.set_cmd(Commands.CMD_BFILEDIR_DATALENGTH);
command.set_data(Util.filenameToData(fileName));
send(command);
try {
wait(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return returnAmount;
}
public void checkCorruption(String fileName) {
command.set_cmd(Commands.CMD_BFILEDIR_CHECKCORRUPTION);
command.set_data(Util.filenameToData(fileName));
send(command);
}
}
--- NEW FILE: BFileDirEvents.class ---
Êþº¾
SourceFile
--- NEW FILE: BFileDir.class ---
Êþº¾
get_length
get_result
SourceFile
- Previous message: [Tinyos-contrib-commits]
CVS: tinyos-1.x/contrib/rincon/tools/java/com/rincon/flashbridgeviewer/receive
FlashViewerEvents.java, NONE, 1.1 FlashViewerEvents.class,
NONE, 1.1 FlashViewerReceiver.java, NONE,
1.1 FlashViewerReceiver.class, NONE, 1.1
- Next message: [Tinyos-contrib-commits]
CVS: tinyos-1.x/contrib/rincon/tools/java/com/rincon/blackbook/bclean
BClean.java, NONE, 1.1 BClean.class, NONE,
1.1 BCleanEvents.java, NONE, 1.1 todo.txt, NONE,
1.1 BCleanEvents.class, NONE, 1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Tinyos-contrib-commits
mailing list