diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/RileyLinkUtil.java b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/RileyLinkUtil.java index 01bc5c4271..7d80b7d907 100644 --- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/RileyLinkUtil.java +++ b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/RileyLinkUtil.java @@ -23,6 +23,7 @@ import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.data.RLHistor import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.data.ServiceResult; import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.data.ServiceTransport; import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.service.tasks.ServiceTask; +import info.nightscout.shared.logging.AAPSLogger; /** * Created by andy on 17/05/2018. @@ -37,6 +38,8 @@ public class RileyLinkUtil { private RileyLinkEncodingType encoding; private Encoding4b6b encoding4b6b; + @Inject AAPSLogger aapsLogger; + @Inject public RileyLinkUtil() { } @@ -50,7 +53,7 @@ public class RileyLinkUtil { this.encoding = encoding; if (encoding == RileyLinkEncodingType.FourByteSixByteLocal) { - this.encoding4b6b = new Encoding4b6bGeoff(); + this.encoding4b6b = new Encoding4b6bGeoff(aapsLogger); } } diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/data/encoding/Encoding4b6bAbstract.java b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/data/encoding/Encoding4b6bAbstract.java index 36a4b4cd71..d45e9c456c 100644 --- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/data/encoding/Encoding4b6bAbstract.java +++ b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/data/encoding/Encoding4b6bAbstract.java @@ -1,9 +1,8 @@ package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.data.encoding; -import org.slf4j.Logger; - import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.RileyLinkCommunicationException; import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil; +import info.nightscout.shared.logging.AAPSLogger; /** @@ -51,9 +50,10 @@ public abstract class Encoding4b6bAbstract implements Encoding4b6b { } - public void writeError(Logger LOG, byte[] raw, String errorData) { + public void writeError(AAPSLogger aapsLogger, byte[] raw, String errorData) { - LOG.error(String.format("\n=============================================================================\n" + // + aapsLogger.error(String.format("\n" + + "=============================================================================\n" + // " Decoded payload length is zero.\n" + " encodedPayload: %s\n" + " errors: %s\n" + @@ -62,8 +62,6 @@ public abstract class Encoding4b6bAbstract implements Encoding4b6b { //FabricUtil.createEvent("MedtronicDecode4b6bError", null); - return; - } } diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/data/encoding/Encoding4b6bGeoff.java b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/data/encoding/Encoding4b6bGeoff.java index 930e98de85..3c4dffe31c 100644 --- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/data/encoding/Encoding4b6bGeoff.java +++ b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/data/encoding/Encoding4b6bGeoff.java @@ -1,15 +1,13 @@ package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.data.encoding; -import org.slf4j.Logger; - import java.util.ArrayList; import java.util.List; import java.util.Locale; -import info.nightscout.shared.logging.StacktraceLoggerWrapper; import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.RileyLinkCommunicationException; import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.defs.RileyLinkBLEError; import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil; +import info.nightscout.shared.logging.AAPSLogger; /** * Created by andy on 11/24/18. @@ -17,8 +15,11 @@ import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil; public class Encoding4b6bGeoff extends Encoding4b6bAbstract { - public static final Logger LOG = StacktraceLoggerWrapper.getLogger(Encoding4b6bGeoff.class); + private final AAPSLogger aapsLogger; + public Encoding4b6bGeoff(AAPSLogger aapsLogger) { + this.aapsLogger = aapsLogger; + } @Override public byte[] encode4b6b(byte[] data) { // if ((data.length % 2) != 0) { @@ -150,7 +151,7 @@ public class Encoding4b6bGeoff extends Encoding4b6bAbstract { if (codingErrors > 0) { // LOG.error("decode4b6b: " + codingErrors + " coding errors encountered."); errorMessageBuilder.append("decode4b6b: " + codingErrors + " coding errors encountered."); - writeError(LOG, raw, errorMessageBuilder.toString()); + writeError(aapsLogger, raw, errorMessageBuilder.toString()); throw new RileyLinkCommunicationException(RileyLinkBLEError.CodingErrors, errorMessageBuilder.toString()); } return rval; diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/data/encoding/Encoding4b6bGo.java b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/data/encoding/Encoding4b6bGo.java deleted file mode 100644 index a81959b180..0000000000 --- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/data/encoding/Encoding4b6bGo.java +++ /dev/null @@ -1,163 +0,0 @@ -package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.data.encoding; - -import org.slf4j.Logger; - -import java.util.HashMap; -import java.util.Map; - -import info.nightscout.shared.logging.StacktraceLoggerWrapper; -import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.RileyLinkCommunicationException; -import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.defs.RileyLinkBLEError; -import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil; - -/** - * Created by andy on 11/24/18. - */ - -public class Encoding4b6bGo extends Encoding4b6bAbstract { - - public static final Logger LOG = StacktraceLoggerWrapper.getLogger(Encoding4b6bGo.class); - private static Map decodeGoMap; - - - @Override public byte[] encode4b6b(byte[] src) { - // 2 input bytes produce 3 output bytes. - // Odd final input byte, if any, produces 2 output bytes. - int n = src.length; - byte[] dst = new byte[3 * (n / 2) + 2 * (n % 2)]; - int j = 0; - - for (int i = 0; i < n; i += 2, j = j + 3) { - short x = convertUnsigned(src[i]); - short a = encode4b6bList[hi(4, x)]; - short b = encode4b6bList[lo(4, x)]; - dst[j] = (byte)(a << 2 | hi(4, b)); - if (i + 1 < n) { - short y = convertUnsigned(src[i + 1]); - short c = encode4b6bList[hi(4, y)]; - short d = encode4b6bList[lo(4, y)]; - dst[j + 1] = (byte)(lo(4, b) << 4 | hi(6, c)); - dst[j + 2] = (byte)(lo(2, c) << 6 | d); - } else { - // Fill final nibble with 5 to match pump behavior. - dst[j + 1] = (byte)(lo(4, b) << 4 | 0x5); - } - - } - return dst; - } - - - /** - * Decode from Go code by ecc1. NOT WORKING - * - * @param src - * @return - */ - @Override public byte[] decode4b6b(byte[] src) throws RileyLinkCommunicationException { - int n = src.length; - - if (decodeGoMap == null) - initDecodeGo(); - - StringBuilder errorMessageBuilder = new StringBuilder(); - - errorMessageBuilder.append("Input data: " + ByteUtil.getHex(src) + "\n"); - int codingErrors = 0; - - // Check for valid packet length. - if (n % 3 == 1) { - errorMessageBuilder.append("Invalid package length " + n); - codingErrors++; - // return nil, ErrDecoding - } - // 3 input bytes produce 2 output bytes. - // Final 2 input bytes, if any, produce 1 output byte. - byte[] dst = new byte[2 * (n / 3) + (n % 3) / 2]; - - int j = 0; - for (int i = 0; i < n; i = i + 3, j = j + 2) { - if (i + 1 >= n) { - errorMessageBuilder.append("Overflow in i (" + i + ")"); - } - short x = convertUnsigned(src[i]); - short y = convertUnsigned(src[i + 1]); - short a = decode6b_goMap(hi(6, x)); - short b = decode6b_goMap(lo(2, x) << 4 | hi(4, y)); - if (a == 0xFF || b == 0xFF) { - errorMessageBuilder.append("Error decoding "); - codingErrors++; - } - dst[j] = (byte)(a << 4 | b); - if (i + 2 < n) { - short z = convertUnsigned(src[i + 2]); - short c = decode6b_goMap(lo(4, y) << 2 | hi(2, z)); - short d = decode6b_goMap(lo(6, z)); - if (c == 0xFF || d == 0xFF) { - errorMessageBuilder.append("Error decoding "); - codingErrors++; - } - dst[j + 1] = (byte)(c << 4 | d); - } - } - - if (codingErrors > 0) { - errorMessageBuilder.append("decode4b6b: " + codingErrors + " coding errors encountered."); - writeError(LOG, dst, errorMessageBuilder.toString()); - throw new RileyLinkCommunicationException(RileyLinkBLEError.CodingErrors, errorMessageBuilder.toString()); - } - - return dst; - } - - - static short hi(int n, short x) { - // x = convertUnsigned(x); - return (short)(x >> (8 - n)); - } - - - static short lo(int n, short x) { - // byte b = (byte)x; - return (short)(x & ((1 << n) - 1)); - } - - - public static void initDecodeGo() { - - decodeGoMap = new HashMap<>(); - - putToMap(0x0B, 0x0B); - putToMap(0x0D, 0x0D); - putToMap(0x0E, 0x0E); - putToMap(0x15, 0x00); - putToMap(0x16, 0x07); - putToMap(0x19, 0x09); - putToMap(0x1A, 0x08); - putToMap(0x1C, 0x0F); - putToMap(0x23, 0x03); - putToMap(0x25, 0x05); - putToMap(0x26, 0x06); - putToMap(0x2A, 0x0A); - putToMap(0x2C, 0x0C); - putToMap(0x31, 0x01); - putToMap(0x32, 0x02); - putToMap(0x34, 0x04); - - } - - - private static short decode6b_goMap(int value) { - short val = (short)value; - if (decodeGoMap.containsKey(val)) - return decodeGoMap.get(val); - else - return (short)0xff; - } - - - private static void putToMap(int val1, int val2) { - decodeGoMap.put((short)val1, (short)val2); - } - -} diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/data/encoding/Encoding4b6bLoop.java b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/data/encoding/Encoding4b6bLoop.java deleted file mode 100644 index 8d065a3d58..0000000000 --- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/data/encoding/Encoding4b6bLoop.java +++ /dev/null @@ -1,135 +0,0 @@ -package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.data.encoding; - -import org.slf4j.Logger; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import info.nightscout.shared.logging.StacktraceLoggerWrapper; -import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.RileyLinkCommunicationException; -import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil; - -/** - * Created by andy on 11/24/18. - */ - -public class Encoding4b6bLoop extends Encoding4b6bAbstract { - private static final Logger log = StacktraceLoggerWrapper.getLogger(Encoding4b6bLoop.class); - - public Map codesRev = null; - - - public Encoding4b6bLoop() { - createCodeRev(); - } - - - /** - * This method is almost 1:1 with same method from Loop, only change is unsigning of element and |05 added for - * last byte. It should work better than original one, which is really different than this one. - * - * @param data - * @return - */ - @Override public byte[] encode4b6b(byte[] data) { - - List buffer = new ArrayList(); - int bitAccumulator = 0x0; - int bitcount = 0; - - for (byte element : data) { - - short element2 = element; - - if (element2 < 0) { - element2 += 256; - } - - bitAccumulator <<= 6; - bitAccumulator |= encode4b6bList[element2 >> 4]; - bitcount += 6; - - bitAccumulator <<= 6; - bitAccumulator |= encode4b6bList[element2 & 0x0f]; - bitcount += 6; - - while (bitcount >= 8) { - buffer.add((byte)((bitAccumulator >> (bitcount - 8)) & 0xff)); - bitcount -= 8; - bitAccumulator &= (0xffff >> (16 - bitcount)); - } - } - - if (bitcount > 0) { - bitAccumulator <<= (8 - bitcount); - buffer.add((byte)((bitAccumulator | 0x5) & 0xff)); - } - - return ByteUtil.getByteArrayFromList(buffer); - } - - - /** - * DOESN'T WORK YET - * - * @param data - * @return - * @throws RileyLinkCommunicationException - */ - @Override public byte[] decode4b6b(byte[] data) throws RileyLinkCommunicationException { - List buffer = new ArrayList(); - int availBits = 0; - int bitAccumulator = 0; - - for (byte element2 : data) { - - short element = convertUnsigned(element2); - - // if (element < 0) { - // element += 255; - // } - - if (element == 0) { - break; - } - - bitAccumulator = (bitAccumulator << 8) + element; - availBits += 8; - - if (availBits >= 12) { - - int hiNibble; - int loNibble; - - try { - int index = (bitAccumulator >> (availBits - 6)); - int index2 = ((bitAccumulator >> (availBits - 12)) & 0b111111); - hiNibble = codesRev.get((bitAccumulator >> (availBits - 6))); - loNibble = codesRev.get(((bitAccumulator >> (availBits - 12)) & 0b111111)); - } catch (Exception e) { - log.error("Unhandled exception", e); - return null; - } - - int decoded = ((hiNibble << 4) + loNibble); - buffer.add((byte)decoded); - availBits -= 12; - bitAccumulator = bitAccumulator & (0xffff >> (16 - availBits)); - } - } - - return ByteUtil.getByteArrayFromList(buffer); - } - - - private void createCodeRev() { - codesRev = new HashMap<>(); - - for (int i = 0; i < encode4b6bList.length; i++) { - codesRev.put(i, encode4b6bList[i]); - } - } - -} diff --git a/rileylink/src/test/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/RFToolsParametrizedUTest.java b/rileylink/src/test/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/RFToolsParametrizedUTest.java index 2e5b6b1cb3..42ed577d43 100644 --- a/rileylink/src/test/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/RFToolsParametrizedUTest.java +++ b/rileylink/src/test/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/RFToolsParametrizedUTest.java @@ -1,18 +1,16 @@ package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble; -import java.util.Arrays; -import java.util.Collection; +import android.util.Log; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; -import android.util.Log; +import java.util.Arrays; +import java.util.Collection; import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.data.encoding.Encoding4b6bGeoff; -import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.data.encoding.Encoding4b6bGo; -import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.data.encoding.Encoding4b6bLoop; import info.nightscout.androidaps.plugins.pump.common.utils.ByteUtil; /** @@ -66,7 +64,7 @@ public class RFToolsParametrizedUTest { // @Test public void testEncodeGeoff() { - Encoding4b6bGeoff decoder = new Encoding4b6bGeoff(); + Encoding4b6bGeoff decoder = new Encoding4b6bGeoff(null); /* * {0xa7} -> {0xa9, 0x60} @@ -121,156 +119,11 @@ public class RFToolsParametrizedUTest { } - // @Test - public void testEncodeGo() { - - Encoding4b6bGo decoder = new Encoding4b6bGo(); - - /* - * {0xa7} -> {0xa9, 0x60} - * {0xa7, 0x12} -> {0xa9, 0x6c, 0x72} - * {0xa7, 0x12, 0xa7} -> {0xa9, 0x6c, 0x72, 0xa9, 0x60} - */ - /* test compare */ - // byte[] s1 = { 0, 1, 2 }; - // byte[] s2 = { 2, 1, 0, 3 }; - // byte[] s3 = { 0, 1, 2, 3 }; - // if (ByteUtil.compare(s1, s1) != 0) { - // LOG.error("test: compare failed."); - // } - // if (ByteUtil.compare(s1, s2) >= 0) { - // LOG.error("test: compare failed."); - // } - // if (ByteUtil.compare(s2, s1) <= 0) { - // LOG.error("test: compare failed."); - // } - // if (ByteUtil.compare(s1, s3) >= 0) { - // LOG.error("test: compare failed."); - // } - // testCompose(new byte[] {(byte)0xa7, (byte)0xa7}); - byte[] bs = decoder.encode4b6b(new byte[] { (byte)0xa7 }); - byte[] out = new byte[] { (byte)(0xa9), 0x65 }; - - System.out.println("EncodeGo: " + ByteUtil.getHex(bs)); - - if (ByteUtil.compare(bs, out) != 0) { - Log.e( - TAG, - "encode Data failed: expected " + ByteUtil.shortHexString(out) + " but got " - + ByteUtil.shortHexString(bs)); - Assert.fail(); - } - - bs = decoder.encode4b6b(new byte[] { (byte)0xa7, 0x12 }); - out = new byte[] { (byte)(0xa9), 0x6c, 0x72 }; - if (ByteUtil.compare(bs, out) != 0) { - Log.e( - TAG, - "encode Data failed: expected " + ByteUtil.shortHexString(out) + " but got " - + ByteUtil.shortHexString(bs)); - Assert.fail(); - } - - bs = decoder.encode4b6b(new byte[] { (byte)0xa7, 0x12, (byte)0xa7 }); - out = new byte[] { (byte)(0xa9), 0x6c, 0x72, (byte)0xa9, 0x65 }; - if (ByteUtil.compare(bs, out) != 0) { - Log.e( - TAG, - "encode Data failed: expected " + ByteUtil.shortHexString(out) + " but got " - + ByteUtil.shortHexString(bs)); - Assert.fail(); - } - - } - - - // @Test - public void testDecodeGo() throws Exception { - - Encoding4b6bGo decoder = new Encoding4b6bGo(); - - // testCompose(new byte[] {(byte)0xa7, (byte)0xa7}); - byte[] bs = decoder.encode4b6b(new byte[] { (byte)0xa7 }); - byte[] out = new byte[] { (byte)(0xa9), 0x65 }; - if (ByteUtil.compare(bs, out) != 0) { - Log.e( - TAG, - "encode Data failed: expected " + ByteUtil.shortHexString(out) + " but got " - + ByteUtil.shortHexString(bs)); - } - - byte[] back = decoder.decode4b6b(out); - - if (ByteUtil.compare(back, bs) != 0) { - Log.e( - TAG, - "decode Data failed: expected " + ByteUtil.shortHexString(out) + " but got " - + ByteUtil.shortHexString(bs)); - Assert.fail(); - } - - bs = decoder.encode4b6b(new byte[] { (byte)0xa7, 0x12 }); - out = new byte[] { (byte)(0xa9), 0x6c, 0x72 }; - if (ByteUtil.compare(bs, out) != 0) { - Log.e( - TAG, - "encode Data failed: expected " + ByteUtil.shortHexString(out) + " but got " - + ByteUtil.shortHexString(bs)); - } - - back = decoder.decode4b6b(out); - - if (ByteUtil.compare(back, bs) != 0) { - Log.e( - TAG, - "decode Data failed: expected " + ByteUtil.shortHexString(out) + " but got " - + ByteUtil.shortHexString(bs)); - Assert.fail(); - } - - bs = decoder.encode4b6b(new byte[] { (byte)0xa7, 0x12, (byte)0xa7 }); - out = new byte[] { (byte)(0xa9), 0x6c, 0x72, (byte)0xa9, 0x65 }; - if (ByteUtil.compare(bs, out) != 0) { - Log.e( - TAG, - "encode Data failed: expected " + ByteUtil.shortHexString(out) + " but got " - + ByteUtil.shortHexString(bs)); - } - - back = decoder.decode4b6b(out); - - if (ByteUtil.compare(back, bs) != 0) { - Log.e( - TAG, - "decode Data failed: expected " + ByteUtil.shortHexString(out) + " but got " - + ByteUtil.shortHexString(bs)); - Assert.fail(); - } - - return; - } - - - // @Test - // public void ttt_decodeGo() { - // - // RFTools.DecodeResponseDto decodeResponseDto = RFTools.decode6b4b_go(new byte[] { - // (byte)0xF9, (byte)0xE9, 0x63, (byte)0x9E, 0x7F, (byte)0xE6, 0x79, 0x5F, -1, (byte)0xCF, (byte)0xF0 }); - // - // if (decodeResponseDto.errorData != null) { - // Log.e(TAG, decodeResponseDto.errorData); - // Assert.assertTrue(false); - // } else { - // Assert.assertTrue(true); - // System.out.println("Response: " + ByteUtil.getHex(decodeResponseDto.data)); - // } - // - // } // @Test public void testParametrizedGeoffEncode() { - Encoding4b6bGeoff decoder = new Encoding4b6bGeoff(); + Encoding4b6bGeoff decoder = new Encoding4b6bGeoff(null); byte[] encodedX = decoder.encode4b6b(this.decoded); @@ -284,7 +137,7 @@ public class RFToolsParametrizedUTest { @Test public void geoffDecode() throws Exception { - Encoding4b6bGeoff decoder = new Encoding4b6bGeoff(); + Encoding4b6bGeoff decoder = new Encoding4b6bGeoff(null); byte[] decodedX = decoder.decode4b6b(this.encoded); @@ -292,38 +145,10 @@ public class RFToolsParametrizedUTest { } - @Test - public void goDecode() { - // Encoding4b6bGo decoder = new Encoding4b6bGo(); - // - // DecodeResponseDto decodeResponseDto = decoder.decode4b6b(this.encoded); - // - // Assert.assertNull(decodeResponseDto.errorData); - // System.out.println("Result: " + ByteUtil.getHex(decodeResponseDto.data)); - // System.out.println("Expected: " + ByteUtil.getHex(decoded)); - // Assert.assertArrayEquals(decoded, decodeResponseDto.data); - } - - - // @Test - public void loopDecode() { - // Encoding4b6bLoop decoder = new Encoding4b6bLoop(); - // - // byte[] data = decoder.decode4b6b(this.encoded); - // - // // RFTools.DecodeResponseDto decodeResponseDto - // - // // Assert.assertNull(decodeResponseDto.errorData); - // System.out.println("Result: " + ByteUtil.getHex(data)); - // System.out.println("Expected: " + ByteUtil.getHex(decoded)); - // Assert.assertArrayEquals(decoded, data); - } - - @Test public void geoffEncode() { - Encoding4b6bGeoff decoder = new Encoding4b6bGeoff(); + Encoding4b6bGeoff decoder = new Encoding4b6bGeoff(null); byte[] encodedX = decoder.encode4b6b(this.decoded); @@ -331,42 +156,4 @@ public class RFToolsParametrizedUTest { } - @Test - public void goEncode() { - Encoding4b6bGo decoder = new Encoding4b6bGo(); - - byte[] encodedX = decoder.encode4b6b(this.decoded); - System.out.println("Result: " + ByteUtil.getHex(encodedX)); - System.out.println("Expected: " + ByteUtil.getHex(encoded)); - Assert.assertArrayEquals(encoded, encodedX); - } - - - @Test - public void loopEncode() { - Encoding4b6bLoop decoder = new Encoding4b6bLoop(); - - byte[] encodedX = decoder.encode4b6b(this.decoded); - System.out.println("Result: " + ByteUtil.getHex(encodedX)); - System.out.println("Expected: " + ByteUtil.getHex(encoded)); - Assert.assertArrayEquals(encoded, encodedX); - } - - - private short[] createShortArray(byte[] data) { - - short[] outData = new short[data.length]; - - for (int i = 0; i < data.length; i++) { - short d = data[i]; - - if (d < 0) { - d += 256; - } - - outData[i] = d; - } - - return outData; - } }