From 3243153a0e1d76d070393994733f5d8fe016ad35 Mon Sep 17 00:00:00 2001 From: schlaepfer Date: Thu, 10 Nov 2005 07:35:55 +0000 Subject: [PATCH] - compare method added - some updates git-svn-id: https://svn.code.sf.net/p/libusbjava/code/trunk@43 94ad28fe-ef68-46b1-9651-e7ae4fcf1c4c --- mcdp/src/ch/ntb/mcdp/bdi/test/BDI332test.java | 112 +++++++++++++++++- mcdp/src/ch/ntb/mcdp/bdi/test/BDI555test.java | 23 ++-- 2 files changed, 121 insertions(+), 14 deletions(-) diff --git a/mcdp/src/ch/ntb/mcdp/bdi/test/BDI332test.java b/mcdp/src/ch/ntb/mcdp/bdi/test/BDI332test.java index ace312a..7a36876 100644 --- a/mcdp/src/ch/ntb/mcdp/bdi/test/BDI332test.java +++ b/mcdp/src/ch/ntb/mcdp/bdi/test/BDI332test.java @@ -300,22 +300,126 @@ public class BDI332test { } public static void button13() { - System.out.println("readMem()"); - readMem(); + final int BASE_ADDR = 0x105624; + final int FIRST_VAL = 0xFF; + final boolean DEBUG_ON = true; + + try { + System.out.println("initialize data"); + BDI332.writeMem(BASE_ADDR, FIRST_VAL, 4); + int[] data = new int[BDI332.MAX_NOF_LONGS_FILL]; + for (int i = 0; i < data.length; i++) { + data[i] = 5; + } + BDI332.fillMem(data, data.length); + + System.out.println("write data"); + BDI332.writeMem(BASE_ADDR, FIRST_VAL, 4); + data = new int[10]; + for (int i = 0; i < data.length; i++) { + data[i] = i; + } + BDI332.fillMem(data, data.length); + System.out.println("Fill done"); + System.out.println("read back data"); + int firstResult = BDI332.readMem(BASE_ADDR, 4); + if (firstResult != FIRST_VAL) { + System.out.println("Error at 0: 0x" + + Integer.toHexString(firstResult) + " instead of 0x" + + Integer.toHexString(FIRST_VAL)); + } + if (DEBUG_ON) { + System.out.println("Compare first 0x" + + Integer.toHexString(firstResult) + " == 0x" + + Integer.toHexString(FIRST_VAL)); + } + int[] result = BDI332.dumpMem(BDI332.MAX_NOF_LONGS_FILL); + for (int i = 0; i < result.length; i++) { + if (DEBUG_ON) { + System.out.println("Compare " + i + ": 0x" + + Integer.toHexString(result[i])); + + } + } + System.out.println("Dump done"); + } 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 button14() { - System.out.println("readMem()"); - readMem(); + + final int BASE_ADDR = 0x105624; + final int FIRST_VAL = 0xFF; + final boolean DEBUG_ON = true; + + System.out.println("write data"); + try { + BDI332.writeMem(BASE_ADDR, FIRST_VAL, 4); + int[] data = new int[BDI332.MAX_NOF_LONGS_FILL]; + for (int i = 0; i < data.length; i++) { + data[i] = i; + } + BDI332.fillMem(data, data.length); + System.out.println("Fill done"); + System.out.println("read back data"); + int firstResult = BDI332.readMem(BASE_ADDR, 4); + if (firstResult != FIRST_VAL) { + System.out.println("Error at 0: 0x" + + Integer.toHexString(firstResult) + " instead of 0x" + + Integer.toHexString(FIRST_VAL)); + } + if (DEBUG_ON) { + System.out.println("Compare first 0x" + + Integer.toHexString(firstResult) + " == 0x" + + Integer.toHexString(FIRST_VAL)); + } + int[] result = BDI332.dumpMem(BDI332.MAX_NOF_LONGS_FILL); + for (int i = 0; i < result.length; i++) { + if (data[i] != result[i]) { + System.out.println("Error at " + i + ": 0x" + + Integer.toHexString(result[i]) + " instead of 0x" + + Integer.toHexString(data[i])); + } + if (DEBUG_ON) { + System.out.println("Compare " + i + ": 0x" + + Integer.toHexString(result[i]) + " == 0x" + + Integer.toHexString(data[i])); + + } + } + System.out.println("Dump done"); + } 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 button15() { System.out.println("resetUSB()"); try { USBDevice.reset(); + Thread.sleep(500); + USBDevice.open(); } catch (USBException e) { // TODO Auto-generated catch block e.printStackTrace(); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); } } diff --git a/mcdp/src/ch/ntb/mcdp/bdi/test/BDI555test.java b/mcdp/src/ch/ntb/mcdp/bdi/test/BDI555test.java index fdc572e..13dd196 100644 --- a/mcdp/src/ch/ntb/mcdp/bdi/test/BDI555test.java +++ b/mcdp/src/ch/ntb/mcdp/bdi/test/BDI555test.java @@ -98,8 +98,9 @@ public class BDI555test { } private static void writeMem() { + final int BASE_ADDR = 0x800000; try { - BDI555.writeMem(0x800000, 0x123456, 4); + BDI555.writeMem(BASE_ADDR, 0x123456, 4); } catch (USBException e) { // TODO Auto-generated catch block e.printStackTrace(); @@ -113,13 +114,14 @@ public class BDI555test { } private static void readMem() { + final int BASE_ADDR = 0x800000; try { - StringBuffer sb = new StringBuffer("0x" - + Integer.toHexString(BDI555.readMem(0x800000, 4)) + "\n"); - sb.append("0x" + Integer.toHexString(BDI555.readMem(0x800004, 4)) - + "\n"); - sb.append("0x" + Integer.toHexString(BDI555.readMem(0x800008, 4)) - + "\n"); + StringBuffer sb = new StringBuffer(); + for (int i = 0; i < 10; i++) { + sb.append("0x" + + Integer.toHexString(BDI555.readMem(BASE_ADDR + i*4, 4)) + + "\n"); + } System.out.println(sb.toString()); } catch (USBException e) { // TODO Auto-generated catch block @@ -134,12 +136,13 @@ public class BDI555test { } private static void fastDownload() { + final int BASE_ADDR = 0x800000; int[] testData = new int[120]; for (int i = 0; i < testData.length; i++) { testData[i] = i; } try { - BDI555.startFastDownload(0x800000); + BDI555.startFastDownload(BASE_ADDR); BDI555.fastDownload(testData, BDI555.MAX_NOF_WORDS_FAST_DOWNLOAD); BDI555.stopFastDownload(); } catch (USBException e) { @@ -155,10 +158,10 @@ public class BDI555test { } private static void readMemSeq() { - int startAddr = 0x800000; + final int BASE_ADDR = 0x800000; try { StringBuffer sb = new StringBuffer(0 + "\tData: 0x" - + Integer.toHexString(BDI555.readMem(startAddr, 4)) + "\n"); + + Integer.toHexString(BDI555.readMem(BASE_ADDR, 4)) + "\n"); for (int i = 1; i < 120; i++) { sb.append(i + "\tData: 0x" + Integer.toHexString(BDI555.readMemSeq(4)) + "\n");