Einzelnen Beitrag anzeigen

totti14

Registriert seit: 26. Mai 2005
Ort: Bremen
90 Beiträge
 
Delphi 10.3 Rio
 
#63

AW: Smartcard auslesen, Kommandos senden

  Alt 9. Nov 2011, 21:50
Hi newuser01,
was hast Du vor

Soll das so aussehen wir bei mir

ja genau, du weist schon was ich will auslesen und CMDs senden


CMD's senden ganz einfach

Delphi-Quellcode:

const
 sc_GetHEXSerial: Array [0 .. 4] Of byte = ($02, $01, $00, $00, $00);

//------------------------------------------------------------------------
Function ICC_Async_CardWrite(Var reader: treader; command: Pbyte; command_len: Word; rsp: Pbyte; Var lr: Word): Boolean;
Const
  resync: Array [0 .. 3] Of byte = ($21, $C0, $00, $E1);
Var try1: Integer;
  a: byte;
Begin
  a := command[0];
  lr := 0; // will be returned in case of error
  Case (reader.protocol_type) Of
    ATR_PROTOCOL_TYPE_T0:
      Protocol_T0_Command(reader, command, command_len, rsp, lr);

    ATR_PROTOCOL_TYPE_T1:
      Begin
        try1 := 1;
        While (try1 <= 3) Do
        Begin
          If Protocol_T1_Command(reader, command, command_len, rsp, lr) = OK Then
            break;
          Inc(try1);
            // try to resync
          Protocol_T1_Command(reader, @resync, sizeof(resync), rsp, lr);
          reader.ifsc := DEFAULT_IFSC;
        End;
      End;
    ATR_PROTOCOL_TYPE_T14:
      Protocol_T14_ExchangeTPDU(reader, command, command_len, rsp, lr);

    Else
      Log.cs_log('Error, unknown protocol type %i', [reader.protocol_type]);
      Result := false;
      exit;
    End;
  If debug Then
  Begin

    Dump.cs_dump(rsp, lr, 'answer from cardreader %s:', [reader.alabel]);
  End;
  Result := True;
End;


//-------------------------------------------------------------------------
Function reader_cmd2icc(Var reader: tReader; buf: PByte; l: Word; cta_res: PByte; Var cta_lr: Word): Boolean;
Var
  rc: Boolean;
Begin
  If debug Then
  Begin
    Dump.cs_dump(buf, l,'write to cardreader %s:', [reader.alabel]);
  End;
  rc := ICC_Async_CardWrite(reader, buf, l, cta_res, cta_lr);
end;

------------------------------------------------------------------------------
 // * Ascii/Hex-Serial
  reader_cmd2icc(reader, @sc_GetASCIISerial, SizeOf(sc_GetASCIISerial), @cta_res, cta_lr);
Nachdem die Karte im richtigen Modus läuft
  Mit Zitat antworten Zitat