Archives 2012

SpringCard introduces new SDK for NFC-enabled PC/SC readers

It’s now the final countdown before the launch of new SpringCard NFC products, H512 and NFC’Roll. Both products are not only able to read/write NFC Tags, but they also introduce NFC peer-to-peer communication and an innovative Card emulation mode.

The developers who already have an early release of either product, or who want to start evaluating the development process, are welcomed to download the first version of the SDK, which has been made available today, together with its documentation.

The NFC SDK for PC/SC includes
NFcTool, a Tag read/write Utility,
NFcBeam, implementing the NFC Forum ‘Simple NDEF Exchange Protocol’ (SNEP) on top of NFC Forum LLCP (Logical Link Control Protocol), itself on top of NFC-DEP, i.e. the NFCIP1 peer-to-peer layer (ISO 18092 chapter 12). A typical use-case would be to retrieve a contact entry (VCard) from an Android smartphone, or to push a SmartPoster from the PC to the smartphone,
NfcTagEmul, showing how easy it is for either H512 or NFC’Roll to emulate a NFC Forum Tag (type 2 or type 4). This makes it possible to push a SmartPoster, URI, Text, VCard… from the PC to the smartphone, as smoothly as if the phone was reading a static Tag,
– and much more!

Edit 15/10/2013: starting with PC/SC SDK version 2.12, the NFC extensions are now included in the PC/SC SDK itself. Please read this article for details.

