Handle M20 - List SD Card for printers don't support M20

Hi, is there a way to handle M20 in a way that it is not send to the printer, because it doesn't support it and inject instead a response which is a valid M20 response for octoprint?

is it possible to use octoprint.comm.protocol.gcode.received in a way that one line on the response will result in multiple lines on the return of the hooked method?

thx for support / feedback

Yeah, you could look at the bundled virtual printer to see how it handles it. I used that as a starting point for the Bambu plugin I've been working on. It lists files uploaded to X1 via ftps commands and responds the file list as expected.

thx. that's a good hint.

this _gcode_Mxxxx methods - they are automaticaly invoked by octoprint or do i have to register them somehow.

my idea is to make also a list of file with an wifisd card.

if i use that plugin togehter with the flashforge plugin is it enough to set the order to 1 for the sdcard plugin to handle the sdcard topics before it is handles by the flashforge plugin?

is it possible that 2 plugins in parallel hooking octoprint.comm.transport.serial.factory for the same serial connection?

thx

this only works because my plugin is using serial factory, but you could potentially achieve the same with gcode queueing hook to catch the M20 command (possibly replace with another command or completely ignore it) and then use the comm module to virtually receive the results. I would have to look into the comm module more to see if that could be utilized to mimic commands received.

I've seen this plugin developed already for aircards

That would be a good assumption assuming the flashforge plugin doesn't specify any order in their hooks.

This I don't think is possible.

mentioned plugin

but you probably want the patched version in this fork....