kliment / Printrun

Pronterface, Pronsole, and Printcore - Pure Python 3d printing host software
GNU General Public License v3.0
2.38k stars 996 forks source link

ERROR:root:Not connected to printer. #1243

Open ProbablyAnds opened 2 years ago

ProbablyAnds commented 2 years ago

Hi there, Ive tried with mutliple different branches of the project to no avail. I am using a Ardiuno Mega 2560, with a Ramps 1.4.

`from printrun.printcore import printcore from printrun import gcoder p=printcore('COM5',250000)

while not p.online : time.sleep(1)

If you need to interact with the printer:

p.send_now("G0 x100 y0") # this will send M105 immediately, ahead of the rest of the print `

I have this in the init.py folder and I get this output ERROR:root:Not connected to printer.

rockstorm101 commented 2 years ago

If (and only if) connection is succesful, it takes a bit of time before the printer comes online and allows sending commands. What happens if you uncomment the following line? (I.e. drop the hash '#' symbol)

#while not p.online : time.sleep(1)
ProbablyAnds commented 2 years ago

The program just waits forever on all branches. The ardiuno connects perfectly fine with pronterface, but just not through the python code.

My end goal is to have a raspberry pi camera attached to the printer head, instead of an extruder, so I can move the head to predefined points in order to take photos every set time interval. Thus I don't think I would be able to import the raspberry pi python camera library using gcode marcos with !.

Would it be a better idea to use octoprint? do you have any other suggestions?

rockstorm101 commented 2 years ago

The ardiuno connects perfectly fine with pronterface, but just not through the python code.

Well if Pronterface works a code similar to what you propose above should work. Apart from [allowing the printer to connect][1]. Things that come to mind:

  1. Import the time library to be able to sleep: import time
  2. Double check that "COM5" is the right port to use. It might change from time to time or when other stuff is connected to other ports.
  3. Make sure the printer is connected to a power supply capable of moving the motors. Typically, if only connected through the computer, the printer will respond to commands but won't be able to move the motors.
  4. Depending on your firmware, the command G0 x100 y0 might not work straight away. Try sending command G28 (which homes all axes) first.
    
    from printrun.printcore import printcore
    from printrun import gcoder
    import time

p=printcore('COM5',250000) while not p.online : time.sleep(1)

p.send_now("G28") # home all axes, should see some response from the printer by now p.send_now("G0 x100 y0")



[1]: https://github.com/kliment/Printrun/issues/1243#issuecomment-1048490972
volconst commented 2 years ago

Try dtr param and the many other proposals in here https://github.com/kliment/Printrun/issues/1201#issuecomment-885250173 Try to push the hardware reset button of arduino or this plug out its power while the script is looping in the while statement. Enable p.loud to see if you are using marlin with broken 'start' command.