external command send to Raspberry Pi before printer on? (Raspberry Pi

I know you inject the start external commands via gcode scripts but is there any way to run one before the printer is on to the pi?  I have one (@printeron) which is a script to bring a gpio pin high.  It works fine via CLI but I'd love to inject this right after slicing or perhaps right before sending the print to the printer.  This would work very nicely w/ my script to turn printer off after the print job ends effectively automating all power functionality.  Since this is sending the command to a pi which is already on I don't see why this isn't physically possible, maybe just not software possible yet.

Thanks
Dave

Comments

  • When printer is connected you can send any script, if not it would make no sense so will not happen. Not sure what is the case since you want to turn on printer - so can it already communicate because usb delivers power or not. If not, then you need to make it a server command and can only send it from frontend gui but not from a script.
  • edited January 2018
    The pi is on and connected to printer always.  At any time I can basically send the GPIO pin high/low to turn the printer on/off.   By sending the GPIO pin high it energizes a relay which turns the printer on.  Obviously this cannot be done w/ gcode while the printer is off.  Just looking to see if there is a way to add a process (Run my PrinterOn.sh script) on the pi right after slicing or even when slicing is started.
    So this is the flow:
    1.  slice print
    2.  After completion of slice send gpio command to pi to turn printer on via my script (Cannot be via gcode as printer is off).  I already have a power on button setup in host/server which works to power on/off the printer, perhaps those can be utilized and called?
    3.  Click print to send gcode to pi and start printing sliced file.
    4.  After print done, power off printer. (Already set up and working thanks to you) 
  • Why not simply add the power on command in the start script. Then add a G4 S1 to wait a second so power is up and continue with regular sliced print. I mean turning on printer does not take so long that you need a minute until it is done.
  • Doesn't the start script just inject into gcode?  I cannot use gcode until printer is on.  If that start script will actually run independent of the printer being on I could do it but I don't think the print button is active (Thus cannot send print/start script) until it detects a serial interface connection.  I just confirmed print is not active, so I don't see how that can work.

    Dave
  • You said "The pi is on and connected to printer always.  " which I interpreted that you can also communicate as printer board gets power from pi. If that is not the case you can only use the extcommands.xml printer command solution. You can add there some for menu and for @execute.
  • edited January 2018
    The printer board does get power from a relay controlled by the pi (I can turn the printer on/off at will via CLI in pi.  I have to turn printer on to allow @execute as that is embedded into the gcode which cannot be sent until the printer is powered on and a serial interface is available correct?  What I need to do it send that @execute command some other way or just call my script prior to printing, maybe as slicing starts or right after it is done?  Make sense?  I do have menus that turn the printer on in host but it must be executed manually.  Can I automate this power on button which is tied to my power on sh file which is also defined as an @execute command in extcommands.xml?  
      
  • @execute only works when the printer is online and you said that's not the case so script solution does not work.

    You need the external command solution that adds commands to frontend menu, but these do not appear in host only in server frontend.

    Only solution I see is a postprocessor script so after slicing that script does not change gcode but call the command on the pi, e.g. using the server web api.
  • Sorry that went above my head.  Yes I do have extcommand  setup and working.  I can manually turn the printer on from either host or server as I showed in the pic above.  Can I have this post processor script do both?  First run my external command to power on printer and then slice?

    Dave
  • Now I do not understand.
    When you can do it already, what is the problem? I though on is not working because printer is off and you could net send the command.
  • I would like to automate it.  So right after a slice it will turn on printer.  Problem is it cannot be done by gcode.  I just need to somehow emulate that same process I use to turn it on w/ the method I use in the picture in my post above.   That runs the sh file I created to send the GPIO pin high.
  • edited January 2018
    So it appears that I can use the advanced option (Post slice filter)  under printer setting but I don't quite understand how this operates or the formatting.  Can I just somehow have it run my sh file on the pi server?  I tried to put that in using @execute printeron #out and that didn't do it.   Printeron.sh is in extcommands.xml and works to turn on printer from CLI.  Can you perhaps further elaborate on the formatting I need to use to run one of the allowed extcommands commands? 

    BTW this is what I get when trying that:

    [quote]
    Error starting postprocessor:System.ComponentModel.Win32Exception (0x80004005): The system cannot find the file specified

       at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)

       at RepetierHost.view.SlicerPanel.Postprocess(String file)

    [/quote]

    Thanks
    Dave
  • edited January 2018
    Couldn't edit the above sadly.

    I do have a bit of a ghetto way I'm doing it now but then I noticed it doesn't print the print jobs when clicking print after slice.  I have to go to the server tab and manually click print rather than just clicking print from print preview tab.    What I did was running a putty command to run a txt file upon login that executes the sh file but perhaps there is a better way?  With my way I have to have my ssh password exposed and it also temp opens a dos window and putty before it closes.  I'd like to do this a way where it doesn't rely on files on my local pc just to run an sh command on the pi.   Primarily because I slice from multiple computers. 


  • There is simply no button/function in host to do this. So you need to program something and there are many ways. You could also make a host plugin adding a menu item to do so. You can call form there the server api which calls a function that triggers your command. But all solutions require programming knowledge. Simple solution is always just to hit the function in server web fron-end.
  • Ok thanks.  I saw your page on creating your own plugin, I will have to look into it some.

    Dave
Sign In or Register to comment.