Total Complexity | 3 |
Total Lines | 38 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | """ |
||
2 | * PyDMXControl: A Python 3 module to control DMX using uDMX. |
||
3 | * Featuring fixture profiles, built-in effects and a web control panel. |
||
4 | * <https://github.com/MattIPv4/PyDMXControl/> |
||
5 | * Copyright (C) 2018 Matt Cowley (MattIPv4) ([email protected]) |
||
6 | """ |
||
7 | |||
8 | from serial import Serial |
||
9 | import time |
||
10 | |||
11 | from ._transmittingController import transmittingController |
||
12 | |||
13 | |||
14 | class SerialController(transmittingController): |
||
15 | |||
16 | def __init__(self, port, *args, **kwargs): |
||
17 | """ |
||
18 | Serial port interface requires port string to establish connection, e.g. 'COM1' for |
||
19 | windows operating systems. |
||
20 | |||
21 | Parameters |
||
22 | ---------- |
||
23 | port: Serial port string. |
||
24 | """ |
||
25 | self._port = Serial(port=port, baudrate=250000, bytesize=8, stopbits=2) |
||
26 | super().__init__(*args, **kwargs) |
||
27 | |||
28 | def close(self): |
||
29 | # Close serial port |
||
30 | self._port.close() |
||
31 | super().close() |
||
32 | |||
33 | def _send_data(self): |
||
34 | data = [0] + self.get_frame() |
||
35 | self._port.send_break(100e-6) |
||
36 | time.sleep(10e-6) |
||
37 | self._port.write(bytearray(data)) |
||
38 |