- logger added

- procedures for comparing write/read data

git-svn-id: https://svn.code.sf.net/p/libusbjava/code/trunk@67 94ad28fe-ef68-46b1-9651-e7ae4fcf1c4c
This commit is contained in:
schlaepfer
2006-01-09 08:51:54 +00:00
parent 0aeb7fc8f6
commit 892a9a39f1
2 changed files with 276 additions and 83 deletions

View File

@@ -43,6 +43,16 @@ public class BDI332App {
private Button button14 = null; private Button button14 = null;
private Button button20 = null;
private Button button16 = null;
private Button button17 = null;
private Button button18 = null;
private Button button19 = null;
/** /**
* This method initializes sShell * This method initializes sShell
*/ */
@@ -50,7 +60,7 @@ public class BDI332App {
sShell = new Shell(); sShell = new Shell();
sShell.setText("Shell"); sShell.setText("Shell");
sShell.setLayout(new RowLayout()); sShell.setLayout(new RowLayout());
sShell.setSize(new org.eclipse.swt.graphics.Point(312,110)); sShell.setSize(new org.eclipse.swt.graphics.Point(320, 134));
button1 = new Button(sShell, SWT.NONE); button1 = new Button(sShell, SWT.NONE);
button1.setText("testBdiTransaction"); button1.setText("testBdiTransaction");
button1 button1
@@ -115,39 +125,94 @@ public class BDI332App {
button10.setText("fillMem"); button10.setText("fillMem");
button11 = new Button(sShell, SWT.NONE); button11 = new Button(sShell, SWT.NONE);
button11.setText("initTarget"); button11.setText("initTarget");
button11.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() { button11
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) { .addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
BDI332test.button11(); public void widgetSelected(
} org.eclipse.swt.events.SelectionEvent e) {
}); BDI332test.button11();
}
});
button12 = new Button(sShell, SWT.NONE); button12 = new Button(sShell, SWT.NONE);
button12.setText("-------"); button12.setText("replaceA");
button12.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() { button12
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) { .addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
BDI332test.button12(); public void widgetSelected(
} org.eclipse.swt.events.SelectionEvent e) {
}); BDI332test.button12();
}
});
button13 = new Button(sShell, SWT.NONE); button13 = new Button(sShell, SWT.NONE);
button13.setText("-------"); button13.setText("compare1");
button13.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() { button13
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) { .addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
BDI332test.button13(); public void widgetSelected(
} org.eclipse.swt.events.SelectionEvent e) {
}); BDI332test.button13();
}
});
button14 = new Button(sShell, SWT.NONE); button14 = new Button(sShell, SWT.NONE);
button14.setText("-------"); button14.setText("compare2");
button14.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() { button14
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) { .addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
BDI332test.button14(); public void widgetSelected(
} org.eclipse.swt.events.SelectionEvent e) {
}); BDI332test.button14();
}
});
button15 = new Button(sShell, SWT.NONE); button15 = new Button(sShell, SWT.NONE);
button15.setText("resetUSB"); button15.setText("resetUSB");
button15.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() { button16 = new Button(sShell, SWT.NONE);
public void widgetSelected(org.eclipse.swt.events.SelectionEvent e) { button16.setText("replaceE");
BDI332test.button15(); button16
} .addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
}); public void widgetSelected(
org.eclipse.swt.events.SelectionEvent e) {
BDI332test.button16();
}
});
button17 = new Button(sShell, SWT.NONE);
button17.setText("-");
button17
.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
public void widgetSelected(
org.eclipse.swt.events.SelectionEvent e) {
BDI332test.button17();
}
});
button18 = new Button(sShell, SWT.NONE);
button18.setText("-");
button18
.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
public void widgetSelected(
org.eclipse.swt.events.SelectionEvent e) {
BDI332test.button18();
}
});
button19 = new Button(sShell, SWT.NONE);
button19.setText("-");
button19
.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
public void widgetSelected(
org.eclipse.swt.events.SelectionEvent e) {
BDI332test.button19();
}
});
button20 = new Button(sShell, SWT.NONE);
button20.setText("-");
button20
.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
public void widgetSelected(
org.eclipse.swt.events.SelectionEvent e) {
BDI332test.button20();
}
});
button15
.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
public void widgetSelected(
org.eclipse.swt.events.SelectionEvent e) {
BDI332test.button15();
}
});
button10 button10
.addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() { .addSelectionListener(new org.eclipse.swt.events.SelectionAdapter() {
public void widgetSelected( public void widgetSelected(

View File

@@ -6,10 +6,14 @@ import ch.ntb.mcdp.mc68332.IMCBTargetBoard;
import ch.ntb.mcdp.usb.DataPacket; import ch.ntb.mcdp.usb.DataPacket;
import ch.ntb.mcdp.usb.DispatchException; import ch.ntb.mcdp.usb.DispatchException;
import ch.ntb.mcdp.usb.USBDevice; import ch.ntb.mcdp.usb.USBDevice;
import ch.ntb.mcdp.utils.logger.LogUtil;
import ch.ntb.mcdp.utils.logger.McdpLogger;
import ch.ntb.usb.USBException; import ch.ntb.usb.USBException;
public class BDI332test { public class BDI332test {
private static McdpLogger logger = LogUtil.ch_ntb_mcdp_bdi_test;
private static void testBdiTransaction() { private static void testBdiTransaction() {
// test bdi transaction // test bdi transaction
DataPacket result = null; DataPacket result = null;
@@ -26,7 +30,7 @@ public class BDI332test {
e.printStackTrace(); e.printStackTrace();
} }
if (result != null) { if (result != null) {
result.toString(); logger.info(result.toString());
} }
} }
@@ -47,8 +51,7 @@ public class BDI332test {
private static void freeze() { private static void freeze() {
try { try {
System.out logger.info("isFreezeAsserted: " + MC68332.isFreezeAsserted());
.println("isFreezeAsserted: " + MC68332.isFreezeAsserted());
} catch (USBException e) { } catch (USBException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
@@ -121,7 +124,7 @@ public class BDI332test {
sb.append("0x" sb.append("0x"
+ Integer.toHexString(MC68332.readMem(BASE_ADDR + 8, 4)) + Integer.toHexString(MC68332.readMem(BASE_ADDR + 8, 4))
+ "\n"); + "\n");
System.out.println(sb.toString()); logger.info(sb.toString());
} catch (USBException e) { } catch (USBException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
@@ -178,37 +181,37 @@ public class BDI332test {
// } // }
public static void button1() { public static void button1() {
System.out.println("testBdiTransaction()"); logger.info("testBdiTransaction()");
testBdiTransaction(); testBdiTransaction();
} }
public static void button2() { public static void button2() {
System.out.println("reset_target()"); logger.info("reset_target()");
reset_target(); reset_target();
} }
public static void button3() { public static void button3() {
System.out.println("go()"); logger.info("go()");
go(); go();
} }
public static void button4() { public static void button4() {
System.out.println("break_()"); logger.info("break_()");
break_(); break_();
} }
public static void button5() { public static void button5() {
System.out.println("freeze()"); logger.info("freeze()");
freeze(); freeze();
} }
public static void button6() { public static void button6() {
System.out.println("writeMem()"); logger.info("writeMem()");
writeMem(); writeMem();
} }
public static void button7() { public static void button7() {
System.out.println("readMem()"); logger.info("readMem()");
readMem(); readMem();
} }
@@ -217,15 +220,16 @@ public class BDI332test {
final int BASE_ADDR = 0x105624; final int BASE_ADDR = 0x105624;
int[] result; int[] result;
System.out.println("dump()"); logger.info("dump()");
try { try {
System.out.println("Data: 0x" logger.info("Data: 0x"
+ Integer.toHexString(MC68332.readMem(BASE_ADDR, 4)) + " "); + Integer.toHexString(MC68332.readMem(BASE_ADDR, 4)) + " ");
result = MC68332.dumpMem(MC68332.MAX_NOF_LONGS_FILL); result = MC68332.dumpMem(MC68332.MAX_NOF_LONGS_FILL);
StringBuffer sb = new StringBuffer();
for (int i = 0; i < result.length; i++) { for (int i = 0; i < result.length; i++) {
System.out.print("0x" + Integer.toHexString(result[i]) + " "); sb.append("0x" + Integer.toHexString(result[i]) + " ");
} }
System.out.println(); logger.info(sb.toString());
} catch (USBException e) { } catch (USBException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
@@ -258,7 +262,7 @@ public class BDI332test {
final int BASE_ADDR = 0x105624; final int BASE_ADDR = 0x105624;
System.out.println("fill"); logger.info("fill");
try { try {
MC68332.writeMem(BASE_ADDR, 0, 4); MC68332.writeMem(BASE_ADDR, 0, 4);
int[] data = new int[MC68332.MAX_NOF_LONGS_FILL]; int[] data = new int[MC68332.MAX_NOF_LONGS_FILL];
@@ -279,7 +283,7 @@ public class BDI332test {
} }
public static void button11() { public static void button11() {
System.out.println("initTarget()"); logger.info("initTarget()");
try { try {
IMCBTargetBoard.init(); IMCBTargetBoard.init();
} catch (USBException e) { } catch (USBException e) {
@@ -295,17 +299,54 @@ public class BDI332test {
} }
public static void button12() { public static void button12() {
System.out.println("readMem()");
readMem(); final int BASE_ADDR = 0x105624;
final int DATA = 0x00ff00ff;
final int OFFSET = 0x06 * 4;
final int LENGTH = 0x04;
try {
logger.info("Fill (1 to data.length)");
MC68332.writeMem(BASE_ADDR, 0, 4);
int[] data = new int[MC68332.MAX_NOF_LONGS_FILL];
for (int i = 0; i < data.length; i++) {
data[i] = i + 1;
}
MC68332.fillMem(data, data.length);
logger.info("writing byte " + (OFFSET / 4) + " to "
+ ((OFFSET / 4) + LENGTH) + " with 0x"
+ Integer.toHexString(DATA));
MC68332.writeMem(BASE_ADDR + OFFSET, DATA, 4);
for (int i = 0; i < LENGTH; i++) {
data[i] = DATA;
}
MC68332.fillMem(data, LENGTH);
logger.info((LENGTH + 1) + " bytes written");
logger.info("dump data");
int firstInt = MC68332.readMem(BASE_ADDR, 4);
int[] result = MC68332.dumpMem(MC68332.MAX_NOF_LONGS_FILL);
StringBuffer sb = new StringBuffer();
for (int i = 0; i < result.length; i++) {
sb.append("0x" + Integer.toHexString(result[i]) + " ");
}
logger.info("Data: 0x" + Integer.toHexString(firstInt) + " "
+ sb.toString());
logger.info("Done");
} catch (BDIException e) {
e.printStackTrace();
} catch (USBException e) {
e.printStackTrace();
} catch (DispatchException e) {
e.printStackTrace();
}
} }
public static void button13() { public static void button13() {
final int BASE_ADDR = 0x105624; final int BASE_ADDR = 0x105624;
final int FIRST_VAL = 0xFF; final int FIRST_VAL = 0xFF;
final boolean DEBUG_ON = true;
try { try {
System.out.println("initialize data"); logger.info("initialize data");
MC68332.writeMem(BASE_ADDR, FIRST_VAL, 4); MC68332.writeMem(BASE_ADDR, FIRST_VAL, 4);
int[] data = new int[MC68332.MAX_NOF_LONGS_FILL]; int[] data = new int[MC68332.MAX_NOF_LONGS_FILL];
for (int i = 0; i < data.length; i++) { for (int i = 0; i < data.length; i++) {
@@ -313,35 +354,29 @@ public class BDI332test {
} }
MC68332.fillMem(data, data.length); MC68332.fillMem(data, data.length);
System.out.println("write data"); logger.info("write data");
MC68332.writeMem(BASE_ADDR, FIRST_VAL, 4); MC68332.writeMem(BASE_ADDR, FIRST_VAL, 4);
data = new int[10]; data = new int[10];
for (int i = 0; i < data.length; i++) { for (int i = 0; i < data.length; i++) {
data[i] = i; data[i] = i;
} }
MC68332.fillMem(data, data.length); MC68332.fillMem(data, data.length);
System.out.println("Fill done"); logger.info("Fill done");
System.out.println("read back data"); logger.info("read back data");
int firstResult = MC68332.readMem(BASE_ADDR, 4); int firstResult = MC68332.readMem(BASE_ADDR, 4);
if (firstResult != FIRST_VAL) { if (firstResult != FIRST_VAL) {
System.out.println("Error at 0: 0x" logger.warning("Error at 0: 0x"
+ Integer.toHexString(firstResult) + " instead of 0x" + Integer.toHexString(firstResult) + " instead of 0x"
+ Integer.toHexString(FIRST_VAL)); + Integer.toHexString(FIRST_VAL));
} }
if (DEBUG_ON) { logger.fine("Compare first 0x" + Integer.toHexString(firstResult)
System.out.println("Compare first 0x" + " == 0x" + Integer.toHexString(FIRST_VAL));
+ Integer.toHexString(firstResult) + " == 0x"
+ Integer.toHexString(FIRST_VAL));
}
int[] result = MC68332.dumpMem(MC68332.MAX_NOF_LONGS_FILL); int[] result = MC68332.dumpMem(MC68332.MAX_NOF_LONGS_FILL);
for (int i = 0; i < result.length; i++) { for (int i = 0; i < result.length; i++) {
if (DEBUG_ON) { logger.fine("Compare " + i + ": 0x"
System.out.println("Compare " + i + ": 0x" + Integer.toHexString(result[i]));
+ Integer.toHexString(result[i]));
}
} }
System.out.println("Dump done"); logger.info("Dump done");
} catch (USBException e) { } catch (USBException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
@@ -358,9 +393,8 @@ public class BDI332test {
final int BASE_ADDR = 0x105624; final int BASE_ADDR = 0x105624;
final int FIRST_VAL = 0xFF; final int FIRST_VAL = 0xFF;
final boolean DEBUG_ON = true;
System.out.println("write data"); logger.info("write data");
try { try {
MC68332.writeMem(BASE_ADDR, FIRST_VAL, 4); MC68332.writeMem(BASE_ADDR, FIRST_VAL, 4);
int[] data = new int[MC68332.MAX_NOF_LONGS_FILL]; int[] data = new int[MC68332.MAX_NOF_LONGS_FILL];
@@ -368,34 +402,29 @@ public class BDI332test {
data[i] = i; data[i] = i;
} }
MC68332.fillMem(data, data.length); MC68332.fillMem(data, data.length);
System.out.println("Fill done"); logger.info("Fill done");
System.out.println("read back data"); logger.info("read back data");
int firstResult = MC68332.readMem(BASE_ADDR, 4); int firstResult = MC68332.readMem(BASE_ADDR, 4);
if (firstResult != FIRST_VAL) { if (firstResult != FIRST_VAL) {
System.out.println("Error at 0: 0x" logger.warning("Error at 0: 0x"
+ Integer.toHexString(firstResult) + " instead of 0x" + Integer.toHexString(firstResult) + " instead of 0x"
+ Integer.toHexString(FIRST_VAL)); + Integer.toHexString(FIRST_VAL));
} }
if (DEBUG_ON) { logger.fine("Compare first 0x" + Integer.toHexString(firstResult)
System.out.println("Compare first 0x" + " == 0x" + Integer.toHexString(FIRST_VAL));
+ Integer.toHexString(firstResult) + " == 0x"
+ Integer.toHexString(FIRST_VAL));
}
int[] result = MC68332.dumpMem(MC68332.MAX_NOF_LONGS_FILL); int[] result = MC68332.dumpMem(MC68332.MAX_NOF_LONGS_FILL);
for (int i = 0; i < result.length; i++) { for (int i = 0; i < result.length; i++) {
if (data[i] != result[i]) { if (data[i] != result[i]) {
System.out.println("Error at " + i + ": 0x" logger.warning("Error at " + i + ": 0x"
+ Integer.toHexString(result[i]) + " instead of 0x" + Integer.toHexString(result[i]) + " instead of 0x"
+ Integer.toHexString(data[i])); + Integer.toHexString(data[i]));
} }
if (DEBUG_ON) { logger.fine("Compare " + i + ": 0x"
System.out.println("Compare " + i + ": 0x" + Integer.toHexString(result[i]) + " == 0x"
+ Integer.toHexString(result[i]) + " == 0x" + Integer.toHexString(data[i]));
+ Integer.toHexString(data[i]));
}
} }
System.out.println("Dump done"); logger.info("Dump done");
} catch (USBException e) { } catch (USBException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
@@ -409,7 +438,7 @@ public class BDI332test {
} }
public static void button15() { public static void button15() {
System.out.println("resetUSB()"); logger.info("resetUSB()");
try { try {
USBDevice.reset(); USBDevice.reset();
Thread.sleep(500); Thread.sleep(500);
@@ -423,6 +452,105 @@ public class BDI332test {
} }
} }
public static void button16() {
final int BASE_ADDR = 0x105624;
final int DATA = 0x00ff00ff;
final int OFFSET = (MC68332.MAX_NOF_LONGS_FILL - 2) * 4;
final int LENGTH = 0x04;
final int DUMP_BASE = BASE_ADDR + (MC68332.MAX_NOF_LONGS_FILL / 2) * 4;
try {
logger.info("REPLACE at the end");
logger.info("Fill first");
MC68332.writeMem(BASE_ADDR, 0, 4);
int[] data = new int[MC68332.MAX_NOF_LONGS_FILL];
for (int i = 0; i < data.length; i++) {
data[i] = i + 1;
}
MC68332.fillMem(data, data.length);
logger.info("Fill second");
MC68332.writeMem(BASE_ADDR + (MC68332.MAX_NOF_LONGS_FILL + 1) * 4,
0, 4);
for (int i = 0; i < data.length; i++) {
data[i] = MC68332.MAX_NOF_LONGS_FILL + i + 2;
}
MC68332.fillMem(data, data.length);
logger.info("Dump from base: 0x" + Integer.toHexString(DUMP_BASE));
int firstInt = MC68332.readMem(DUMP_BASE, 4);
int[] result = MC68332.dumpMem(MC68332.MAX_NOF_LONGS_FILL);
StringBuffer sb = new StringBuffer();
for (int i = 0; i < result.length; i++) {
sb.append("0x" + Integer.toHexString(result[i]) + " ");
}
logger.info("Data: 0x" + Integer.toHexString(firstInt) + " "
+ sb.toString());
logger.info("writing byte " + (OFFSET / 4) + " to "
+ ((OFFSET / 4) + LENGTH) + " with 0x"
+ Integer.toHexString(DATA));
MC68332.writeMem(BASE_ADDR + OFFSET, DATA, 4);
for (int i = 0; i < LENGTH; i++) {
data[i] = DATA;
}
MC68332.fillMem(data, LENGTH);
logger.info((LENGTH + 1) + " bytes written");
logger.info("dump data from base: 0x"
+ Integer.toHexString(DUMP_BASE));
firstInt = MC68332.readMem(DUMP_BASE, 4);
result = MC68332.dumpMem(MC68332.MAX_NOF_LONGS_FILL);
sb = new StringBuffer();
for (int i = 0; i < result.length; i++) {
sb.append("0x" + Integer.toHexString(result[i]) + " ");
}
logger.info("Data: 0x" + Integer.toHexString(firstInt) + " "
+ sb.toString());
logger.info("Done");
} catch (BDIException e) {
e.printStackTrace();
} catch (USBException e) {
e.printStackTrace();
} catch (DispatchException e) {
e.printStackTrace();
}
}
public static void button17() {
}
public static void button18() {
}
public static void button19() {
}
public static void button20() {
final int BASE_ADDR = 0x01004E0;
try {
StringBuffer sb = new StringBuffer("0x"
+ Integer.toHexString(MC68332.readMem(BASE_ADDR, 4)) + "\n");
sb.append("0x"
+ Integer.toHexString(MC68332.readMem(BASE_ADDR + 4, 4))
+ "\n");
sb.append("0x"
+ Integer.toHexString(MC68332.readMem(BASE_ADDR + 8, 4))
+ "\n");
logger.info(sb.toString());
} catch (USBException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (DispatchException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (BDIException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
// public static void main(String[] args) { // public static void main(String[] args) {
// boolean testRunning = true; // boolean testRunning = true;
// //