|
Message
From: cvs at opencores.org<cvs@o...>
Date: Sun Aug 19 22:29:18 CEST 2007
Subject: [cvs-checkins] MODIFIED: jop ...
Date: 00/07/08 19:22:29 Modified: jop/java/target/src/common/yaffs2/utils/debug/communication DirectInterfaceClientStub.java Transceiver.java Log: Revision Changes Path 1.2 jop/java/target/src/common/yaffs2/utils/debug/communication/DirectInterfaceClientStub.java http://www.opencores.org/cvsweb.shtml/jop/java/target/src/common/yaffs2/utils/debug/communication/DirectInterfaceClientStub.java.diff?r1=1.1&r2=1.2 (In the diff below, changes in quantity of whitespace are not shown.) Index: DirectInterfaceClientStub.java =================================================================== RCS file: /cvsroot/peter.hilber/jop/java/target/src/common/yaffs2/utils/debug/communication/DirectInterfaceClientStub.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -b -r1.1 -r1.2 --- DirectInterfaceClientStub.java 1 Jul 2007 01:29:52 -0000 1.1 +++ DirectInterfaceClientStub.java 19 Aug 2007 20:29:18 -0000 1.2 @@ -14,6 +14,7 @@ public DirectInterfaceClientStub(yaffs_Device dev, InputStream rx, OutputStream tx) { super(rx, tx); + this.dev = dev; } public yaffs_Device deviceIdToDevice(int deviceId) 1.2 jop/java/target/src/common/yaffs2/utils/debug/communication/Transceiver.java http://www.opencores.org/cvsweb.shtml/jop/java/target/src/common/yaffs2/utils/debug/communication/Transceiver.java.diff?r1=1.1&r2=1.2 (In the diff below, changes in quantity of whitespace are not shown.) Index: Transceiver.java =================================================================== RCS file: /cvsroot/peter.hilber/jop/java/target/src/common/yaffs2/utils/debug/communication/Transceiver.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -b -r1.1 -r1.2 --- Transceiver.java 1 Jul 2007 01:29:52 -0000 1.1 +++ Transceiver.java 19 Aug 2007 20:29:18 -0000 1.2 @@ -11,6 +11,8 @@ public abstract class Transceiver { + static final Object sync = new Object(); // FIXME + static final int CMD_READCHUNKFROMNAND = 1; static final int CMD_WRITECHUNKTONAND = 2; static final int CMD_ERASEBLOCKINNAND = 3; @@ -24,7 +26,8 @@ protected InputStream rx; protected OutputStream tx; - protected int sequenceNumber = -1; + protected int rxSequenceNumber = -1; + protected int txSequenceNumber = -1; public Transceiver(InputStream rx, OutputStream tx) { @@ -39,16 +42,34 @@ { tx.write(START_DELIMITER); - tx.write(DebugUtils.intToByteArray(sequenceNumber++)); + tx.write(DebugUtils.intToByteArray(++txSequenceNumber)); tx.write(DebugUtils.intToByteArray(command)); tx.write(DebugUtils.intToByteArray(dev.subField1.genericDevice)); tx.write(DebugUtils.intToByteArray(chunkInNAND)); tx.write(DebugUtils.intToByteArray(blockInNAND)); + tx.write(DebugUtils.intToByteArray(data != null ? 1 : 0)); + if (data != null) tx.write(data, dataIndex, dev.subField1.nDataBytesPerChunk); + tx.write(DebugUtils.intToByteArray(spare != null ? 1 : 0)); + if (spare != null) tx.write(spare.serialized, spare.offset, spare.SERIALIZED_LENGTH); tx.write(END_DELIMITER); + + tx.flush(); + + try + { + synchronized(sync) + { + sync.wait(); + } + } + catch (Exception e) + { + throw new UnexpectedException(); + } } catch (IOException e) {
@@ -67,7 +88,7 @@
{
int ch;
- while (loop)
+ do
{
while ((ch = rx.read()) != -1 && ch != START_DELIMITER[0])
{
@@ -78,18 +99,23 @@
break;
{
- int lastSequenceNumber = sequenceNumber;
- sequenceNumber = DebugUtils.readIntFromInputStream(rx);
+ int lastSequenceNumber = rxSequenceNumber;
+ rxSequenceNumber = DebugUtils.readIntFromInputStream(rx);
- if (!(lastSequenceNumber == -1) && lastSequenceNumber +1 != sequenceNumber)
+ if (!(lastSequenceNumber == -1) && lastSequenceNumber +1 != rxSequenceNumber)
throw new UnexpectedException("Sequence number mismatch!");
int command = DebugUtils.readIntFromInputStream(rx);
yaffs_Device dev = deviceIdToDevice(DebugUtils.readIntFromInputStream(rx));
int chunkInNAND = DebugUtils.readIntFromInputStream(rx);
int blockInNAND = DebugUtils.readIntFromInputStream(rx);
+
+ boolean dataPresent = DebugUtils.readIntFromInputStream(rx) != 0;
+ if (dataPresent)
rx.read(data, dataIndex, dev.subField1.nDataBytesPerChunk);
+ boolean sparePresent = DebugUtils.readIntFromInputStream(rx) != 0;
+ if (sparePresent)
rx.read(spare.serialized, spare.offset, spare.SERIALIZED_LENGTH);
int endDelim = rx.read();
@@ -97,10 +123,15 @@
if (endDelim != END_DELIMITER[0])
throw new UnexpectedException("Failed to receive message!");
- processInput(command, (dev), chunkInNAND, blockInNAND,
- data, dataIndex, spare);
+ synchronized (sync)
+ {
+ sync.notify();
}
+
+ processInput(command, (dev), chunkInNAND, blockInNAND,
+ dataPresent ? data : null, dataIndex, sparePresent ? spare : null);
}
+ } while (loop);
}
catch (IOException e)
{
|
 |