Skip to content

MFRC522 - sigsegv without irqPin #114

@jeffrson

Description

@jeffrson

Describe the bug
I want to MFRC522 without an IrqPin. The program stops with SigSegv

To Reproduce
Steps to reproduce the behavior:

  1. Run program https://periph.io/device/mf-rc522/
...
 rfid, err = mfrc522.NewSPI(port, gpioResetPin, nil, mfrc522.WithSync())
...
  1. Run it.
  2. 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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions