Hi there, I'm trying to establish a connection to grbl on the X32 blackbox through the serial port. I haven't found anything that works out of the box. I'm not sure what I am missing. Maybe you could help me debug this, so I can have a working sample on GitHub that we can refer users too. Right now, it's stuck at "Sending: b'\r\n\r\n'" My basic understanding of initialization would be something like this: Wake up grbl → '\r\n\r\n' Reset errors → '$X' Homing → '$H' Send G-Code → 'G1 X100 Y100 Z0.0 F5000' The project is on GitHub: grbl-python/demo.py at main · dottenbr/grbl-python (github.com) Code: #!/usr/bin/env python import serial import time # Open grbl serial port s = serial.Serial('/dev/tty.usbserial-AQ02Z8ND', 11520) # put your serial port here print('Connected to: ' + s.name) print('Serial port open: ' + str(s.is_open)) # Serial write and readline def send_gcode(gcode): s.write(str.encode(gcode)) print('Sending: ' + str(str.encode(gcode))) print(s.readline().strip().decode('utf-8')) # Wake up grbl send_gcode('\r\n\r\n') time.sleep(2) # Wait for grbl to initialize s.flushInput() # Flush startup text in serial input send_gcode('$X') # Reset errors send_gcode('$H') # Homing send_gcode('G1 X100 Y100 Z0.0 F5000') # Go to X:100, Y:100, Z:0.0 at 5000 mm/min # Close serial port s.close()
Have a read through Grbl v1.1 Interface and the sample code at grbl/doc/script at master · gnea/grbl 11520 != 115200 (;
Thank you for the hint, the baud rate was obviously wrong. I fixed that, and I also realized that I was missing the carriage return '\n'. I have updated the code on GitHub and I have now included a jog mode with which you can use the arrow keys to move the head as well as homing, centering and going to zero coordinate. I hope this helps other people who are trying to communicate with Black Box through Python.