Those software are available with complete source (C# for .NET) in the SDK. Please download and read PMD2228: NFC SDK for PC/SC – Getting Started Guide for a guided tour and a few technical details.

Click here to download SpringCard NFC SDK for PC/SC

The reference manual for operating the readers from PC/SC applications is here: PMD2176: H512 (and NFC’Roll) Developer’s Reference Manual.

An installer is also available (SQ2211: QuickStart for H512 and NFC’Roll) for people who want to try the products but don’t need the full SDK.

Warning: a few changes have been on the specifications since the Alpha version of the firmware (1.6x branch). Products shall be updated to firmware v1.70 in order to be compliant with the final specifications, and to work with this SDK. Current 1.7x branch doesn’t include peer-to-peer in Target mode (only Initiator mode is currently implemented). This will be added in 1.8x branch.

Retrieving the firmware version of your SpringCard PC/SC reader

In order to retrieve the firmware version of your SpringCard PC/SC reader (CSB6Prox’N’Roll PC/SCEasyFinger and CrazyWriter), you’ll need the Springcard PC/SC Diagnostic Tool, available in our SDK (PcscDiag2.exe).

Once launched, the tool should display your smart card reader. In the following snapshots, the reader is a Prox’N’Roll PC/SC, but it would be same for other PC/SC readers (CSB6, CrazyWriter, CrazyWriter-HSP, CSB-HSP, H663, …).

Right click on it, and choose Reader Info :

A pop-up window will then appear, indicating the firmware version (1-64 in this example):

Note: Instead of right clicking on the reader, you can also press Ctl+R to get the same information.

Print and encode simultaneously using SpringCard CrazyWriter and Evolis Zenius

Evolis Zenius is a color or monochrome card printer. Evolis offers SpringCard CrazyWriter PC/SC (ISO 14443, ISO 15693 + 2 SAM) as the contactless encoding option for Zenius -as well as for the other printers in its portfolio. Zenius plus CrazyWriter makes it easy to issue personalized cards on-the-field.

In this article we’ll show how to synchronize the card encoding part (CrazyWriter PC/SC) with the card printing job using Evolis’ SDK. Our sample project (C# source code available in the PC/SC SDK, under folder /samples/dotnet/ZeniusVCard) is a real-world example: we print a business card on a Desfire EV1 smartcard, and we store a vCard object into the Desfire, following NFC Forum standard known as ‘NFC Forum Type 4 tag’. Doing so, the business card goes NFC and could be read by any compliant smartphone, that will automatically add the vCard data to its contact list! All you need to try the demo by yourself is a blank and virgin Desfire EV1 card, and, of course, an Evolis Zenius printer featuring SpringCard CrazyWriter.

In a nutshell

To print and encode a vCard, the process is as follows:

  1. Ask the printer to take one card in the feeder, and to put it in position for encoding (in front of the CrazyWriter’s antenna),
  2. Recognize the card, format it if needed, write the data,
  3. Launch the print job,
  4. Optionnaly repeat the process, until there is no card left in the feeder.

The process always encodes a card before printing it. Doing so, should any problem append (not the expected type of card, card locked read-only…), the card is ejected immediately. No time nor ribbon has been waisted printing a useless card.

Architecture

There are two ways to communicate with an Evolis printer:

  • using the Windows spooler (as with any other printer),
  • using iomem.dll, a communication library supplied within Evolis’ SDK.

Sending print jobs to the spooler is straightforward as all the steps of the printing are handled automatically by the system. Unfortunately, once the job is launched, the software has no way to know where the card actually is in the printer nor to stop it for a few seconds in front of the antenna..

On the other end, sending low level commands through iomem.dll offers a lot of flexibility, but lots of things have to be re-implemented in the printing software. This requires a specific expertise and can be time consuming.

So we’ll take the best of the two worlds: iomem.dll will be used to drive the card in the printer until the CrazyWriter has done its job, and afterwards a print job will be sent to the spooler to actually print the card. We’ll also have to use iomem.dll again to detect the end of the print job, so our software will not try to insert another card in the path until the previous card has been printed and ejected.

Step by step explanation of the sample project

Selecting the target printer and contactless coupler

The .NET PrintDialog object (System.Windows.Controls.PrintDialog) if the easiest way to select a printer. The name of the selected printer is returned in PrintDialog.PrinterSettings.PrinterName.

There’s no immediate way to know which CrazyWriter (or in general which PC/SC reader) belongs to the selected printer. So we display our common ‘Select PC/SC Reader’ dialog to let the user find the reader. Default is to select the contactless interface of the first available CrazyWriter.

Controlling the printer through iomem.dll

First step is to gain access to iomem.dll‘s entry points from our C# application. The function used are:

  • OpenPebble
  • ClosePebble
  • ReadPebble
  • WritePebble
  • GetTimeout
  • SetTimeout


Please refer to Evolis’ SDK for a detailed documentation of the DLL.

OpenPebble(PrinterName) gives use access to the printer, we then can use the couple WritePebble/ReadPebble to send arbitrary commands to the printer -and wait for its answer.

Here are the 3 only commands we need:

  • Rlr;h to check whether the feeder is empty,
  • Sic to load a card from the feeder, and to move it into position for encoding (in front of the CrazyWriter’s antenna),
  • Se to eject the card (in case the encoding has failed).

If the encoding is successful, sending a print job to the spooler is enough to make the printer take the card from its current position (in front of the antenna), print it, and eject it.

To know whether the print job is terminated or still pending, we’ll use a very simple trick: as the printer is not available to answer to iomem.dll commands while it is under control of the system’s spooler, we’ll send repeated dummy commands, and we’ll know that the job is ended when we’ll get an answer at last. The dummy command is:

  • Rfv read firmware version

Please also refer to Evolis’ SDK for details regarding the printer’s command set.

Encoding the vCard on the contactless card

This part is shared with the vCard part of NFCTool, another of our samples. The only difference is that NFCTool can also read cards, and implements a ‘wake up on card arrival’ scheme that doesn’t have to be implemented in this sample. The card ‘arrives’ only after a successful invocation of the “Sic” control command.

We start by opening a PC/SC channel to the card: scard = new SCardChannel(ReaderName) (see the documentation of our PC/SC for .NET API for details).

Then we use the methods of our NfcTag object (NfcTag.IdentifyTagType, NfcTag.BackgroundRecognize) to check whether the card is a NFC Forum tag or not. It must be either already formatted (and offering enough memory space to store the vCard) or a Desfire EV1 that we know how to format and write. Note that BackgroundRecognize, as the name says, performs the recognition in a background thread and invoke a callback function once done. This is generally speaking a good practice to implement card-related stuff in a background thread so the application’s window remains ‘alive’ even if the card takes its time to answer. At this step, the card is now for sure compliant with NFC Forum type 4 specification (or has been ejected if not, or if the user has chosen not to overwrite existing data).

Eventually, a new NfcVCard object is created, populated with the data entered by the user, and inserted as the content of the NfcTag objet. The the NfcTag.BackgroundWrite method is called, so the vCard content goes actually into the card. Once again this is done in a background thread.

Printing the layout on the card

At the end of the writing (that takes no more than one second anyway), the callback that is invoked launches the print job.

To print our business card, we process as follow:

  1. Create a PrintDocument object (System.Drawing.Printing.PrintDocument),
  2. Add to this PrintDocument object a PrintPageEventHandler function that will be invoked to actually draw the layout,
  3. Code the PrintPageEventHandler to implement the drawing of the business card from the data entered by the user,
  4. Invoke the PrintDocument.Print() method to send it to the spooler.

In this example, the PrintPageEventHandler is implemented in the FormatBusinnessCard function. The name and the title are printed in the middle of the card, respectively in Arial 16 and Arial 14; the contact information (business phone and e-mail) are in the down-left corner in Arial 10; the picture is printed in the up-right corner; etc… Of course this is the first thing you’ll have to change to design your cards according your own layout.

Waiting for the end of the job

Once PrintDocument.Print() has been called, there’s nothing else to do but wait. The spooler works in background, so the application is free to do anything else, but we can’t start encoding another card until the current one has been printed and ejected. Therefore we implement a waiting loop, sending the “Rfv” command through iomem.dll repeatedly. Once the printer responds, we know that the job is over. We could then loop to go on with the next card.

PC/SC driver updated

We’ve just published a new release of our WHQL-certified driver for SpringCard PC/SC products. This new version (code name: SDD480-BB) fixes a few bugs that have been experienced with the earlier release:
– corrected a memory leakage that used to occur as a consequence of frequent SCardControl calls
– CSB6 now reports correctly “card mute” when a card is physically inserted but unresponsive
– improved overall stability on multi-slot readers thanks to a stricter synchronization of SCardTransmit calls

To download the driver, please go to http://www.springcard.com/download/find.php?file=sdd480. The installer now contains both x86 and x64 binaries, and select automatically the one adapted to your system. It will also be available through Windows Update in a few days.

As the previous one, this release targets all SpringCard USB CCID readers :
CSB6
CrazyWriter
EasyFinger
Prox’N’Roll PC/SC

Users are welcome to deploy this new release as soon as possible.

New PC/SC SDK and sample applications

The version 2.00 of our PC/SC SDK is now available for download: pcsc-sdk_2-00.zip. This SDK works with our PC/SC readers (CSB6Prox’N’Roll PC/SCEasyFinger and CrazyWriter).

This release of the SDK includes a new PC/SC Diag application, rewritten from scratch in C# for the .NET framework (previous version written in C++ with MFC for Win32 is still available anyway). This PC/SC Diagnostic application makes it easy to exchange APDU commands/responses (SCardTransmit) with the smartcard in a given reader, and/or to send directly control commands to the reader itself (SCardControl). Giving the user full control on the various options given by the other winscard.dll‘s function (SCardConnect, SCardReconnect, SCardDisconnect), this new version of PC/SC Diag is the must-have utility to discover the PC/SC world and to explore virtually any smartcard “by hand”.

The SDK provides both the source code and the compiled binaries. Should you want to use the software directly, you may download and install PC/SC Diag for Windows through this setup package: PC/SC Diag setup (SQ2075).

The SDK also now includes a brand new application to deal with NFC Forum tags, according to the SmartPoster and vCard specifications. NFCTool is able to both format, write and read the popular NFC Forum type 2 tags (NXP Mifare UL and UL C family, Infineon My-D NFC SLE66 series, Kovio 2KB tags, and more) and also the NFC Forum type 4 tags (formatting is implemented only for NXP Desfire EV1, but read/write is designed to operate with virtually any compliant card already formatted). A companion to NFCTool is NFCSpTray is a small utility that sits in the tray-bar and waits “silently” until a tag holding a valid SmartPoster is presented on the contactless reader. Then NFCSpTray opens the SmartPoster’s URL in your default web browser. This is the first step for a NFC Forum SmartPoster-based navigation on Windows!

The SDK provides both the source code and the compiled binaries. Should you want to use the software directly, you may download and install NFCTool and NFCSpTray for Windows through this setup package: NFCTool and NFCSpTray setup (SQ2074).

Card analysis on NFCWizard

NFCWizard.com is a free web-based online service, created and managed by SpringCard. Thanks to a Java applet, NFCWizard makes it possible to read and write SmartPoster or vCard tags directly within your web browser! NFCWizard is compliant with NFC Forum type 2 tags (Mifare UL family, and equivalent chips) and NFC Forum type 4 tags (ISO 7816-4, including complete handling of Desfire EV1 chips). All you need is a SpringCard PC/SC reader.

More than that, NFCWizard provides a free and easy-to-use card « analysis » tool, that given a smartcard will tell you want kind of chip it may be, and/or what kind of application it may host. You can use NFCWizard with our products in the SpringCard CSB6 Family (CSB6Prox’N’Roll PC/SCEasyFinger and CrazyWriter) and our NFC readers/encoders (H512NFC’Roll).

Click here for a direct access to NFCWizard’s card analysis page.