Click or drag to resize

12.4.3 How to Connect to a Card using its Serial Number

This procedure for making contact with a particular SP-ICE-3 Card from your application assumes that you already know the card's Serial Number.

Important note  Important
  • This procedure is intended for use with Internal and Peer-to-Peer cards.

  • It can not be used to connect over IPv4 to a card which is installed Externally/DHCP, since the card's IP Address is generally not predictable in such cases.

    The procedure is, however, applicable for IPv6 connections to a cards installed Externally/DHCP.

  • RAYLASE GmbH recommends the use of IPv6 for all connections to SP-ICE-3 Cards, since their IPv6 addresses are predictable from the cards' serial numbers under all normal circumstances.

Please refer to 5.5.2.3 How to obtain Card IP-Addresses the Hard Way.

Making contact with a card using its Serial Number.

Assuming we have armed ourselves with the card's Serial Number, we can attempt to make contact with it like this:

Note  Note
  • Boilerplate code is omitted from this example for brevity: please refer to 12.3 Example Code in this Manual.

  • This example is deliberately simplistic (some might say simple minded) to illustrate a point.

    It is not intended as an example of good programming style, nor of good programming practice.

C#
using ( ClientAPI client = new ClientAPI() )
{
    // NB: we assume the existence of a variable called SerialNumber,
    // which contains the serial number of the card we wish to contact.

    string CardIP = ClientAPI.PredictIPAddressFromSerialNumber( SerialNumber );

    // Open a communications channel to the card:
    client.Connect( CardIP );
    if ( client.Connected )
    {
        // Make sure that we are indeed in contact with the correct card!
        string cardSerialNumber = client.System.GetCardSerialNumber();

        Console.WriteLine( "Using SN {0}, connected to SN {1} at {2}", SerialNumber, cardSerialNumber, CardIP );

        // Close the communications channel to the card:
        client.Disconnect();
    }
}
See Also