How terminal handle firmware response after sending Gcode command?

What is the problem?

I wonder how terminal (of the web app) handle the response of the firmware after sending a G-Code

What did you already try to solve it?

I try to check a complete call in order to analyse the full stack trace and try to understand how it works but I'm stuck. I saw that when I enter a command in the terminal this is the /api/printer/command function which is call but after that, how the response is handle by the terminal ? Is there a way to retrieve a firmware response via the API after attempting a POST request with /api/printer/command. (For example a M114 command)

Additional information about your setup
I'm currently running with the latest version of Octoprint. My printer is custom and runnig marlin firmware.

No. This has technical reasons. Due to a firmware bug that is still present in vendor forks it's not possible to reliably associate sent commands with their output (due to commands not necessarily being acknowledged in the same order as they were sent in). Which makes it impossible for OctoPrint to provide you with the output produced by a command you send.

What OctoPrint does internally is look for known response formats in the received lines and match them via string matching or regular expressions. The whole communication is completely asynchronous. It also happens in the backend/server portion of OctoPrint, not the Terminal tab (otherwise your printer would stop if you'd close the browser).

Damn is it still the case ?
I was interested in getting the result of a M114 too in a 3D engine app to sync a 3D model with my printer.
I'm getting the temperatures values without any problem and was just missing the (x,y,z) head position :frowning:

Yes, the problem is still present in firmware. But stuff like position queries are handled so you should only have to subscribe to an PositionUpdate event and get what you need once you issue an M114.