private static void AssertWriteValidFunction(FunctionCode functionCode, byte controlByteValue, byte uppperThreeBit) { var controlByte = new ControlByte(uppperThreeBit); controlByte.FunctionCode = functionCode; Assert.AreEqual(controlByteValue, controlByte.Byte); }
private static void AssertReadInvalidFunctionCode(ControlByte controlByte) { void AccessFunctionCode() { var _ = controlByte.FunctionCode; } DltLibAssert.AssertException <InvalidControlByteException>(AccessFunctionCode, ex => ex.InvalidControlByte == controlByte.Byte); }
private static void AssertWriteInvalidFunctionCode(byte functionCodeValue, byte uppperThreeBit) { var controlByte = new ControlByte(uppperThreeBit); void AssignFunctionCode() { controlByte.FunctionCode = (FunctionCode)functionCodeValue; } DltLibAssert.AssertException <InvalidEnumArgumentException>(AssignFunctionCode); }
public string GetApdu(ControlByte control, ushort address, byte data) { byte fullControlByte = (byte)control; switch (control) { case ControlByte.WriteAndEraseWithProtectBit: case ControlByte.WriteAndEraseWithoutProtectBit: case ControlByte.WriteProtectBitWithDataComparison: case ControlByte.Read9BitsDataWithProtectBit: case ControlByte.Read8BitsDataWithoutProtectBit: fullControlByte |= (byte)(((1 << 9 | 1 << 8) & address) >> 2); break; case ControlByte.WriteErrorCounter: address = 0xFD; break; case ControlByte.ResetErrorCounter: address = 0xFD; data = 0xFF; break; case ControlByte.ReadErrorCounter: address = 0xFD; data = 0x00; break; case ControlByte.VerifyPinByte: if (!(address == 0x03FE || address == 0x03FF)) { return(null); } break; default: return(null); } return("FF70076B07A605A103" + fullControlByte.ToString("X2") + ((byte)address).ToString("X2") + data.ToString("X2") + "00"); }
public string GetApdu(ControlByte control, byte address, byte data) { return("FF70076B07A605A003" + ((byte)control).ToString("X2") + address.ToString("X2") + data.ToString("X2") + "00"); }
private static void AssertReadValidFunctionCode(FunctionCode functionCode, ControlByte controlByte) { Assert.AreEqual(functionCode, controlByte.FunctionCode); }