Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UltralightCard fixes - byte order of ATQA, number of blocks in EV1 #2022

Merged
merged 1 commit into from
Jan 25, 2023

Conversation

jdbruner
Copy link
Contributor

@jdbruner jdbruner commented Jan 21, 2023

The ATQA returned by NFC anticollision is converted by a ushort by the Mfrc522, Pn532, and Pn5180 transceivers. In the case of the Mfrc522, the byte order was reversed - which was corrected by #2005. However, perhaps because the ATQA ushorts were inconsistently calculated by the different transceivers, it is also inconsistently used. Iot.Device.Card.Mifare.SetCapacity expects the ATQA of a Mifare classic 1K card to be 0x0004 and the ATQA of a Mifare classic 4K card to be 0x0002 (which are the values defined by NXP for those parts). However, Iot.Device.Card.Ultralight.UltralightCard.IsUltralightCard expects the ATQA of an Ultralight card to be 0x4400, when it should be 0x0044 according to the NXP spec.

In addition, the property UltralightCard.NumberBlocks returns the number of blocks based upon the type of the card. The values returned for UltralightEV1 cards are incorrect. This causes the sample code to attempt to read past the end of the card prevents the card configuration from being decoded.

This change aligns the expected ATQA and the actual number of blocks with the spec.

Tested with an Mfrc522 and a Pn532 using Mifare Classic and Ultralight cards. The cards are now correctly identified.

Microsoft Reviewers: Open in CodeFlow

@ghost ghost added the area-device-bindings Device Bindings for audio, sensor, motor, and display hardware that can used with System.Device.Gpio label Jan 21, 2023
@pgrawehr
Copy link
Contributor

/azp run dotnet.iot

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Member

@Ellerbach Ellerbach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Thanks for fixing those nit in all the cards.

@Ellerbach Ellerbach merged commit 5d07526 into dotnet:main Jan 25, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Dec 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-device-bindings Device Bindings for audio, sensor, motor, and display hardware that can used with System.Device.Gpio
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants