Skip to content

Commit 6f57698

Browse files
authored
Merge pull request #49 from josevcm/develop
handle EGT
2 parents 16c1b5a + ada0993 commit 6f57698

File tree

1 file changed

+20
-7
lines changed
  • src/nfc-lib/lib-lab/lab-logic/src/main/cpp/tech

1 file changed

+20
-7
lines changed

src/nfc-lib/lib-lab/lab-logic/src/main/cpp/tech/Iso7816.cpp

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -926,24 +926,37 @@ struct Iso7816::Impl : IsoTech
926926
case IsoRequestFrame:
927927
{
928928
frameStatus.frameType = IsoResponseFrame;
929-
frameStatus.guardTime = protocolStatus.characterGuardTime - GT_THRESHOLD * protocolStatus.elementaryTime;
930-
frameStatus.waitingTime = protocolStatus.blockWaitingTime + WT_THRESHOLD * protocolStatus.elementaryTime;
931929
break;
932930
}
933931
case IsoResponseFrame:
934932
{
935933
frameStatus.frameType = IsoRequestFrame;
936-
frameStatus.guardTime = protocolStatus.characterGuardTime - GT_THRESHOLD * protocolStatus.elementaryTime;
937-
frameStatus.waitingTime = protocolStatus.blockWaitingTime + WT_THRESHOLD * protocolStatus.elementaryTime;
938934
break;
939935
}
940-
default:
936+
}
937+
938+
// N=255 has a protocol-dependent meaning:
939+
// - GT=12 ETU under protocol T=0 nad during PPS (Protocol and Parameters Selection)
940+
// - GT=11 ETU under protocol T=1 (corresponding to 1 start bit, 8 data bits, 1 parity bit, and 1 stop bit; with no error indication)
941+
if (protocolStatus.extraGuardTimeUnits == 255)
942+
{
943+
if (protocolStatus.protocolType == PROTO_T0)
941944
{
942-
frameStatus.guardTime = protocolStatus.characterGuardTime - GT_THRESHOLD * protocolStatus.elementaryTime;
943-
frameStatus.waitingTime = protocolStatus.characterWaitingTime + WT_THRESHOLD * protocolStatus.elementaryTime;
945+
frameStatus.guardTime = (12 - GT_THRESHOLD) * protocolStatus.elementaryTime;
944946
}
947+
else
948+
{
949+
frameStatus.guardTime = (11 - GT_THRESHOLD) * protocolStatus.elementaryTime;
950+
}
951+
}
952+
else
953+
{
954+
frameStatus.guardTime = protocolStatus.characterGuardTime - GT_THRESHOLD * protocolStatus.elementaryTime;
945955
}
946956

957+
// waiting time is set by default to 960 ETUs for T=0 and 9600 ETUs for T=1
958+
frameStatus.waitingTime = protocolStatus.characterWaitingTime + WT_THRESHOLD * protocolStatus.elementaryTime;
959+
947960
// clear search to detect first start bit of next frame
948961
modulationStatus.searchStartTime = 0;
949962
modulationStatus.searchEndTime = 0;

0 commit comments

Comments
 (0)