I am reading a value from a device over serial, and the return value has the format:
[Theoretical position in mm, Encoder position in mm], for example, b'\r#-0.001504,-0.001516\n'
I would like to format this return value and save the second value into an array. Does anyone have an idea how I might do this? Any suggestions are much appreciated.
Thanks.
New edit: This is my code and output. At this point I only need to extract the float value from this string.
ser.write(b'1POS?\r') #command to query positionpos = ser.readline() #read the positionpos_str = str(pos)pos_splt = pos_str.split(",") enc_pos = pos_splt[1]print(enc_pos)
Output: "-0.028970\n'"