jminardi / mecode

GCode for all
MIT License
221 stars 61 forks source link

grbl support #73

Open mo-nonym opened 3 years ago

mo-nonym commented 3 years ago

The Printer class works with a printer running on a Marlin firmware (I guess). How can support for the grbl be added ?

A tryout of the following code

import mecode

g = mecode.G(
    direct_write=True,
    direct_write_mode="serial",
    printer_port="/dev/ttyACM0",
    baudrate=115200
)
g.write("$H")
g.move(x=10, y=10)
g.teardown()

...returns G91 ;relative in the terminal before freezing.

KeyboardInterrupt returns this:

^CTraceback (most recent call last):
  File "move.py", line 7, in <module>
    baudrate=115200
  File "/home/me/.local/miniconda3/envs/mecode_env/lib/python3.7/site-packages/mecode/main.py", line 238, in __init__
    self.setup()
  File "/home/me/.local/miniconda3/envs/mecode_env/lib/python3.7/site-packages/mecode/main.py", line 337, in setup
    self.write('G91 {}relative'.format(self.comment_char))
  File "/home/me/.local/miniconda3/envs/mecode_env/lib/python3.7/site-packages/mecode/main.py", line 981, in write
    self._p.connect()
  File "/home/me/.local/miniconda3/envs/mecode_env/lib/python3.7/site-packages/mecode/printer.py", line 151, in connect
    sleep(0.01)  # wait until the start message is recieved.
KeyboardInterrupt

Thx for hints and help !

P.S. This script from the grbl repo could maybe hold the solution.