|
|
@@ -60,7 +60,8 @@ class GRBLHandler:
|
|
|
logger.debug(f"Sending G-Code command: {cmd}")
|
|
|
self.writer.write(f"{cmd}\n".encode())
|
|
|
await self.writer.drain()
|
|
|
- await self._process_response()
|
|
|
+ if not (await self._process_response()):
|
|
|
+ raise RuntimeError("Did not receive response from GRBL")
|
|
|
except RuntimeError as e:
|
|
|
logger.error(f"Failed to send G-Code commands: {str(e)}")
|
|
|
finally:
|
|
|
@@ -77,7 +78,9 @@ class GRBLHandler:
|
|
|
if self.writer:
|
|
|
self.writer.write(b"?\n")
|
|
|
await self.writer.drain()
|
|
|
+ # '?' command returns status report and 'ok'
|
|
|
response = await self._process_response()
|
|
|
+ response = response + await self._process_response()
|
|
|
|
|
|
if response and "Idle" in response:
|
|
|
logger.debug("Movement complete.\nContinuing...")
|
|
|
@@ -93,6 +96,7 @@ class GRBLHandler:
|
|
|
async def send_and_wait_gcode(self, commands: List[str], timeout_s=60):
|
|
|
"""Send GCODE commands and wait until machine is idle"""
|
|
|
await self.send_gcode(commands)
|
|
|
+ await asyncio.sleep(0.2) # Delay to allow GRBL to process commands
|
|
|
await self.wait_until_idle(timeout_s)
|
|
|
|
|
|
async def _process_response(self):
|