More from CNC.js dev:
I did not spend much time looking at the changes because they are not presented in the standard form of a pull request (PR) against a specific version. There is a very good reason for that standard form - it saves time for primary developers, who are often very busy and overwhelmed with requests from many different people. With a PR, you can easily see exactly what changed, accept/merge it with the push of a button if it is good, comment on specific lines with a single click, etc.
Another meta issue is with the specific “ask” in the original issue posting “can someone take a look at it and confirm that it does what it is supposed to”. Asking CNCjs developers to review Marlin code is out of scope. As far as I know, there is no overlap between the CNCjs and Marlin development team. There just happens to be some g2core overlap, as I am also a g2core developer, but even so, I would expect requests for g2core code review to go to the g2core site.
But those meta issues aside, it seems to me that the thread has morphed into three separate issues:
Coordinate system support via G10
“automatic” position reports (actually a subset of a fully useful solution to that problem)
work coordinate reporting
(As with the PR meta-issue, when too many issues get conflated, it is hard for people to focus. When too-busy people are presented with conflated issues, the tendency is to disengage.)
Taking those one at a time:
G10: So what is the CNCjs issue here? Does CNCjs work with the changed version or not? If it does, what is the problem? If not, an issue specifically identifying how to reproduce the problem would be appropriate - but possibly time-consuming for the CNCjs developers to handle because testing it would require us to set up a Marlin compilation environment, compile the patched code, load it onto a board, etc. That might be worthwhile if this feature becomes standard on Marlin, but until is clear whether that will happen, it’s a “one off” situation.
“not really automatic” position reports: Again, does this work with CNCjs or not? My guess is that it does work, because CNCjs just deals with position reports whenever they arrive. There is no notion of “expected” vs “unexpected” reports. There is some CNCjs code to try and coerce Marlin to send some reports, but on the receiving side, whenever a position report happens to come in, things get updated. Perhaps the issue should be framed as an announcement?
“work coordinate reporting”: This was framed as “could you add mpos: and wpos: tags like g2core” and “what position reports should look like for optimum CNCjs compatibility”. As it currently stands, Marlin reports look nothing at all like g2core reports, so trying to shoehorn g2core syntax into Marlin syntax is not workable. g2core report syntax is highly structured using JSON notation, whereas Marlin is totally ad-hoc. With a structured report format, you add new features easily because the parser expects everything to be tagged. Any new tag is simply ignored by older versions of the code, which is possible because the parser can always tell what is a tag and what are the arguments for that tag. Ad-hoc formats are very tricky to change without risk of breaking old code. Since the format is unstructured, different UI agents probably use different strategies for recognizing the various different reports and pulling out the different fields. You must be very careful to design a new report that old parsers won’t confuse for a preexisting report - and just adding fields to an old report suffers from the same problem. To do this safely requires you to consider every different UI agent that purports to support Marlin - not just CNCjs.
And thus perhaps you can see why I am not a fan of Marlin for the use case of external UI control. Its serial communications framework is poorly designed at a very fundamental level. For the use case of running a 3D printer via an attached LCD panel, Marlin works brilliantly. I use it on my 3D printer. Copy the GCode to a USB stick, bung it in the printer, and let the job run for hours without worrying about whether an attached PC will go to sleep at a bad time.
The answer to “what should they look like for optimum CNCjs compatibility” is this: Compatibility with current releases of CNCjs is hopeless because CNCjs parses Marlin reports according to existing Marlin syntax which does not have work position. For the future, whatever you can convince the Marlin team to do will be okay with CNCjs, under the assumption that the Marlin team will invent something that is unambiguous (otherwise it will cause endless problems for everybody). The Marlin and g2core report parsers are totally separate so trying to make an amalgam of the two is not helpful. If Marlin were to use g2core style JSON reports, that might be helpful in theory, but the fact that there are so many copies of Marlin out there that use the existing Marlin format makes a new JSON format not helpful in practice.
Sorry if this sounded cranky - but the fact is that there are lots of factors in play and I wanted to lay them out so you understand the depth of the problem. Maintaining and enhancing complex software is a big problem, and is made much much harder by interactions between multiple separately-developed components.