WMT-GmbH / pn532

no_std implementation of the Pn532 protocol using embedded_hal traits
Apache License 2.0
20 stars 19 forks source link

RFC: Add basic HSU implementation #2

Closed plaes closed 2 years ago

plaes commented 3 years ago

This is a basic example on getting the HSU interface work on Linux using the Serialport-rs crate.

dimpolo commented 3 years ago

This looks very good, thank you!

I'll give this a try on hardware on Monday.

Until then could you move the code into a examples folder in the top level crate and declare the dependecies as dev-dependencies?

plaes commented 3 years ago

I moved it under the example and added bunch of TODO items. I don't know when I have time to look into this again...

dimpolo commented 3 years ago

Code looks good to me, thank you. Not sure why, but I can't get any kind of response from my hardware. Did you have any success?

plaes commented 3 years ago

Code looks good to me, thank you. Not sure why, but I can't get any kind of response from my hardware. Did you have any success?

Indeed, it doesn't work out of the box when trying with newly connected device. Apparently I never unplugged my device after playing with libnfc.

After running nfc-list -v with appropriate configuration, it starts working with the current example...

And here's the communication log from libnfc:

LIBNFC_LOG_LEVEL=3 nfc-list -v
debug   libnfc.bus.uart Serial port speed requested to be set to 115200 baud.
debug   libnfc.chip.pn53x   Diagnose
debug   libnfc.chip.pn53x   Timeout value: 500
debug   libnfc.bus.uart TX: 55 55 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
debug   libnfc.chip.pn53x   SAMConfiguration
debug   libnfc.chip.pn53x   Timeout value: 1000
debug   libnfc.bus.uart TX: 00 00 ff 03 fd d4 14 01 17 00 
debug   libnfc.bus.uart RX: 00 00 ff 00 ff 00 
debug   libnfc.chip.pn53x   PN53x ACKed
debug   libnfc.bus.uart RX: 00 00 ff 02 fe 
debug   libnfc.bus.uart RX: d5 15 
debug   libnfc.bus.uart RX: 16 00 
debug   libnfc.bus.uart TX: 00 00 ff 09 f7 d4 00 00 6c 69 62 6e 66 63 be 00 
debug   libnfc.bus.uart RX: 00 00 ff 00 ff 00 
debug   libnfc.chip.pn53x   PN53x ACKed
debug   libnfc.bus.uart RX: 00 00 ff 09 f7 
debug   libnfc.bus.uart RX: d5 01 
debug   libnfc.bus.uart RX: 00 6c 69 62 6e 66 63 
debug   libnfc.bus.uart RX: bc 00 
debug   libnfc.chip.pn53x   GetFirmwareVersion
debug   libnfc.bus.uart TX: 00 00 ff 02 fe d4 02 2a 00 
debug   libnfc.bus.uart RX: 00 00 ff 00 ff 00 
debug   libnfc.chip.pn53x   PN53x ACKed
debug   libnfc.bus.uart RX: 00 00 ff 06 fa 
debug   libnfc.bus.uart RX: d5 03 
debug   libnfc.bus.uart RX: 32 01 06 07 
debug   libnfc.bus.uart RX: e8 00 
dimpolo commented 2 years ago

Thanks for the hint! I got it working now. I'll merge this as is, and update the example once I updated the lib.