How to upload Java Applet to SmartMX controller - nfc

In one week I will have the following SmartMX controller: NXP P5CD041 (in NFC ring). As I understand it has 2 interfaces: ISO/IEC 14443 A Contactless Interface and ISO/IEC 7816 contact interface.
I have read that I can write Java Applet and upload it to this controller. But I don't understand how. As I unserstand, I can upload it only using ISO/IEC 7816 contact interface and it needs some wired programmer that will be connected to pins of this controller. Am I right?
Can someone explain me what equipment do I need to upload Java Applet to this controller? Can I do it wirelessly (e.g. using Android or some special device)?

There is no difference between developing an applet for a contact card or for a contact-less card.
Requirements :
A Contact or contactless smart card reader [ACR122 is a Contactless reader & ACR38 is contact reader for example. There are also some readers that are dual interface]
The Java Card Development Kit : It's available in Oracle.
An IDE (Optional) : Eclipse or NetBeans for example
A tool to Upload and install your Java Card applications (Optional) : GlobalPlatformPro for example.
A tool to send and receive APDU commands to/from the card (Optional) : OpenSCTool for example.
JCOP Tools if your chio comes with a JCOP OS installed on it and you want to use proprietary packages and methods also (So it is optional also)
Note that 3, 4 and 5 are optional because you can use the same Java Card Development Kit tools to do whatever you want. (But these tool are really more friendly than JCDK Tools)
If you choose Eclipse as your IDE, you must add a plugin named Eclipse-JCDE to it, And if you choose NetBeans as the IDE, it has Java Card plugin installed by default [in new versions].
An example :
The is a simple procedure for a simple helloWorld applet (Java Card applications), it returns "Hello Wolrd" in reception of any command:
1- Write this program in the IDE.
2- Assign a 5 to 16 byte number to the package and another one to the application as their AID (Application Identifier) and compile the .java file to .class using Java Development Kit.
3- Convert the .class file of previous step to a .cap file using Java Card Development Kit directly or using those IDE plugins indirectly.
4- Insert your card in the reader (For contactless cards bring in the field of the reader) and upload and install that .cap file on the chip using GlobalPlatformPro command as below : (In this step you do Authentication procedure and you need some keys)
CommandLine:> gp -install "capFileAddress"
5- Use Opensctool to select your applet using its AID and send APDU commands to it and receive APDU responses from it :
CommandLine:> opensc-tool -s 00a40400[AID Length In hex][AID] -s [AnotherOptionalCommand]
Notes :
1- AID is a name for applications and packages on the card. It has a 5 byte mandatory part and a 0 to 11 byte optional part. Applet AID must be equal with its package AID in the first 5 bytes.
2- When you want to make a communication with your applet in your card, you first need to select it using a select command. and the all the others commands refer to that selected applet.
3- What is APDU? It is a protocol in which commands defined as a sequence of hexadecimal numbers. You use this commands to communicate with the cards.
4- OpenSCTool and GlobalPlatformPro has whatever you need. But if you want to write your own tool, you can use PyScard library for Python or javax.smartcardio package for Java programs.

As I unserstand, I can upload it only using ISO/IEC 7816 contact
interface and it needs some wired programmer that will be connected
to pins of this controller. Am I right?
I haven't checked the datasheet of this part, but you should in any case be able to upload your applets via the ISO7816 interface. The "programmer" that you need is nothing more than a ordinary SmartCard reader. These are cheap. You can get them for around 12 €/$. When you go shopping make sure that it supports the PC/SC interface (95% of all readers do, but just check just in case).
If your SmartMX chip comes in form of a smart-card with integrated antenna for NFC then you're done. It will fit almost any reader. If you get the bare chip you have to hook up the ISO7816 signals: clock, data, power, reset and ground. Since the readers are so cheap you can just crack one open and solder some wires onto it. Keep them below 20cm.
Can I do it wirelessly (e.g. using Android or some special device)
Maybe. The SmartMX will appear on a Android phone as a IsoDep tag. You can exchange the same data over NFC as you can exchange over ISO7816. Both interfaces speak the ISO7816-4 protocol. It is possible that access to privileged operations like installing/deleting applets is restricted on the wireless interface though.
Also you won't get the nice upload tools from the SDK for Android.
To develop applets you need the JavaCard SDK from Oracle. It comes with a emulator, so you can already try out some of the examples and run them. As far as I remember the SDK also contains a bunch of scripts that allow uploading applets to various Smart-cards including the JCOP/SmartMX.
You may also need authentication keys to install the applets. If so they should be supplied with the chips/cards.

