Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from serial import Serial
- from time import sleep
- ser = serial.Serial("/dev/ttyS2", 115200, timeout = 1)
- def getTFminiData(broken):
- while True:
- count = ser.in_waiting
- if count >= 9:
- recv = ser.read(9)
- ser.reset_input_buffer()
- if recv[0] == 'Y' and recv[1] == 'Y': # 0x59 is 'Y'
- low = int(recv[2].encode('hex'), 16)
- high = int(recv[3].encode('hex'), 16)
- distance = low + high * 256
- print("This is your distance away from the Lidar: ", distance)
- sleep(0.5)
- getTFminiData(2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement