Topics   All   Mac OS X (Only)   Windows (Only)   Linux (Only, Not)   iOS (Only, Not)  
Components   Crossplatform Mac & Win   Server (Not)   Client   Old   Guides   Examples
New in version: 6.1   6.2   6.3   6.4   6.5   7.0   7.1   7.2   7.3   7.4    Statistic  

SmartCard.Transmit

Sends a service request to the smart card and expects to receive data back from the card.

Component Version macOS Windows Server FileMaker Cloud FileMaker iOS SDK
SmartCard 6.3 Yes Yes Yes No No

MBS( "SmartCard.Transmit"; SmartCardContext; SendHeader; SendBuffer; RecvLength )

Parameters

Parameter Description Example value
SmartCardContext The smartcard context reference number. $SmartCardContext
SendHeader The hex encoded protocol header structure for the instruction.
This buffer is in the format of an SCARD_IO_REQUEST structure, followed by the specific protocol control information (PCI).
For the T=0, T=1, and Raw protocols, the PCI structure is constant. The smart card subsystem supplies a global T=0, T=1, or Raw PCI structure, which you can reference by using the symbols SCARD_PCI_T0, SCARD_PCI_T1, and SCARD_PCI_RAW respectively.
With version 7.0 or newert this can be empty to use default header.
SendBuffer The hex encoded data to be sent to the card.
For T=0, the data parameters are placed into the address pointed to by pbSendBuffer according to the following structure:

Type name Description
Byte Cla The instruction class
Byte Ins The instruction code
Byte P1 Parameter to the instruction
Byte P2 Parameter to the instruction
Byte P3 Size of I/O transfer

The data sent to the card should immediately follow the send buffer. In the special case where no data is sent to the card and no data is expected in return, P3 is not sent.
RecvLength The number of bytes for the receiving buffer. 1024

Result

Returns Receive Buffer or error.

Description

Sends a service request to the smart card and expects to receive data back from the card.
Returns receive buffer hex encoded.

see also
https://msdn.microsoft.com/en-us/library/windows/desktop/aa379804(v=vs.85).aspx

You can use SmartCard.TransmitReceiveHeader to return last Transmit's receive header.

Examples

Query serial number of card:

MBS( "SmartCard.Transmit"; $Context; "0200000008000000"; "00ca018108"; 8 )

Query version:

MBS( "SmartCard.Transmit"; $Context; "0200000008000000"; "00ca018202"; 2 )

Connect and query value:

If [MBS( "SmartCard.Available" ) = 1]
    #Start a new session
    Set Variable [$SCContext; Value:MBS( "SmartCard.Init" )]
    If [MBS( "SmartCard.Valid"; $SCContext )]
        #Query list of readers and pick first
        Set Variable [$SCReader; Value:GetValue ( MBS( "SmartCard.ListReaders"; $SCContext) ; 1 )]
        If [MBS("IsError") = 0]
            # Connect to card
            Set Variable [$SCConnect; Value:MBS( "SmartCard.Connect"; $SCContext ; $SCReader ; "Shared"; "any")]
            Set Variable [$PRotocol; Value:MBS( "SmartCard.GetActiveProtocol"; $SCContext)]
            If [$SCConnect = "OK"]
                #Run a query
                Set Variable [$Result; Value:MBS( "SmartCard.Transmit"; $SCContext; "0200000008000000"; "00ca018202"; 512 )]
                #Result is 4 bytes. Starts with C901 for Version 5.0 or C903 for Version 5.3
                Show Custom Dialog ["Version"; $result]
                #Disconnect
                Set Variable [$SCDisconnect; Value:MBS( "SmartCard.Disconnect"; $SCContext; "Leave" )]
            Else
                Show Custom Dialog ["Error"; "No card available."]
            End If
        End If
        #End Card Session
        Set Variable [$SCRelease; Value:MBS( "SmartCard.Release" ; $SCContext )]
    Else
        Show Custom Dialog ["Error"; "Failed to initalize"]
    End If
Else
    Show Custom Dialog ["Error"; "No SmartCard API on this OS."]
End If

See also


SmartCard.Status   -   SmartCard.TransmitReceiveHeader

Feedback: Report problem or ask question.




Links
MBS Xojo Chart Plugins