I've really been trying to figure this out on my own, reading into the re and struct modules, but I can't seem to figure out how to format the data the way I want.
It's been through a few iterations, but heres the code I currently have:
Code: Select all
prop_board_in = uart.readline()
if prop_board_in is not None:
# convert bytearray to string
prop_board_in_string = ''.join([chr(b) for b in prop_board_in ])
print(prop_board_in_string, end="")
Code: Select all
motion "2920 -118 7526 -29 -13 -3"
motion "2923 -105 7552 -28 -15 -2"
motion "2925 -106 7548 -27 -9 -1"
motion "2915 -95 7528 -27 -11 2"
Code: Select all
b'motion "2905 -149 7525 -29 -11 3"\n'
Code: Select all
x1 = 2905
x2 = -149
y1 = 7525
y2 = 29
z1 = -11
z1 = 3
I feel like I could do something with .split(), or maybe there's some format module that could take out the quotes and spaces. I imagine I'd have to populate an array, then iterate through it, adding each value to a different variable. I'd probably want to convert the values it int, too.
Either way, I'd definitely appreciate advice with this one.