Skip to content

RX Fix to interrupts #24

Merged
rightup merged 15 commits intodevfrom
fix/timing
Dec 13, 2025
Merged

RX Fix to interrupts #24
rightup merged 15 commits intodevfrom
fix/timing

Conversation

@rightup
Copy link
Owner

@rightup rightup commented Dec 13, 2025

This PR fixes interrupt handling in the SX1262 LoRa radio driver by implementing thread-safe interrupt processing and refining RX interrupt logic. The changes migrate from gpiozero to python-periphery GPIO library, introduce a trampoline pattern for bridging GPIO interrupts to the asyncio event loop, and improve distinction between terminal and progress RX interrupts to prevent spurious wake-ups.

Key changes:

Implemented thread-safe interrupt trampoline pattern that schedules handlers on the event loop via call_soon_threadsafe
Refactored RX interrupt handling to distinguish terminal interrupts (RX_DONE, CRC_ERR, TIMEOUT, HEADER_ERR) from progress interrupts (PREAMBLE, SYNC, HEADER_VALID)
Migrated from gpiozero to python-periphery GPIO API with centralized GPIO manager shared between driver layers

…ggers and ensure callback execution on rising edges
…rupt handler and improving logging for CAD operations
…t trampoline for GPIO interrupts and capturing the event loop for thread-safe operations.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes interrupt handling in the SX1262 LoRa radio driver by implementing thread-safe interrupt processing and refining RX interrupt logic. The changes migrate from gpiozero to python-periphery GPIO library, introduce a trampoline pattern for bridging GPIO interrupts to the asyncio event loop, and improve distinction between terminal and progress RX interrupts to prevent spurious wake-ups.

Key changes:

  • Implemented thread-safe interrupt trampoline pattern that schedules handlers on the event loop via call_soon_threadsafe
  • Refactored RX interrupt handling to distinguish terminal interrupts (RX_DONE, CRC_ERR, TIMEOUT, HEADER_ERR) from progress interrupts (PREAMBLE, SYNC, HEADER_VALID)
  • Migrated from gpiozero to python-periphery GPIO API with centralized GPIO manager shared between driver layers

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

File Description
src/pymc_core/node/dispatcher.py Removed debug logging statements from packet reception path
src/pymc_core/hardware/sx1262_wrapper.py Added interrupt trampoline for thread-safety, refactored RX interrupt handling to distinguish terminal vs progress interrupts, improved CAD result storage, fixed TX timeout calculation, changed setRx to request method calls, and corrected IRQ clearing order
src/pymc_core/hardware/lora/LoRaRF/SX126x.py Migrated from gpiozero to python-periphery API (off/on → write(False/True), value → read()), integrated centralized GPIO manager via set_gpio_manager(), removed local GPIO pin tracking
src/pymc_core/hardware/gpio_manager.py Added EdgeEvent import, updated edge detection to consume events from kernel queue via read_event(), added Any type import (unused)
Comments suppressed due to low confidence (1)

src/pymc_core/hardware/gpio_manager.py:12

  • Import of 'Any' is not used.
from typing import Any, Callable, Dict, Optional

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@rightup rightup merged commit 4758ed0 into dev Dec 13, 2025
@rightup rightup deleted the fix/timing branch December 13, 2025 22:49
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

Successfully merging this pull request may close these issues.

2 participants