Help with a serial response in python
$10-30 USD
Paid on delivery
I have a response i am parsing that has two lines. I a parsing the first line no problem but it leaves junk in the input buffer for next time
Its the code:
# Poll GRBL for parser status 1 second max
tries = 0
while tries < 2:
[login to view URL]() # Flush startup text in serial input
[login to view URL]("$G\n".encode())
pstatus_out = [login to view URL]().decode().strip() # Wait for GRBL response with status return message
if pstatus_out != "":
if 'error' in [login to view URL](): # Check For Error
error_3 = error_2 # Rotate Error Log
error_2 = error_1 # Rotate Error Log
error_1 = "GRBL " + [login to view URL]() # Set error 1 to current error
grbl_motion, grbl_units, grbl_spindle, grbl_coolant = parse_grbl_parser(pstatus_out)
[login to view URL]() # Flush startup text in serial input
break
sleep(.2)
tries += 1
if tries >= 2:
error_3 = error_2 # Rotate Error Log
error_2 = error_1 # Rotate Error Log
error_1 = "GRBL Timeout Parser Status" # Set error 1 to current error
grbl_motion, grbl_units, grbl_spindle, grbl_coolant = parse_grbl_parser(pstatus_out)
The Function is
def parse_grbl_parser(pstatus_out):
try:
pstatus_out = [login to view URL](":", 1)[1].replace("]", "")
pstatus_out = [login to view URL](" ")
grbl_motion = pstatus_out[0]
grbl_units = pstatus_out[3]
grbl_spindle = pstatus_out[6]
grbl_coolant = pstatus_out[7]
except:
grbl_motion = "Err"
grbl_units = "Err"
grbl_spindle = "Err"
grbl_coolant = "Err"
return grbl_motion, grbl_units, grbl_spindle, grbl_coolant
The response is
[GC:G0 G54 G17 G20 G90 G94 M5 M9 T0 F0.0 S0]
ok
Project ID: #29417172
About the project
3 freelancers are bidding on average $33 for this job
Hi there, I have read your project description and I am confident about your project I can do perfectly. Please leave a message on my chat so we can discuss the budget and deadline of the project. Thanks. regard , fa More