unosquare / raspberryio

The Raspberry Pi's IO Functionality in an easy-to-use API for Mono/.NET/C#
https://unosquare.github.io/raspberryio
Other
673 stars 104 forks source link

Waveshare PN532. Cant read UID #227

Closed Crashdummyy closed 3 years ago

Crashdummyy commented 3 years ago

Describe the bug I want to read the UID of some cards ( desfires, too ). I bought this Module. The module is a pn532 and as of #198 i suspected it could read the card

To Reproduce

            Pi.Init<BootstrapWiringPi>();
            while (true)
            {
                var device = new RFIDControllerMfrc522(Pi.Spi.Channel0,
                                                       spiFrequency: 500000,
                                                       Pi.Gpio[20]);
                // If a card is found
                var result = device.DetectCard();
                if (result == RFIDControllerMfrc522.Status.Error) continue;
                Console.WriteLine("Card detected");

                // Get the UID of the card
                var uidResponse = device.ReadCardUniqueId();
                Console.WriteLine($"Raw: {uidResponse.Data}");
                Console.WriteLine($"Card UID: {uidResponse.Data[0]}|{uidResponse.Data[1]}|{uidResponse.Data[2]}|{uidResponse.Data[3]}");
                Console.WriteLine($"UID String: {Encoding.UTF8.GetString(uidResponse.Data)}");
            }

No Output is printed to my console. I tried various other pins or frequencies... However the Demo Codes define like that.

#define _RESET_PIN                      (20)
#define _REQ_PIN                        (16)

#define _SPI_STATREAD                   (0x02)
#define _SPI_DATAWRITE                  (0x01)
#define _SPI_DATAREAD                   (0x03)
#define _SPI_READY                      (0x01)
#define _SPI_CHANNEL                    (0)
#define _NSS_PIN                        (4)

Expected behavior The Uid of the chip should be printed to the console

Devices

Additional context The examples apparently work:

$ python3 ~/tools/nfc/python/example_get_uid.py 
Found PN532 with firmware version: 1.6
Waiting for RFID/NFC card...
.Found card with UID: ['0x4', '0x33', '0x8b', '0x2', '0xa1', '0x5d', '0x80']

Any help on how to get this to work?

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.