diff --git a/src/org/openlcb/can/NIDaAlgorithm.java b/src/org/openlcb/can/NIDaAlgorithm.java index bd3051de..ffedfe14 100644 --- a/src/org/openlcb/can/NIDaAlgorithm.java +++ b/src/org/openlcb/can/NIDaAlgorithm.java @@ -12,7 +12,7 @@ * to and from the actual interface. * It also requires subclassing to provide a timer function. * - * @author Bob Jacobsen Copyright 2009, 2010 + * @author Bob Jacobsen Copyright 2009, 2010, 2023 */ public class NIDaAlgorithm implements CanFrameListener { /// Callback to invoke when the alias was successfully reserved. @@ -70,6 +70,9 @@ public OpenLcbCanFrame nextFrame() { } else if (index == 4) { f = new OpenLcbCanFrame(nida.getNIDa()); f.setRIM(nida.getNIDa()); + } else if (index == 5) { + f = new OpenLcbCanFrame(nida.getNIDa()); + f.setAMD(nida.getNIDa(), nid); complete = true; } else { // send nothing @@ -148,6 +151,7 @@ protected void timerExpired() { } scheduleTimer(200); } else if (index == 4) { + sendInterface.send(nextFrame()); sendInterface.send(nextFrame()); if (done != null) { done.run(); diff --git a/test/org/openlcb/can/NIDaAlgorithmTest.java b/test/org/openlcb/can/NIDaAlgorithmTest.java index 1e411fb4..fcee4fc2 100644 --- a/test/org/openlcb/can/NIDaAlgorithmTest.java +++ b/test/org/openlcb/can/NIDaAlgorithmTest.java @@ -52,16 +52,18 @@ public void testFirst() { } @Test - public void testFifth() { + public void testSixth() { Assert.assertTrue("not complete", !alg.isComplete()); - // seventh frame is RIM + // fifth frame is RIM Assert.assertTrue(alg.nextFrame().isCIM()); Assert.assertTrue(alg.nextFrame().isCIM()); Assert.assertTrue(alg.nextFrame().isCIM()); Assert.assertTrue(alg.nextFrame().isCIM()); Assert.assertTrue(alg.nextFrame().isRIM()); + Assert.assertNotEquals(alg.nextFrame(), null); // AMD frame + Assert.assertTrue("complete", alg.isComplete()); Assert.assertEquals(alg.nextFrame(), null); @@ -94,6 +96,9 @@ public void testNotAConflict() { alg.processFrame(t); Assert.assertTrue(alg.nextFrame().isRIM()); + // sixth is AMD + Assert.assertNotEquals((alg.nextFrame()), null); + Assert.assertTrue("complete", alg.isComplete()); Assert.assertEquals(alg.nextFrame(), null); @@ -130,6 +135,9 @@ public void testConflictAfterOne() { f = alg.nextFrame(); Assert.assertTrue(f.isRIM()); + // sixth is AMD + Assert.assertNotEquals((f = alg.nextFrame()), null); + Assert.assertTrue("complete", alg.isComplete()); Assert.assertEquals((f = alg.nextFrame()), null); @@ -157,6 +165,9 @@ public void testLatecomerConflict() { f = alg.nextFrame(); Assert.assertTrue(f.isRIM()); + // sixth is AMD + Assert.assertNotEquals((f = alg.nextFrame()), null); + int nida = f.getSourceAlias(); Assert.assertTrue("complete", alg.isComplete()); @@ -188,7 +199,7 @@ public void testSequentialStart2() { alg1.nextFrame(); alg1.nextFrame(); - int expectedCount = 5; + int expectedCount = 6; int count = sequentialRunner(new NIDaAlgorithm[]{alg1, alg2}, expectedCount); debug("tSS2 converges " + count);