adafruit / adafruit/Adafruit_CircuitPython_MCP2515
Using only one mask produces a lot of print spam
- Dominant language
- Python
- Stars
- 29
- Forks
- 16
- PR merge metrics
- No merged PRs in 30d
Description
Please see test case:
```python
import digitalio
import board
import busio
import adafruit_mcp2515
cs = digitalio.DigitalInOut(board.CAN_CS)
cs.switch_to_output()
spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
matches = [
adafruit_mcp2515.Match(0x060, mask = 0x7F0)
]
# for me, the first 3 bits correspond to priority
# the next 4 bits are used for the device number
# the last 4 correspond to the message type.
# each device except the central controller can then only need to listen to a subset of matches that correspond to it's
# device number
mcp = adafruit_mcp2515.MCP2515(spi, cs, baudrate=1000000)
received_messages = []
while True:
# If there's a better way to specify mask, let me know.
with mcp.listen(matches, timeout=.00001) as listener:
next_message = listener.receive()
while next_message is not None:
received_messages.append(next_message)
print("adding message")
next_message = listener.receive()
# just to prove the point
while len(received_messages) > 0:
received_messages.pop()
```
This produces a LOT of spam on the serial log.
intended functionality would be: the mcp2515 can be used with one mask without something printing.
Adding ANOTHER mask removes the print.
```python
import digitalio
import board
import busio
import adafruit_mcp2515
cs = digitalio.DigitalInOut(board.CAN_CS)
cs.switch_to_output()
spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
matches = [
adafruit_mcp2515.Match(0x060, mask=0x7F0), # I think this might be what i want? i cant test.
adafruit_mcp2515.Match(0x060, mask=0x06F) # I think this may be what I want... but I cant test?
]
# for me, the first 3 bits correspond to priority
# the next 4 bits are used for the device number
# the last 4 correspond to the message type.
# each device except the central controller can then only need to listen to a subset of matches that correspond to it's
# device number
mcp = adafruit_mcp2515.MCP2515(spi, cs, baudrate=1000000)
received_messages = []
while True:
# If there's a better way to specify mask, let me know.
with mcp.listen(matches, timeout=.00001) as listener:
next_message = listener.receive()
while next_message is not None:
received_messages.append(next_message)
print("adding message")
next_message = listener.receive()
# just to prove the point
while len(received_messages) > 0:
received_messages.pop()
```
this seems to be the problem... but I think it may point to a larger issue.
https://github.com/adafruit/Adafruit_CircuitPython_MCP2515/blob/a50e24362154677d262e643c8edec9237f810a77/adafruit_mcp2515/__init__.py#L917
Lastly, adding some documentation to Mask would be pretty cool.
https://docs.circuitpython.org/projects/mcp2515/en/latest/api.html#adafruit_mcp2515.canio.Match
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with adafruit_mcp2515/__init__.py around the linked line and review the Match mask behavior in the API documentation. Reproduce the provided single-mask and two-mask cases, then verify that using one mask no longer causes unexpected serial output and that the Match documentation explains mask usage.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- documentation, embedded-iot
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100