-
Notifications
You must be signed in to change notification settings - Fork 50
Open
Description
Describe the bug
I want to MFRC522 without an IrqPin. The program stops with SigSegv
To Reproduce
Steps to reproduce the behavior:
- Run program https://periph.io/device/mf-rc522/
...
rfid, err = mfrc522.NewSPI(port, gpioResetPin, nil, mfrc522.WithSync())
...- Run it.
- See error
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x30 pc=0xed15c]
goroutine 33 [running]:
periph.io/x/devices/v3/mfrc522/commands.(*LowLevel).WaitForEdge.func1()
/home/lyra/go/pkg/mod/periph.io/x/devices/v3@v3.7.4/mfrc522/commands/low_level.go:201 +0x58
created by periph.io/x/devices/v3/mfrc522/commands.(*LowLevel).WaitForEdge in goroutine 1
/home/lyra/go/pkg/mod/periph.io/x/devices/v3@v3.7.4/mfrc522/commands/low_level.go:199 +0x98
Expected behavior
Well, should work without that error
Platform (please complete the following information):
- OS: Ubuntu 22.04.5 LTS (Jammy Jellyfish)
- Board Luckfox Lyra Ultra
- Device MFRC522
Additional context
Does it access irqPin? Also, despite the comment ("If IRQ pin is not set, then always returns false immediately.") I cannot see where it checks irqPin and leaves.
func (r *LowLevel) WaitForEdge(timeout time.Duration) error {
irqChannel := make(chan bool)
go func() {
defer close(irqChannel)
irqChannel <- r.irqPin.WaitForEdge(timeout)
}()
...
Edit: BTW, I cannot use some "fake" IRQ, because the pin cannot be configured:
sysfs-gpio (GPIO44): doesn't support pull-up/pull-down
Edit2: There's another problem in periph.io/x/devices/v3@v3.7.4/mfrc522/commands/low_level.go:ClearInterrupt(), where r.irqPin is used without check as well.
Metadata
Metadata
Assignees
Labels
No labels