Every Printjob starts with GCODE-Script "After print job completes"

What is the problem?
Every Printjob starts with GCODE-Script "After print job completes"

What did you already try to solve it?
I tried to delete script and change gcode but nothing happens. If I start a new job I start with the (old)Script which was intended for the finished job.

Additional information about your setup (OctoPrint version, OctoPi version, printer, firmware, octoprint.log, serial.log or output on terminal tab, ...)
Version 1.3.9 / Raspberry Pi 3

Remote in to your Raspberry Pi:

ssh pi@octopi.local # default password is "raspberry"

Then navigate to where OctoPrint stores these scripts:

cd ~/.octoprint/scripts/gcode

Review the various scripts there, for example:

cat afterPrintDone
 G92 E1
 G1 E-1 F300
 G28 X Y Z
 M104 S0
 M84
cat beforePrintStarted
 OCTO801
 G91
 G28 X0 Y0 Z0
 G90
 G92 E0
 G29

You might even try to edit one if you don't love it:

nano beforePrintStarted

Then restart OctoPrint.

Thank you for the fast reply. I review the scripts "afterPrintDone" and "beforePrintStarted" and I saw exactly the same what I found in the Octoprint-Settings. If I modify the file over ssh I can find the changes in the settings (after restart).

Problem is, that Octoprint always add an old version of "afterPrintDone" to the beginning of the Gcode when I start a Printjob, I never used "beforePrintStarted" and its still empty.

So you're saying that you edit beforePrintStarted in either the GUI or from a command line and you can see the changes in the other place... and then after a restart of OctoPrint... it ignores you and does its own thing by reverting? Here, I would have confirmed that the changes persist after the restart (the text file or Settings dialog agree with my intent) before sending another print job to be the guinea pig. If they don't (meaning that upon a restart OctoPrint has written over my changes) then I would fight that battle to try to determine what's going on.

Can you confirm:

  1. I edit beforePrintStarted
  2. I confirm that the feature is edited
  3. I restart OctoPrint
  4. I revisit the Setting

5) ...and OctoPrint reverted beforePrintStarted to equal the file afterPrintDone?

If so, then this sounds like a bug.

And of course, all this needs to be done a second time having rebooted IN SAFE MODE from the System menu. If it now works as expected yet it failed above, then one of your plugins is behaving badly.

Ok I now try the following:

I open beforePrintStarted in ~/octoprint/scripts/gcode with nano over ssh:
--> the file is empty

I open afterPrintDone in ~/octoprint/scripts/gcode with nano over ssh:
I see:

G90 ; use absolute positioning for the XYZ axes
G0 Z180 F3600 ; move to the Z=200mm position on the bed
G0 X140 F3600 ; move to the X=150mm position on the bed
G0 Y140 F3600 ; move to the Y=150mm position on the bed
M81 192.168.0.199 1 ;Schalte Steckdose aus

Now I look in the OctoprintSettings over Webinterface:

--> beforePrintStarted is empty
--> afterPrintDone is the same as what I see over ssh

Now I modify afterPrintDone over ssh and restart octoprint
--> I can see the modification in the settingsTab of WebInterface

Now I open Webinterface and click "open and print"

This is what I see in the Terminal:


