bitbyt3r / dmx

Simple DMX driver using an RS485 adapter
MIT License
17 stars 12 forks source link

Better OS detection #4

Open ptrdvds opened 2 years ago

ptrdvds commented 2 years ago

I found that os detection does not work for Mac OS.

Please use:


import platform

if platform.system() == "Linux":
    import fcntl

def sender(self):
    while True:
        if not(self.enabled):
            continue
        if platform.system() == "Linux":
            fcntl.ioctl(self.desc, 0x5427) # Yeah, it's magic. Start Break (TIOCSBRK)
            time.sleep(0.0001)
            fcntl.ioctl(self.desc, 0x5428) # Yeah, it's magic. End Break (TIOCCBRK)
        else:
            self.ser.send_break(0.0001)

https://docs.python.org/3.8/library/platform.html

I tried to use a pull request, but it was to cumbersome.

Thanks for the code, it works for me, but with changes merged to master for OS detection, it easier to use. I am a mac and linux user :)

Chears Peter

ptrdvds commented 2 years ago

The platform test could also be used to set the default USB port for an OS. Eg.: For "Darwin" : '/dev/tty.usbserial-1420' For "Linux" : '/dev/ttyUSB0