Related

Is it possible to obtain the vendor and product ID from a USB device connected to a client using RDP?

Hello fellow community,
I'm currently trying to differentiate between multiple HID input sources connected to a RDP client running Windows 10 Business build 19045.2251. The server itself is a Microsoft Windows Server 2019 build 17763 running a custom C# 4.7 .NET application.
The application shall then differentiate betweeen a barcode reader, an RFID reader and a keyboard respectively.
My naive idea is to only allow inputs coming from the barcode reader and only when an authorized person gives permission by means of his/her RFID chip, keyboard inputs are permitted.
Running the application locally for testing purposes allowed to perform the distinction using the vendor and product ID of a given input device using raw inputs.
Unfortunately, this breaks once I move the application onto the server and try obtaining raw inputs from the device connected to the client, as shown below:
raw information of USB device connected to client
So far I tried activating remoteFx in the hope of gettig device specific information, but to no avail.
I could not find any helpful resources on the internet and thus I am turning to you, hoping anybody could provide me with some hints on how to go on.
Also if this approach is flawed to begin with, I am happy to adapt the logic in order for it to work.
Thanks in advance for any input!

How to Emulate Com Ports on Windows and provide VendorId and ProductId

I need to emulate a few USB devices on Windows to write and test code without any hardware dependencies.
We use COM port emulators (here com0com) to create COM port pairs. Most devices we test by sending control signals from a controller application to any open ports which can then be picked up by device simulator applications that can return relevant commands (by way of HTTP requests). The applications are written in Nestjs (Node) and utilize the SerialPort library.
However, for some devices we need to get the specific VendorId and ProductId and I am not sure if and how this can be emulated, even if we would write our own drivers. It seems that this information has to come from the devices themselves (firmware)?
I am relatively new to software development and surely to this specific domain and I would be grateful for some directions and pointers. I am willing to invest some time to solve this, e.g. get into driver development, if I have an idea about how it could look and where to start (if at all).

How can I make a custom USB device show up in Windows as a COM Port?

I have developed a USB device that communicates with linux over a simple but proprietary interface and some custom Linux drivers. My goal is to port this to Windows without writing windows drivers. What I would like to do is find an open source or inbuilt class driver for windows that would look like a COM port in Windows. Then I would tailor the embedded software to match what ever protocol and descriptors the virtual COM port expects to see.
The idea would be that I could plug my device in to a Windows machine and a relatively high speed COM port would appear with out me having to develop Windows drivers for it.
I have been looking at the USB CDC (Communications Device Class) documentation and it looks promising, but I don't know which sub interface would be best to use so that it would show up as a COM port.
Has anyone here done any work like this before or could provide some insight?
Specifically:
Are there virtual COM drivers "built in" to windows or would I need a 3rd party driver.
Which CDC sub class should I use for simple RS232 emulation (No need for modem AT commands, etc)
Is there a better option to do what I am trying to do.
Thanks
There is a USB-to-serial driver built in to Windows that will do what you want. It is called usbser.sys:
http://support.microsoft.com/kb/837637
You will have to write an INF file and distribute that to your users, but that will not be too hard because it is only a few kilobytes of text and you can find examples online.
I'm not aware of any great documentation for this driver by Microsoft, so my advice would be to find some other device that uses it, such as Pololu Wixel, and copy what they did.
Here are the device descriptors we used and the special control tranfers we had to implement:
https://github.com/pololu/wixel-sdk/blob/master/libraries/src/usb_cdc_acm/usb_cdc_acm.c
You can see our INF file, wixel_serial.inf, by downloading the software and looking in the drivers folder:
http://www.pololu.com/docs/0J46/3.a
(There are other files in there that are not necessary for you.)
You can also look at the Arduino Uno because they use the same driver.
Whatever you do, please don't use our USB Vendor ID in your product! You need to get your own.
Update: In Windows 10, you don't need an INF file anymore because of the new usbser.inf driver that comes with Windows.
If you are using a UART you can easily interface it to a FTDI USB chip like http://www.ftdichip.com/Products/ICs/FT232R.htm or a Prolific like http://www.prolific.com.tw/eng/products.asp?id=59
For development, prototype and testing I have half dozen of these laying around http://www.pololu.com/catalog/product/391
I connect it directly to the UART pins on AVR and 8051 micros.