Changing monitoring state from "Offline" to "Detecting serial port"
Serial port list: ['/dev/ttyUSB0']
Connecting to: /dev/ttyUSB0
Changing monitoring state from "Detecting serial port" to "Opening serial port"
Connected to: Serial<id=0x66ab7d10, open=True>(port='/dev/ttyUSB0', baudrate=115200, bytesize=8, parity='N', stopbits=1, timeout=10.0, xonxoff=False, rtscts=False, dsrdtr=False), starting monitor
Changing monitoring state from "Opening serial port" to "Connecting"
Send: N0 M110 N0125
Recv: start
Send: N0 M110 N0
125
Recv: echo: External Reset
Recv: Marlin 1.0.0
Recv: echo: Last Updated: Jul 31 2017 10:16:30 | Author: (none, default config)
Recv: Compiled: Jul 31 2017
Recv: echo: Free Memory: 11813 PlannerBufferBytes: 1232
Recv: echo:Hardcoded Default Settings Loaded
Recv: echo:Steps per unit:
Recv: echo: M92 X80.00 Y80.00 Z400.00 E93.00
Recv: echo:Maximum feedrates (mm/s):
Recv: echo: M203 X500.00 Y500.00 Z5.00 E25.00
Recv: echo:Maximum Acceleration (mm/s2):
Recv: echo: M201 X500 Y500 Z100 E5000
Recv: echo:Acceleration: S=acceleration, T=retract acceleration
Recv: echo: M204 S500.00 T500.00
Recv: echo:Advanced variables: S=Min feedrate (mm/s), T=Min travel feedrate (mm/s), B=minimum segment time (ms), X=maximum XY jerk (mm/s), Z=maximum Z jerk (mm/s), E=maximum E jerk (mm/s)
Recv: echo: M205 S0.00 T0.00 B20000 X20.00 Z0.40 E5.00
Recv: echo:Home offset (mm):
Recv: echo: M206 X0.00 Y0.00 Z0.00
Recv: echo:PID settings:
Recv: echo: M301 P21.73 I1.54 D76.55
Recv: echo:SD init fail
Recv: ok
Changing monitoring state from "Connecting" to "Operational"
Send: N0 M110 N0125
Recv: ok
Send: N1 M115
39
Recv: FIRMWARE_NAME:Marlin V1; Sprinter/grbl mashup for gen6 FIRMWARE_URL:http://www.mendel-parts.com PROTOCOL_VERSION:1.0 MACHINE_TYPE:Ender 3D EXTRUDER_COUNT:1 UUID:00000000-0000-0000-0000-000000000000
Recv: ok
Send: M21
Recv: echo:SD init fail
Recv: ok
Send: M105
Recv: ok T:23.1 /0.0 B:22.9 /0.0 T0:23.1 /0.0 @:0 B@:0
Send: M105
Recv: ok T:23.0 /0.0 B:22.8 /0.0 T0:23.0 /0.0 @:0 B@:0
Changing monitoring state from "Operational" to "Printing"
Changing monitoring state from "Printing" to "Cancelling"
Send: N2 M104 S0103
Recv: ok
Send: N0 M110 N0
125
Recv: ok
Send: N1 M140 S0100
Recv: ok
Send: N2 G90
18
Recv: ok
Send: N3 G0 Z200 F36001
Recv: ok
Send: N4 G0 X150 F3600
2
Recv: ok
Send: N5 G0 Y150 F36002
Recv: ok
Send: N6 M84
25
Unexpected error while reading serial port, please consult octoprint.log for details: SerialException: 'device reports readiness to read but returned no data (device disconnected or multiple access on port?)' @ comm.py:_readline:2581
Please see https://faq.octoprint.org/serialerror for possible reasons of this.
Changing monitoring state from "Cancelling" to "Offline (Error: SerialException: 'device reports readiness to read but returned no data (device disconnected or multiple access on port?)' @ comm.py:_readline:2581)"
Connection closed, closing down monitor

I cut Power from printer because he dont know where Z=200 is (there was no homing before)

This Part (copy from Terminal) can I identify as an old Version from "afterPrintDone" :
Send: N3 G0 Z200 F36001
Recv: ok
Send: N4 G0 X150 F3600
2
Recv: ok
Send: N5 G0 Y150 F3600*2
Recv: ok

Now I start Octoprint in safeMode and start the same printjob. It seems to be ok.

Have you opened the GCode file you're printing? I'm guessing this is actually coming from the slicer, and is in the actual GCode file itself. In that case, you will need to change your slicer settings, because you've got the slicer set up to prepend the GCode in question.

Please note: You've confirmed the GCode you are concerned about doesn't match what is in the settings in the GUI or filesystem, and you've restarted the server, so whatever is in the file is all OctoPrint knows about (unless you're running a non-standard python interpreter setup that is caching something in a VM - highly unlikely), which is what leads me to believe you need to check your slicer settings before continuing.

1 Like