This commit is contained in:
xyj 2023-12-09 14:48:37 +08:00
parent 20cfabef91
commit 5e3f63de37
2 changed files with 3 additions and 2 deletions

View File

@ -19,7 +19,7 @@ if __name__ == '__main__':
windspeed_send = '04 03 00 00 00 02 C4 5E' # 风速查询指令
winddirection_send = '05 03 00 00 00 02 C5 8F' # 风向查询指令
ser = serial.Serial("/dev/ttyS2", 9600)
# 发送的数据转为2进制b'\x01\x03\x00\x00\x00\x02\xc4\x0b'
temp_send = bytes.fromhex(temp_send)
@ -33,6 +33,7 @@ if __name__ == '__main__':
winddirection_send = bytes.fromhex(winddirection_send)
while True:
try:
ser = serial.Serial("/dev/ttyS2", 9600)
# if ser.is_open:
ser.write(temp_send)
time.sleep(1)

View File

@ -23,7 +23,6 @@ def t():
windspeed_send = '04 03 00 00 00 02 C4 5E' # 风速查询指令
winddirection_send = '05 03 00 00 00 02 C5 8F' # 风向查询指令
ser = serial.Serial("/dev/ttyS2", 9600)
# 发送的数据转为2进制b'\x01\x03\x00\x00\x00\x02\xc4\x0b'
temp_send = bytes.fromhex(temp_send)
@ -37,6 +36,7 @@ def t():
winddirection_send = bytes.fromhex(winddirection_send)
while True:
try:
ser = serial.Serial("/dev/ttyS2", 9600)
# if ser.is_open:
ser.write(temp_send)
time.sleep(1)