From 325b0c229b6d7d5bec80977c2f29e5606f1a6ea1 Mon Sep 17 00:00:00 2001 From: Jens Ullmert Date: Wed, 27 Jul 2022 16:49:25 +0200 Subject: [PATCH] respeed --- Python/sock.py | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/Python/sock.py b/Python/sock.py index 8d9941a..7bdf269 100644 --- a/Python/sock.py +++ b/Python/sock.py @@ -56,7 +56,7 @@ DMXRST = 88.0 # typical 88µs DMXBRK = 8.0 # 8µs (min) to 1s (max) # DMX Sequence sleep [ms]/float -DMXSLP = 5000.0 #250.0 # 0µs (min) to 1s (max) +DMXSLP = 250.0 # 0µs (min) to 1s (max) # Buffer for RDM DMXRDM = "" @@ -101,8 +101,8 @@ def sendDMX(data): global DMXRDM while True: - with serial.Serial('/dev/serial0', baudrate=250000, timeout=1, stopbits=serial.STOPBITS_TWO, bytesize=8) as DMXSER:# UART configuration and definition - DMXSER.cancel_read() + with serial.Serial('/dev/serial0', baudrate=250000, timeout=DMXSLP, stopbits=serial.STOPBITS_TWO, bytesize=8) as DMXSER:# UART configuration and definition + #DMXSER.cancel_read() # GPIO_18 to switch RS-485 driver (IC1) to TX-mode GPIO.output(18, GPIO.HIGH) @@ -111,25 +111,20 @@ def sendDMX(data): DMXSER.send_break(DMXRST / 1000000.0) # break-time - #-----------------------------------------------------------------------time.sleep(DMXBRK / 1000000.0) - time.sleep(0.1) + time.sleep(DMXBRK / 1000000.0) # send complete data array DMXSER.write(bytearray(DMXDATA)) + + + # GPIO_18 to switch RS-485 driver (IC1) to RX-mode DMXSER.reset_input_buffer() GPIO.output(18, GPIO.LOW) # Sleep between TX packages, use time to get RDM packages - #DMXRDM = "" - #DMXRDMFLAG = False - - time.sleep(2) - #-----------------------------------------------------------------------DMXSER.timeout(DMXSLP / 1000.0) # between 0 - 1 sec - DMXRDM = DMXSER.read(size=10) - print("input", DMXRDM) - #DMXRDMFLAG = True + DMXRDM = DMXSER.read(400)