Understanding M20 Json Response



  • Hi All,

    A typical JSON response for M20 is as follows:

    {"dir":"0:/gcodes","first":0,"files":["ANGLE BRACKET (46.30).gcode","treefrog_45_SST1.gcode","treefrog_45_SST2.gcode","treefrog_45_SST3.gcode","treefrog_45_SST4.gcode","30mmCube_POT1.gcode"],"next":0,"err":0}

    I Can't find any information regarding the following pairs "first":0,"next":0,"err":0 . The error I guess will the error in the sd, but what all possible values do that have or just 0 and 1. It would be nice if someone can explain it. Thank you all in advance.


  • administrators

    A folder may contain more files than will fit in a single M20 json response. So when you send M20 S2 there is also an R parameter (default 0) which is the number of files to skip at the start. This value is returned in the 'first' field of the result. The 'next' field is the number you should ask to skip in your next M20 request to get the next block of files. If it is zero then there are no more files.

    'err' is currently always 0 for success and 1 for error. We may introduce other error codes in future, but 0 will always mean success.



  • Hi David,

    Thank you for your fast response. This information is missing on the duet Gcode and RepRap Gcode wiki. How much file name can be included in a JSON response can have at the present moment. Is there any limit on the size of JSON responses duet passes? Even on M408 S0 R and M408 S1 in case of the maximum messages that it can include?


  • administrators

    I added that info to the Duet3d wiki yesterday.

    The number of filenames that may be passed back in a single json response depends on the amount of buffer space available. That in turn depends on the number of web clients and other factors.



  • Yea I saw that on the wiki, I was about to edit it 🙂

    What is the maximum size of the buffer? I'm trying to build a new GUI interface. On the deserialization part, I can't finalize on the size of the buffer.


  • administrators

    There isn't a maximum specified size. PanelDue reads the file names as they arrive so it doesn't need to buffer the entire message; however it has a limit on how much file data it can store in its file list.



  • what about the duet, is there any limit for maximum data it can send through a JSON response? like for M20 and M408 commands


  • administrators

    In the current firmware build, the maximum total reply length would be 4K for Duet 2 and 7K for Duet 3.



  • Thank you, David. That's what I was looking for 👍


 

Looks like your connection to Duet3D was lost, please wait while we try to reconnect.