MattIPv4 / MattIPv4/PyDMXControl

val in self.channels.items() can be float

Open
#55 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
143
Forks
23
PR merge metrics
No merged PRs in 30d

Description

Hi fellow,

thanks a looot for your library. Real nice work.

I ran into an issue (can't tell you the origin), but by using a constant stream following line in _Controller.py might create a float, which later on will crash the program:
```
# Get all channels values
for key, val in self.channels.items():
# If channel in frame
if key - first < len(self.__frame):
self.__frame[key - first] = int(val[0])`
```

i placed an int() around the val[0]. Not sure if that's in general a good idea.

but it fixed the issue, that otherwise at this call would break the runtime.

````
def _transmit(self, frame: List[int], first: int):
# Convert to a bytearray and pad the start of the frame
# We're transmitting direct DMX data here, so a frame must start at channel 1, but can end early
try:
data = bytearray(([0] * (first - 1)) + frame)
# The first byte in the type, and is `0` for normal DMX data
data.insert(0, 0)

# Write
self.__device.send_break(100e-6)
sleep(10e-6)
self.__device.write(data)
except:
print("bad request")`
```

as you see I made a try / except for myself.

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.

Research direction

Start in _Controller.py at the channel-value loop and inspect how values from self.channels.items() reach _transmit. Reproduce the constant-stream case that produces a float, then verify the chosen handling preserves valid DMX frame data and prevents the bytearray conversion from failing.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
embedded-iot
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.