[Tinyos-contrib-commits]
CVS: tinyos-1.x/contrib/rincon/tools/java/com/rincon/flashbridgeviewer
FlashRunnerInterface.class, NONE, 1.1 ViewerCommands.class,
NONE, 1.1 DataOutput.java, NONE, 1.1 FlashViewer.java, NONE,
1.1 CommandRunner.class, NONE, 1.1 ViewerCommands.java, NONE,
1.1 CommandRunner.java, NONE, 1.1 DataOutput.class, NONE,
1.1 FlashViewer.class, NONE, 1.1 FlashRunnerInterface.java,
NONE, 1.1
dmm
rincon at users.sourceforge.net
Thu Apr 20 16:02:55 PDT 2006
- Previous message: [Tinyos-contrib-commits]
CVS: tinyos-1.x/contrib/rincon/tools/java/com/rincon/testharness/messages
TestMsg.java, NONE, 1.1 TestMsg.class, NONE, 1.1
- Next message: [Tinyos-contrib-commits]
CVS: tinyos-1.x/contrib/rincon/tools/java/com/rincon/jdebug/receiver
JDebugReceiver.class, NONE, 1.1 JDebugEvents.java, NONE,
1.1 JDebugEvents.class, NONE, 1.1 JDebugReceiver.java, NONE, 1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/tinyos/tinyos-1.x/contrib/rincon/tools/java/com/rincon/flashbridgeviewer
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15414/contrib/rincon/tools/java/com/rincon/flashbridgeviewer
Added Files:
FlashRunnerInterface.class ViewerCommands.class
DataOutput.java FlashViewer.java CommandRunner.class
ViewerCommands.java CommandRunner.java DataOutput.class
FlashViewer.class FlashRunnerInterface.java
Log Message:
Fixed the java/com directory, and added in two more packages: Blackbook, and EavesLogger.
--- NEW FILE: FlashRunnerInterface.class ---
Êþº¾
SourceFile
--- NEW FILE: ViewerCommands.class ---
Êþº¾
REPLY_READ
REPLY_PING
SourceFile
--- NEW FILE: DataOutput.java ---
package com.rincon.flashbridgeviewer;
/*
* 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.File;
import java.util.Arrays;
public class DataOutput {
/** True if we save to a file, False if we print to screen */
private boolean toFile = false;
/** File to dump the image to */
private File outFile;
/** The index we're writing to the screen */
private int screenIndex = 0;
/** Characters get printed at the end of every row */
private char[] characterView = new char[0x16];
/** Keep track of multi-messaged debug numbers */
private boolean numberNext = false;
/** Keep track of multi-messaged hex debug number formatting */
private boolean hex = false;
/**
* Method to output data either to the screen in a nice format, or to a
* binary file
*
* @param data
* @param
*/
public void output(short[] data, int length) {
// Print nicely to the screen
for (int i = 0; i < length; i++) {
characterView[screenIndex] = (char) data[i];
// Here's where we do our formatting
if (screenIndex == 8) {
// New 8-bit column space
System.out.print(" ");
}
if (screenIndex > 15) { // used to be 15
// Print out the character view and start a new line
dumpCharacters();
System.out.println();
screenIndex = 0;
}
if (Integer.toHexString(data[i]).length() < 2) {
// Numbers 0-F only prints 1 character instead of 2.
System.out.print("0");
}
System.out.print(Integer.toHexString(data[i]).toUpperCase() + " ");
screenIndex++;
}
}
private String resultToString(int result) {
if (result == 0) {
return "STORAGE_OK";
} else if (result == 1) {
return "STORAGE_FAIL";
} else if (result == 2) {
return "STORAGE_INVALID_SIGNATURE";
} else if (result == 3) {
return "STORAGE_INVALID_CRC";
}
return "INVALID RETURN CODE";
}
/**
* Turn an array of short[]'s to a String
*
* @param data
* @return
*/
private String dataToString(short[] data) {
String returnString = "";
for (int i = 0; i < data.length; i++) {
returnString += (char) data[i];
}
return returnString;
}
/**
* Dump the character representation of the last line to the screen
*
*/
private void dumpCharacters() {
System.out.print(" | ");
for (int charIndex = 0; charIndex < characterView.length; charIndex++) {
if (charIndex == 8) {
// 8-bit character column space
System.out.print(" ");
}
System.out.print(characterView[charIndex]);
}
Arrays.fill(characterView, ' ');
}
/**
* Flush out the remaining data
*
*/
public void flush() {
// to screen
for (int i = screenIndex; i < 16; i++) {
System.out.print(" ");
if (i == 8) {
// column
System.out.print(" ");
}
}
dumpCharacters();
System.out.println();
}
}
--- NEW FILE: FlashViewer.java ---
package com.rincon.flashbridgeviewer;
/*
* 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 com.rincon.flashbridgeviewer.messages.ViewerMsg;
import com.rincon.flashbridgeviewer.send.FlashViewerSender;
public class FlashViewer {
/** Object to run the commands */
private CommandRunner runner = new CommandRunner();
/*
* // Read the starting address
if (argv.length > ++index) {
startingAddress = parseLong(argv[index]);
} else {
reportError("Read requires a start address");
}
// Read the length
if (argv.length > ++index) {
packet.set_len(parseInt(argv[index]));
} else {
reportError("Data length required");
}
// Read the filename
if (argv.length > ++index) {
packet.set_data(stringToData(argv[index]));
} else {
reportError("Filename required");
}
*/
/**
* Constructor
* @param args
*/
public FlashViewer(String[] argv) {
if (argv.length < 1) {
reportError("No arguments found");
}
int index = 0;
String cmd = argv[0];
long startAddress = 0;
int moteID = 0;
long actualRange = 0;
short volume = 0;
short[] data = new short[ViewerMsg.totalSize_data()];
// Find and set the default mote id
if((moteID = parseInt(argv[0])) == -1) {
moteID = 1;
} else {
if(argv.length > 1) {
cmd = argv[1];
} else {
reportError("No command given");
}
}
if(cmd.matches("-read")) {
// Get the start address
if (argv.length > ++index) {
startAddress = parseLong(argv[index]);
} else {
reportError("Missing [start address]");
}
// Get the range
if (argv.length > ++index) {
actualRange = parseLong(argv[index]);
} else {
reportError("Missing [range]");
}
runner.read(startAddress, actualRange, moteID);
} else if(cmd.matches("-write")) {
// Get the start address
if (argv.length > ++index) {
startAddress = parseLong(argv[index]);
} else {
reportError("Missing [start address]");
}
char[] rawdata = null;
if (argv.length > ++index) {
rawdata = argv[index].toCharArray();
data = new short[ViewerMsg.totalSize_data()];
System.out.println("Writing data");
for (int i = 0; i < data.length && i < rawdata.length; i++) {
data[i] = (short) rawdata[i];
System.out.print("0x" + Integer.toHexString((int) data[i])
+ " ");
}
System.out.println();
} else {
reportError("Missing [data]");
}
runner.write(startAddress, data, rawdata.length, moteID);
} else if(cmd.matches("-erase")) {
// Get the start address
if (argv.length > ++index) {
startAddress = parseLong(argv[index]);
} else {
reportError("Missing [sector]");
}
runner.erase((int) startAddress, moteID);
} else if(cmd.matches("-flush")) {
runner.flush(moteID);
} else if(cmd.matches("-crc")) {
// Get the start address
if (argv.length > ++index) {
startAddress = parseLong(argv[index]);
} else {
reportError("Missing [start address]");
}
// Get the range
if (argv.length > ++index) {
actualRange = parseLong(argv[index]);
} else {
reportError("Missing [range]");
}
runner.crc(startAddress, (int)actualRange, moteID);
} else if(cmd.matches("-ping")) {
runner.ping(moteID);
} else {
reportError("No command given");
}
}
/**
* Attempt to decode the int value, and deal with any illegible remarks.
*
* @param intString
* @return
*/
public int parseInt(String intString) {
try {
return Integer.decode(intString).intValue();
} catch (NumberFormatException e) {
return -1;
}
}
/**
* Attempt to decode the long value, and deal with any illegible remarks.
*
* @param longString
* @return
*/
public long parseLong(String longString) {
try {
return Long.decode(longString).longValue();
} catch (NumberFormatException e) {
reportError(e.getMessage());
}
return -1;
}
/**
* Takes a filename string and converts it to a 14 element
* filename short array
* @param s
* @return
*/
public short[] stringToData(String s) {
int filenameLength = 14;
short[] returnData = new short[filenameLength];
char[] charData = s.toCharArray();
for(int i = 0; i < charData.length && i < filenameLength; i++) {
returnData[i] = (short) charData[i];
}
for(int i = charData.length; i < filenameLength; i++) {
returnData[i] = 0;
}
return returnData;
}
/**
* Report the syntax error, print the usage, and exit.
*
* @param error
*/
private void reportError(String error) {
System.err.println(error);
usage();
System.exit(1);
}
/**
* Prints the usage for this application
*
*/
private static void usage() {
System.err.println("Usage: java com.rincon.flashbridgeviewer.FlashViewer [mote] [command]");
System.err.println(" COMMANDS");
System.err.println(" -read [start address] [range]");
System.err.println(" -write [start address] [" + ViewerMsg.totalSize_data() + " characters]");
System.err.println(" -erase [sector]");
System.err.println(" -flush");
System.err.println(" -crc [start address] [range]");
System.err.println(" -ping");
System.err.println();
}
/**
* Main method
* @param args
*/
public static void main(String[] args) {
new FlashViewer(args);
}
}
--- NEW FILE: CommandRunner.class ---
Êþº¾
totalRange
SourceFile
*´
--- NEW FILE: ViewerCommands.java ---
package com.rincon.flashbridgeviewer;
/*
* 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 ViewerCommands {
public static final short CMD_READ = 0;
public static final short CMD_WRITE = 1;
public static final short CMD_ERASE = 2;
public static final short CMD_FLUSH = 4;
public static final short CMD_PING = 5;
public static final short CMD_CRC = 6;
public static final short REPLY_READ = 10;
public static final short REPLY_WRITE = 11;
public static final short REPLY_ERASE = 12;
public static final short REPLY_FLUSH = 14;
public static final short REPLY_PING = 15;
public static final short REPLY_CRC = 16;
public static final short REPLY_READ_CALL_FAILED = 20;
public static final short REPLY_WRITE_CALL_FAILED = 21;
public static final short REPLY_ERASE_CALL_FAILED = 22;
public static final short REPLY_FLUSH_CALL_FAILED = 24;
public static final short REPLY_CRC_CALL_FAILED = 26;
public static final short REPLY_READ_FAILED = 30;
public static final short REPLY_WRITE_FAILED = 31;
public static final short REPLY_ERASE_FAILED = 32;
public static final short REPLY_FLUSH_FAILED = 34;
public static final short REPLY_CRC_FAILED = 36;
}
--- NEW FILE: CommandRunner.java ---
package com.rincon.flashbridgeviewer;
/*
* 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 com.rincon.flashbridgeviewer.messages.ViewerMsg;
import com.rincon.flashbridgeviewer.receive.FlashViewerEvents;
import com.rincon.flashbridgeviewer.receive.FlashViewerReceiver;
import com.rincon.flashbridgeviewer.send.FlashViewerSender;
public class CommandRunner implements FlashViewerEvents, FlashRunnerInterface {
/** Receiving Mechanism */
private FlashViewerReceiver receiver = new FlashViewerReceiver();
/** Sending mechanism */
private FlashViewerSender mote = new FlashViewerSender();
/** Total range of data to read */
private long totalRange;
/** Current range of data to read */
private int focusedRange;
/** Current address to start reading from */
private long focusedAddress;
/** The address we started reading from */
private long startAddress;
/** The mote we're communicating with right now */
private int focusedMote;
/** Method to output data */
private DataOutput output = new DataOutput();
/**
* Constructor
*
*/
public CommandRunner() {
receiver.addListener(this);
}
/**
* Read some arbitrary range of values from the flash
*/
public void read(long address, long range, int moteID) {
totalRange = range;
startAddress = address;
focusedAddress = address;
focusedMote = moteID;
if(range > ViewerMsg.totalSize_data()) {
focusedRange = ViewerMsg.totalSize_data();
} else {
focusedRange = (int) range;
}
System.out.println("0x" + Long.toHexString(startAddress) + " to 0x" + Long.toHexString(startAddress + totalRange));
System.out.println("_________________________________________________");
mote.read(address, focusedRange, focusedMote);
}
/**
* Write data to the flash
*/
public void write(long address, short[] buffer, int length, int moteID) {
mote.write(address, buffer, length, moteID);
}
/**
* Erase data from the flash
*/
public void erase(int sector, int moteID) {
mote.erase(sector, moteID);
}
/**
* Mount to a volume id
*/
public void crc(long address, int length, int moteID) {
mote.crc(address, length, moteID);
}
/**
* Commit to flash
*/
public void flush(int moteID) {
mote.flush(moteID);
}
/**
* Ping the FlashViewer component on the mote.
*/
public void ping(int moteID) {
mote.ping(moteID);
}
/**
* Read is complete
*/
public void readDone(long address, short[] buffer, int length, boolean success) {
output.output(buffer, length);
if(!success) {
System.out.println("Failure to read data at " + Long.toHexString(address));
System.exit(1);
}
focusedAddress += length;
if(focusedAddress < startAddress + totalRange) {
if(((startAddress + totalRange) - focusedAddress) > ViewerMsg.totalSize_data()) {
focusedRange = ViewerMsg.totalSize_data();
} else {
focusedRange = (int) ((startAddress + totalRange) - focusedAddress);
}
mote.read(focusedAddress, focusedRange, focusedMote);
} else {
output.flush();
System.exit(0);
}
}
/**
* Write is complete
*/
public void writeDone(long address, short[] buffer, int length, boolean success) {
if(success) {
System.out.print("SUCCESS: ");
} else {
System.out.print("FAIL: ");
}
System.out.println(length + " bytes written to 0x" + Long.toHexString(address).toUpperCase());
System.exit(0);
}
/**
* Erase is complete
*/
public void eraseDone(int sector, boolean success) {
if(success) {
System.out.print("SUCCESS: ");
} else {
System.out.print("FAIL: ");
}
System.out.println("Sector " + sector + " erase complete");
System.exit(0);
}
/**
* Flush is complete
*/
public void flushDone(boolean success) {
if(success) {
System.out.print("SUCCESS: ");
} else {
System.out.print("FAIL: ");
}
System.out.println("Flush complete");
System.exit(0);
}
/**
* Ping is complete
*/
public void pong() {
System.out.println("Pong! The mote has FlashViewer installed.");
System.exit(0);
}
public void crcDone(int crc, boolean success) {
if(success) {
System.out.print("SUCCESS: ");
} else {
System.out.print("FAIL: ");
}
System.out.println("CRC is 0x" + Integer.toHexString(crc).toUpperCase());
System.exit(0);
}
}
--- NEW FILE: DataOutput.class ---
Êþº¾
numberNext
STORAGE_OK
SourceFile
--- NEW FILE: FlashViewer.class ---
Êþº¾
getMessage
longString
returnData
COMMANDS
-flush
SourceFile
*+2¶
+2N§
²
4V²
5¸
¾¢
¾¶
--- NEW FILE: FlashRunnerInterface.java ---
package com.rincon.flashbridgeviewer;
/*
* 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 FlashRunnerInterface {
/**
* Read a block of data from flash
* @param address
* @param range
*/
public void read(long address, long range, int moteID);
/**
* Write some bytes to flash
* @param address
* @param buffer
* @param length
*/
public void write(long address, short[] buffer, int length, int moteID);
/**
* Erase the currently mounted sector in flash
*
*/
public void erase(int sector, int moteID);
/**
* Get the crc
* @param id
*/
public void crc(long addr, int len, int moteID);
/**
* Commit changes to flash
*
*/
public void flush(int moteID);
/**
* Ping the FlashViewer on a mote
* @param moteID
*/
public void ping(int moteID);
}
- Previous message: [Tinyos-contrib-commits]
CVS: tinyos-1.x/contrib/rincon/tools/java/com/rincon/testharness/messages
TestMsg.java, NONE, 1.1 TestMsg.class, NONE, 1.1
- Next message: [Tinyos-contrib-commits]
CVS: tinyos-1.x/contrib/rincon/tools/java/com/rincon/jdebug/receiver
JDebugReceiver.class, NONE, 1.1 JDebugEvents.java, NONE,
1.1 JDebugEvents.class, NONE, 1.1 JDebugReceiver.java, NONE, 1.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Tinyos-contrib-commits
mailing list