nbits throws exception when nbits is smaller that bytes*8

Open Beginner friendly
#77 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
85/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
python
Domain
embedded-iot

Research direction

Reproduce the failure with the example in nonblocking.py, then inspect the transmit logic around lines 380-382 of adafruit_irremote.py and the reported failure at line 403. Done means transmit accepts nbits=32 when the byte list contains more bits, avoids IndexError, and limits transmission to the requested bit count.

Written by the indexing model from the issue text.

Description

The following code generates the following exception

Code:
ir_tx_code = [0x00, 0xff, 0xaa, 0x55, 0x5A]
encoder.transmit(pulseout, ir_tx_code, nbits=32)

Exception:
Traceback (most recent call last):
File "nonblocking.py", line 31, in
File "adafruit_irremote.py", line 403, in transmit
IndexError: index out of range

The internal documentation suggests that the number of bits can be limited with the nbits option.
When used it throws a exception.

Lines 380, 381, 382 of the library should catch and adjust to enforce the option.

Bruce

Dominant language
Python
Stars
29
Forks
31
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from adafruit/Adafruit_CircuitPython_IRRemote

All issues in adafruit/Adafruit_CircuitPython_IRRemote

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.