Returning a value from an external command

Is it possible to return a value from an external command? I will write the external command, so it could do anything, such as output a string to stdout. Specifically, I want the external command to parse the g-code of the current job, looking for specially formatted comments. If they are in the g-code, then certain GPIO pins would be enabled turning on a relay for that job, and turned off at its end.

Comments

  • No, external command output gets logged to server log for error analysis but is not available. No server command has a return value.

    I see several solution for this. Simplest solution is make it a synced external command, do gpio enabling. Define gpio in general settings->gpio as well. In job finished/job stopped g-code you can read the gpio with computed expression get_gpio_state and do whatever you wanted to do with it in gcoide (pin off) or call execute if you need that.

    Alternatively make it a web service and use computed expression http_get taht you use with @set to store result in a global variable so you have the return value.

    Last solution is script stores result in a file and exit script gets always called but reads the file to know what to do.
Sign In or Register to comment.