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

doesn't really work #4

Closed
ildar opened this issue May 1, 2018 · 3 comments
Closed

doesn't really work #4

ildar opened this issue May 1, 2018 · 3 comments

Comments

@ildar
Copy link

ildar commented May 1, 2018

Hi!
I reviewed both this fork and @socram8888 's pull request.
Fixed building with cmake, see my repo
Still attempring to run yields disappointing results:

 $ LIBNFC_LOG_LEVEL=3 ./nfc-anticol
info	libnfc.config	Unable to open file: /etc/nfc/libnfc.conf
debug	libnfc.config	key: [device.allow_autoscan], value: [false]
info	libnfc.config	Unknown key in config line: device.allow_autoscan = false
debug	libnfc.config	key: [device.log_level], value: [3]
info	libnfc.config	Unknown key in config line: device.log_level = 3
debug	libnfc.config	key: [device.name], value: [MFRC522]
debug	libnfc.config	key: [device.connstring], value: [rc522_uart:/dev/ttyUSB0]
debug	libnfc.general	log_level is set to 3
debug	libnfc.general	allow_autoscan is set to true
debug	libnfc.general	allow_intrusive_scan is set to false
debug	libnfc.general	1 device(s) defined by user
debug	libnfc.general	  #0 name: "MFRC522", connstring: "rc522_uart:/dev/ttyUSB0"
debug	libnfc.driver.rc522_uart	Attempt to open: /dev/ttyUSB0.
debug	libnfc.driver.rc522_uart	Attempting to establish a connection at 9600 bps.
debug	libnfc.bus.uart	Serial port speed requested to be set to 9600 baud.
debug	libnfc.bus.uart	TX: b7
debug	libnfc.bus.uart	RX: 12
debug	libnfc.chip.rc522	RD 37: 12
debug	libnfc.chip.rc522	Aborting self test for unknown version 12.
debug	libnfc.bus.uart	TX: 01
debug	libnfc.bus.uart	RX: 01
debug	libnfc.bus.uart	TX: 2f
debug	libnfc.chip.rc522	WR 01: 2f
debug	libnfc.driver.rc522_uart	Restoring baud rate to default of 9600 bps.
debug	libnfc.bus.uart	Serial port speed requested to be set to 9600 baud.
debug	libnfc.bus.uart	TX: 81
debug	libnfc.bus.uart	RX: 20
debug	libnfc.chip.rc522	RD 01: 20
debug	libnfc.driver.rc522_uart	Upgrading baud rate to user-specified 115200 bps.
debug	libnfc.bus.uart	Serial port speed requested to be set to 115200 baud.
debug	libnfc.bus.uart	TX: 1f
debug	libnfc.bus.uart	RX: 00
debug	libnfc.driver.rc522_uart	rc522_uart_write ack does not match (sent 1F, received 00)
error	libnfc.chip.rc522	Unable to write register 1F!
debug	libnfc.driver.rc522_uart	Attempting to establish a connection at 115200 bps.
debug	libnfc.bus.uart	Serial port speed requested to be set to 115200 baud.
debug	libnfc.bus.uart	TX: b7
debug	libnfc.bus.uart	RX: 00
debug	libnfc.chip.rc522	RD 37: 00
debug	libnfc.chip.rc522	Aborting self test for unknown version 00.
debug	libnfc.bus.uart	TX: 01
debug	libnfc.bus.uart	RX: 00
debug	libnfc.driver.rc522_uart	rc522_uart_write ack does not match (sent 01, received 00)
error	libnfc.chip.rc522	Unable to write register 01!
debug	libnfc.driver.rc522_uart	Could not connect with RC522 at 9600 or 115200 bps.
debug	libnfc.bus.uart	TX: 01
debug	libnfc.bus.uart	RX: 00
debug	libnfc.driver.rc522_uart	rc522_uart_write ack does not match (sent 01, received 00)
error	libnfc.chip.rc522	Unable to write register 01!
debug	libnfc.general	Unable to open "rc522_uart:/dev/ttyUSB0".
nfc-anticol: ERROR: Error opening NFC reader

This is the current state of the port, right?

@socram8888
Copy link
Contributor

socram8888 commented May 1, 2018

I cannot talk about this fork, but on mine I got as far as nfc-anticoll working, with 115200 bps working too. I am guessing that you may have run into a hardware issue I am experiencing as well which apparently affects some fake/counterfeit MFRC522 chips.

For the development of the '522 patch, I was using a FM17522 chip, which is a compatible version made by Fudan with version register set to 0x88. Official MFRC522 have two different version codes 0x91 and 0x92 (rc522-internal.h).

Yours seem to have a completely different version code (0x12), which probably has some sorta of hardware bug with anything different than 9600bps.

Seeing this was never going to be accepted upstream, I began developing a MFRC522 driver in userland using Python, and while it worked just fine with the Fudan chip, I am experiencing issues with a fake, completely unbranded chip (like, it doesn't even have anything other than the dot marking pin 1) any time I try to change from 9600 to anything else. So there are odds that it's not related to this port, but more like a hardware issue.

Could you try specifying baud rate as 9600, so it uses the default baud rate, and trying again?

@socram8888
Copy link
Contributor

socram8888 commented May 1, 2018

Wait no. For some reason @ehkom modified the rc522-uart driver and broke baudrate changing: https://github.com/ehkom/libnfc/blob/master/libnfc/drivers/rc522_uart.c#L325-L341

You are supposed to write the new baud rate to the MFRC522, and then change the UART baudrate. Otherwise, the MFRC522 keeps trying to read commands with a baud rate different to the one the PC is sending them at.

Also ignoring errors occured when changing UART speed is not a good idea. If that fails, you'll end up with an UART running at a different speed than the MFRC522, with the rest of the library having no idea and trying to use it in an undefined state.

@ildar
Copy link
Author

ildar commented May 2, 2018 via email

@ildar ildar closed this as completed May 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants