Output contents of file to console

  • Thinking about the request for help thread here:


    It occurred to me that a lot of the information gathering could be done using a macro, IF there was a way to A) Echo the contents of a file to the console with a g-code, and B) use M28 to capture output from commands.

    You could do something like:

    (Note, M930 does not exist, just using it as a placeholder for a function that echos file contents).

    M28 tech_support.txt ; Open tech_support.txt for writing
    M118 S"------------ BEGIN Technical Support Readout -----------------"
    M118 S"---- Main System Files Output -----"
    M118 S" -- /sys folder contents ---"
    M20 P"/sys"
    M118 S"--------------"
    M118 S"----- config.g -----"
    M930 P"/sys/config.g"
    M118 S"--------------"
    M118 S"----- config-override.g -----"
    M930 P"/sys/config-override.g"
    M118 S"--------------"
    M118 S"----- homex.g -----"
    M930 P"/sys/homex.g"
    M118 S"--------------"
    M118 S"----- homey.g -----"
    M930 P"/sys/homey.g"
    M118 S"--------------"
    M118 S"----- homez.g -----"
    M930 P"/sys/homez.g"
    M118 S"--------------"
    M118 S"----- homeall.g -----"
    M930 P"/sys/homeall.g"
    M118 S"--------------"
    M118 S"---- Diagnostics Information -----"
    M122 ; output diagnostics for platform, move, heat, gCodes. network and webserver modules
    M118 S"------------ END Technical Support Readout -----------------"
    M29 ; Finish SD card writing
    M118 S"A file called tech_support.txt has been created on the root of your SD card "
    M118 S"Please attach the file to your support request"

    Obviously there are ways to improve this - pretty-printing, adding extra files/diagnostics, verbose/concise mode, etc. There are also far more sophisticated ways of packaging the data using DWC rather than a console. The upside of this approach is that DWC doesn't have to be up-and-running, you just need an operational console connection and the ability to put a file on an SD card.

    When/If branching in gcode becomes available, a more sophisticated approach will be possible as the macro could detect kinematics/drive strategy, etc and finesse the output accordingly.


  • administrators

    Is there a reason why you don't just use the Edit or Download facility in DWC?

  • This was intended to be an easy way to gather useful information for people posting problems here, as per my post in the linked thread. As with many support forums, a lot of effort is expended getting standard information from the people requesting help. I thought a simple way to gather that info would be of some use.

    My reason for advocating a generic gcode approach was to make it possible to get the info even if DWC was not available for some reason e.g. the network is not available.

  • administrators

    You can get config.g echoed to the console by sending M503.

  • administrators

    @dc42 the idea would be a single gcode to create a log file of everything and save it to the SD card for attaching on the forum

Log in to reply