Faking an RS232 Serial Port

I'm developing a project that has a number of hardware sensors connecting to the deployment machine through RS232 serial ports.
But ... I'm developing on a machine without an physical RS232 serial ports, but I would like to make fake serial ports that I can connect to and output data from with the aim of faking input from hardware sensors.
Does anyone know of a way to create a fake serial port and control it on Windows XP?
If you are developing for Windows, the com0com project might be, what you are looking for.
It provides pairs of virtual COM ports that are linked via a nullmodem connetion. You can then use your favorite terminal application or whatever you like to send data to one COM port and recieve from the other one.
EDIT:
As Thomas pointed out the project lacks of a signed driver, which is especially problematic on certain Windows version (e.g. Windows 7 x64).
There are a couple of unofficial com0com versions around that do contain a signed driver. One recent verion (3.0.0.0) can be downloaded e.g. from here.
I know this is an old post, but in case someone else happens upon this question, one good option is Virtual Serial Port Emulator (VSPE) from Eterlogic
It provides an API for creating kernel mode virtual comport devices, i.e. connectors, mappers, splitters etc.
However, some of the advertised capabilities were really not capabilities at all.
EDIT
A much better choice, Eltima. This product is fully baked. Good developer tech support. The product did all it claimed to do. Product options include both desktop applications, as well as software development kits with APIs.
Neither of these products are open source, or free. However, as other posts here have pointed out, there are other options. Here is a list of various serial utilities:
com0com (current)
com0com - With Signed Driver (old version)
Yet another place for com0com with Signed Driver (Pete's Blog)
Tactical Software
Termite
COM Port Serial Emulator
Kermit (obsolete, but still downloadable)
HWVSP3
HHD Software (free edition)
I use com0com - With Signed Driver, on windows 7 x64 to emulate COM3 AND COM4 as a pair.
Then i use COM Dataport Emulator to recieve from COM4.
Then i open COM3 with the app im developping (c#) and send data to COM3.
The data sent thru COM3 is received by COM4 and shown by 'COM Dataport Emulator' who can also send back a response (not automated).
So with this 2 great programs i managed to emulate Serial RS-232 comunication.
Hope it helps.
Both programs are free!!!!!
There's always the hardware route. Purchase two USB to serial converters, and connect them via a NULL modem.
Pro tips:
1) Windows may assign new COM ports to the adapters after every device sleep or reboot.
2) The market leaders in chips for USB to serial are Prolific and FTDI. Both companies are battling knockoffs, and may be blocked in future official Windows drivers. The Linux drivers however work fine with the clones.
Another alternative, even though the OP did not ask for it:
There exist usb-to-serial adapters.
Depending on the type of adapter, you may also need a nullmodem cable, too.
They are extremely easy to use under linux, work under windows, too, if you have got working drivers installed.
That way you can work directly with the sensors, and you do not have to try and emulate data.
That way you are maybe even save from building an anemic system.
(Due to your emulated data inputs not covering all cases, leading you to a brittle system.)
Its often better to work with the real stuff.
i used eltima make virtual serial port for my modbus application debug work. it is really very good application at development stage to check serial port program without connecting hardware.

Retrieve SD Card serial number on Windows XP/Vista/7?

There is a manufacturer's serial number on SD cards, and there are a number of pages on the 'net that describe how to retrieve it on various mobile devices (including this one). But I need to retrieve it under desktop versions of Windows, and the code that works for mobile versions of Windows doesn't seem to translate.
The question: how do you programmatically retrieve the SD card manufacturer's serial number from an SD card under desktop Windows?
EDIT: From what I gather, this can be done using the DeviceIoControl's IOCTL_SFFDISK_DEVICE_COMMAND to send command 10 from the SD Card specs, but it's unreliable -- it only works with certain non-USB card readers, and only with certain drivers for those readers. That makes it useless for our purposes. Maybe someone else can get some use from the information.
Well, you could do this using SetupDiXXX api calls (see this Code Project example) or if I'm not mistaken using WMI queries.
I'm not very versatile using WMI queries but I'm sure there's a ton of info on the net about it.
Using the SetupDiXXX methods you can query for present devices of a specific class (you would have to look up the device class for SD cards) and then enumerate through the devices present in the computer, reading the Manufacturer Serial number.
For reference on SetupDiXXX functions, see the following
SetupDiGetClassDevs
SetupDiEnumDeviceInfo
SetupDiEnumDeviceInterfaces

Resources