Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
marm1te opened this issue Jan 3, 2024 · 3 comments
Open

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

marm1te opened this issue Jan 3, 2024 · 3 comments

Comments

@marm1te
Copy link

marm1te commented Jan 3, 2024

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.
@combs
Copy link

combs commented Mar 5, 2024

just chiming in as a user of the library--the RGB values going in to PyDMXControl should always be ints in your code... I think the author would have to add a lot of extra code throughout the library to handle other variable types.

@MattIPv4
Copy link
Owner

MattIPv4 commented Mar 5, 2024

If you can point to somewhere within PyDMXControl that is resulting in floats being stored in channels, please let me know. But otherwise yes, the library expects to be working with ints, DMX doesn't understand floats.

@marm1te
Copy link
Author

marm1te commented May 22, 2024

Hi, sorry I just relaunched the work on my project. Will inform you, if I find out, why there is a float generated in the controller.

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

No branches or pull requests

3 participants