rearrange serial
This commit is contained in:
parent
bf653c4d46
commit
97f07b65ce
@ -101,9 +101,18 @@ def sendDMX(data):
|
||||
global DMXRDM
|
||||
global DMXSLP
|
||||
|
||||
# UART configuration and definition
|
||||
DMXSER = serial.Serial('/dev/serial0', baudrate=250000, timeout=(DMXSLP/1000.0), stopbits=serial.STOPBITS_TWO, bytesize=8)
|
||||
|
||||
while True:
|
||||
with serial.Serial('/dev/serial0', baudrate=250000, timeout=(DMXSLP/1000.0), stopbits=serial.STOPBITS_TWO, bytesize=8) as DMXSER:# UART configuration and definition
|
||||
#DMXSER.cancel_read()
|
||||
DMXSER.reset_input_buffer()
|
||||
GPIO.output(18, GPIO.LOW)
|
||||
|
||||
wr = bytearray(DMXDATA)
|
||||
|
||||
print("start read for ", DMXSLP, "ms")
|
||||
DMXRDM = DMXSER.read(400)
|
||||
print("end read, input is ", DMXRDM)
|
||||
|
||||
# GPIO_18 to switch RS-485 driver (IC1) to TX-mode
|
||||
GPIO.output(18, GPIO.HIGH)
|
||||
@ -115,21 +124,11 @@ def sendDMX(data):
|
||||
time.sleep(DMXBRK / 1000000.0)
|
||||
|
||||
# send complete data array
|
||||
DMXSER.write(bytearray(DMXDATA))
|
||||
DMXSER.write(wr)
|
||||
|
||||
|
||||
|
||||
|
||||
# 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
|
||||
print("start read for ", DMXSLP, "ms")
|
||||
DMXRDM = DMXSER.read(400)
|
||||
print("end read, input is ", DMXRDM)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user