Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Get GRBL version printout #1300

Open
ColPaulR opened this issue Aug 25, 2024 · 1 comment
Open

Feature: Get GRBL version printout #1300

ColPaulR opened this issue Aug 25, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@ColPaulR
Copy link

Machine Context

FluidNC on TinyBee connected to CNCjs

Feature Description

BLUF: Is there a reason or motivation to not send the startup string with the "$SS" command?

The only way I can get CNCjs to initialize is to execute a soft reset. CNCjs is looking for the "GRBL vx.x" or something similar at the start of a line before it resets. The only way I can find to get FluidNC to send that message from function report_init_message, is to execute a soft reset (what CNCjs wants me to do). I get extremely nervous about losing my position registration doing a soft reset just to get the gcode sender initialized. I read in the wiki that FluidNC is not supposed to lose position if there is no motion while soft reseting.

I added the function report_init_message to showStartupLog to get the "GRBL vx.x" string by command without a reset. CNCjs seems happy. Is there a downside to putting the startup message in the $SS command in the next version? If so, what about a command to echo the startup message from the console (maybe "$SV" for show version)?

Happy to make the changes and execute a push request if one of these approaches is consistent with FluidNC's design vision

Other Approaches

Lots of changes within CNCjs to get GRBL version/startup message without a reset

How I Can Help

Happy to make the changes and execute a push request if one of these approaches is consistent with FluidNC's design vision

@ColPaulR ColPaulR added the enhancement New feature or request label Aug 25, 2024
@MitchBradley
Copy link
Collaborator

There is one potential problem that I can think of. Historically, the appearance of a Grbl signon message is an indication that the controller is in the state that exists after a reset. A UI agent that decodes messages could infer something that is not correct when it sees such a message. This could be mitigated to some extent by issuing the response only on the channel that requested it, so it only be seen by UI agents that explicitly ask by using the new command. It would be up to such agents to modify their interpretation of the message according to whether or not they issued the command. In the case of cncjs, I don't see any obvious problems. The code appears to be (in various files in src/server/controllers/Grbl/):

class GrblLineParserResultStartup {
    // Grbl 0.9j ['$' for help]
    // Grbl 1.1d ['$' for help]
    // Grbl 1.1
    // Grbl 1.1h: LongMill build ['$' for help]
    // Grbl 1.1h ['$' for help] LongMill build Feb 25, 2020
    // gCarvin 2.0.0 ['$' for help]
    static parse(line) {
        const r = line.match(pattern);
        if (!r) {
            return null;
        }

        const firmware = r[1];
        const version = r[2];
        const message = _trim(r[3]);

        const payload = {
            firmware,
            version,
            message,
        };

        return {
            type: GrblLineParserResultStartup,
            payload: payload
        };
    }
}
...
        if (type === GrblLineParserResultStartup) {
            const { version } = payload;
            const nextSettings = { // enforce change
                ...this.settings,
                version: version
            };
            if (!_.isEqual(this.settings.version, nextSettings.version)) {
                this.settings = nextSettings; // enforce change
            }
            this.emit('startup', payload);
            return;
        }
...
        this.runner.on('startup', (res) => {
            this.emit('serialport:read', res.raw);

            // The startup message always prints upon startup, after a reset, or at program end.
            // Setting the initial state when Grbl has completed re-initializing all systems.
            this.clearActionValues();

            // Set ready flag to true when a startup message has arrived
            this.ready = true;

            if (!this.initialized) {
                this.initialized = true;

                // Initialize controller
                this.initController();
            }
        });
...
    async initController() {
        // https://github.com/cncjs/cncjs/issues/206
        // $13=0 (report in mm)
        // $13=1 (report in inches)
        this.writeln('$$');

        await delay(50);
        this.event.trigger('controller:ready');
    }

I think a good name would be $Grbl/Show AKA $GS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants