You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Sep 20, 2023. It is now read-only.
Describe the bug
I have two different typs of tags, a chip card and stickers. When I use the chip card, the behavior is as expected. When I try to use the stickers I get the error "mfrc522: wrong number of bits 4" with changing number of bits between 4 and 7.
I build a small example to show my settings. I tried "commands.PICC_AUTHENT1B" as well as "commands.PICC_AUTHENT1A" for authentication mode.
With my smartphone I'm able to read both tags, with the MIFARE Classic Tool from IKARUS Projects. So the default key (FFFFFFFFFFFF) seem to be correct. I'm also able to write data to both tags with this app.
I already tried a lower and a higher antenna gain without success.
I also tried to use a different reader on another raspberry with the same result.
I will be happy for any help, thanks.
To Reproduce
Steps to reproduce the behavior:
Run program
package main
import (
"fmt""periph.io/x/periph/conn/gpio""periph.io/x/periph/conn/gpio/gpioreg""periph.io/x/periph/conn/spi""periph.io/x/periph/conn/spi/spireg""periph.io/x/periph/experimental/devices/mfrc522""periph.io/x/periph/experimental/devices/mfrc522/commands""periph.io/x/periph/host""time"
)
// mfrc522 rfid devicevarrfid*mfrc522.Dev// spi portvarport spi.PortCloser// pins used for rest and irqconst (
resetPin="P1_22"// GPIO 25irqPin="P1_18"// GPIO 24
)
/*Setup inits and starts hardware.*/funcsetup() {
varerrerror// guarantees all drivers are loaded.if_, err=host.Init(); err!=nil {
fmt.Println(err)
}
// get the first available spi port (empty string).port, err=spireg.Open("")
iferr!=nil {
fmt.Println(err)
}
// get GPIO rest pin from its namevargpioResetPin gpio.PinOut=gpioreg.ByName(resetPin)
ifgpioResetPin==nil {
fmt.Println("Failed to find %v", resetPin)
}
// get GPIO irq pin from its namevargpioIRQPin gpio.PinIn=gpioreg.ByName(irqPin)
ifgpioIRQPin==nil {
fmt.Println("Failed to find %v", irqPin)
}
rfid, err=mfrc522.NewSPI(port, gpioResetPin, gpioIRQPin, mfrc522.WithSync())
iferr!=nil {
fmt.Println(err)
}
// setting the antenna signal strength, signal strength from 0 to 7rfid.SetAntennaGain(5)
fmt.Println("Started rfid reader.")
}
funcstringIntoByte16(strstring) [16]byte {
vardata [16]bytecopy(data[:], str) // copy already checks length of strreturndata
}
funcmain() {
setup()
// trying to read UIDdata, err:=rfid.ReadUID(5*time.Second)
iferr!=nil {
fmt.Println(err)
} else {
fmt.Println(data)
}
// trying to write dataerr=rfid.WriteCard(5*time.Second, byte(commands.PICC_AUTHENT1B), 2, 0, stringIntoByte16("Hallo Welt"), mfrc522.DefaultKey)
iferr!=nil {
fmt.Println(err)
} else {
fmt.Println("Write OK")
}
// trying to read datadata, err=rfid.ReadCard(5*time.Second, commands.PICC_AUTHENT1A, 2, 0, mfrc522.DefaultKey)
iferr!=nil {
fmt.Println(err)
} else {
fmt.Println(data)
}
}
Run it.
See error
Started rfid reader.
mfrc522: wrong number of bits 4
mfrc522: wrong number of bits 5
mfrc522: wrong number of bits 4
Expected behavior
Started rfid reader.
[18 100 14 52 76]
Write OK
[72 97 108 108 111 32 87 101 108 116 0 0 0 0 0 0]
Platform (please complete the following information):
OS: Raspbian GNU/Linux 10 (buster)
Board: Raspberry PI 3B+
Additional context
I read out the information of both tags, the only difference I see is the UID.
The text was updated successfully, but these errors were encountered:
I also added documentation as far as my knowledge goes.
Tried to upload a picture as well, but get message "Uploads are disabled. File uploads require push access to this repository."
To be honest, I do not know if it really was the power supply, just read somewhere on the web, that some hardware can be sensitive. So it was just a guess, I changed it and it worked. So I have no way for diagnose.
But still, I added a hint in the documentation.
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Describe the bug
I have two different typs of tags, a chip card and stickers. When I use the chip card, the behavior is as expected. When I try to use the stickers I get the error "mfrc522: wrong number of bits 4" with changing number of bits between 4 and 7.
I build a small example to show my settings. I tried "commands.PICC_AUTHENT1B" as well as "commands.PICC_AUTHENT1A" for authentication mode.
With my smartphone I'm able to read both tags, with the MIFARE Classic Tool from IKARUS Projects. So the default key (FFFFFFFFFFFF) seem to be correct. I'm also able to write data to both tags with this app.
I already tried a lower and a higher antenna gain without success.
I also tried to use a different reader on another raspberry with the same result.
I will be happy for any help, thanks.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Platform (please complete the following information):
Additional context
I read out the information of both tags, the only difference I see is the UID.
The text was updated successfully, but these errors were encountered: