From c36f42ea9bb6588635745e02e0667462aba34e95 Mon Sep 17 00:00:00 2001 From: Jens Ullmert Date: Wed, 27 Jul 2022 15:03:10 +0200 Subject: [PATCH] MOD: run the script --- Python/sock.py | 44 ++++++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/Python/sock.py b/Python/sock.py index 67b3e61..573aad8 100644 --- a/Python/sock.py +++ b/Python/sock.py @@ -100,32 +100,32 @@ def sendDMX(data): global DMXRDMFLAG global DMXRDM - while False:#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() - # GPIO_18 to switch RS-485 driver (IC1) to TX-mode - GPIO.output(18, GPIO.HIGH) + with serial.Serial('/dev/serial0', baudrate=250000, timeout=1, stopbits=serial.STOPBITS_TWO, bytesize=8) as DMXSER:# UART configuration and definition + DMXSER.cancel_read() - # send reset - DMXSER.send_break(DMXRST / 1000000.0) + # GPIO_18 to switch RS-485 driver (IC1) to TX-mode + GPIO.output(18, GPIO.HIGH) - # break-time - time.sleep(DMXBRK / 1000000.0) + # send reset + DMXSER.send_break(DMXRST / 1000000.0) - # send complete data array - DMXSER.write(bytearray(DMXDATA)) + # break-time + time.sleep(DMXBRK / 1000000.0) - # GPIO_18 to switch RS-485 driver (IC1) to RX-mode - DMXSER.reset_input_buffer() - GPIO.output(18, GPIO.LOW) + # send complete data array + DMXSER.write(bytearray(DMXDATA)) - # Sleep between TX packages, use time to get RDM packages - DMXRDM = "" - DMXRDMFLAG = False - DMXSER.timeout(DMXSLP / 1000.0) # between 0 - 1 sec - DMXRDM = DMXSER.readlines() - DMXRDMFLAG = True + # 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 + DMXSER.timeout(DMXSLP / 1000.0) # between 0 - 1 sec + DMXRDM = DMXSER.readlines() + DMXRDMFLAG = True @@ -339,3 +339,7 @@ GPIO.output(4, GPIO.LOW) asyncio.get_event_loop().run_until_complete( websockets.serve(websworker, port=6789)) asyncio.get_event_loop().run_forever() + +print("start") +while True: + sendDMX(DMXDATA)