get info from command excecuted gcode in frontend

Hello all! I need to display some info in the printing status screen, how do you request the data from a command with gcode and dipsplay it? can you exemplify please?

Comments

  • really hard to know if that gcode response will be returned from the front2 request... nothing documented...
  • Maybe you should start showing your g-code request and how answer looks. You need to add it to response parser with correct regular expression as I already said.  But giving an example that is way off for what you need is just wasing time, so please show us what you need to show. Maybe it is even already available.

  • probably can't get info other than printerstatus type from ws since its hardcoded, looking from the front2 code... but my question is there other way to pass data(data that gets from a specific gcode from a custom marlin firmware) from server to frontend? lua script? or a custom command defined on the printer settings screen? how do you return through websocket?
  • "add it to response parser with correct regular expression" ok, but what do you suggest to get the data for each 3 seconds for example?
  • Ok some ideas for you. First in bindings is a file globalOptions.ts which looks like this:
    export let globalOptions = {
    permInState: false,
    gpermInState: false,
    globalInState: false,
    sglobalInState: false
    };
    Setting globalInState true will make state contain all global variables from server commands, so that is an easy way to update them.

    When you add it to g-codes->Response to Event it will get triggered every time it gets the line from Marlin. So easiest is to make marlin send such an info every 3 seconds then, otherwise you must call the function every 3 seconds which can get delays if a slow operation like homin/heating is blocking new commands,

    Apart from this you can use these server command in gcode to trigger a function

    @timedCall name timeoutMS function_name

    Calls function_name after timeoutMS milliseconds. It does not repeat. The name can be used to stop the timer with @deletedTimedCall. If you need an interval, you need to call the function with @timedCall at the end of the function. In that case, make sure it is never started twice, or you end up with increasing number of calls until you have no time left for printing! Best is to always have some exit conditions in the called function like when you wait for a temperature to be reached, but disabling heater would stop loop as well.

    @deleteTimedCall Name

    Deletes all active monitors with the name Name.



    Just define a function with the g-code and set a new time at the end which will call the function again after timeoutMS milliseconds. Delete timer when you disconnect printer. Best location would be in the connection script so it starts as soon as possible. Note that you must deactivate and activate printer so it gets reread and included.
  • nice! really thank you @Repetier

Sign In or Register to comment.