grblHAL / core

grblHAL core code and master Wiki
Other
330 stars 87 forks source link

Support unlock from plugin code #121

Closed dresco closed 2 years ago

dresco commented 2 years ago

When in an alarm state, the system can be unlocked by a sender ($X), but not from a plugin - as protocol_enqueue_gcode() currently drops commands in STATE_ALARM - any objection to allowing this?

(I would like to be able to unlock from my control panel plugin, as the VFD starts up slower than the controller, and so GRBL alarms when the first modbus messages are unacknowledged).

https://github.com/grblHAL/core/blob/4ff8f1c5e740d82f5065fa36a548a51ae7f3dcc2/protocol.c#L67-L72

terjeio commented 2 years ago

any objection to allowing this?

Not sure what to answer - best to keep it as it is now? In alarm state you can send $X directly to the system command parser:

https://github.com/grblHAL/core/blob/4ff8f1c5e740d82f5065fa36a548a51ae7f3dcc2/system.c#L299-L300

I have called this function directly myself in the HPGL-plugin:

static void go_home (void)
{
    char cmd[LINE_BUFFER_SIZE] = "$H";
    plan_line_data_t plan_data = {0};

    process = wait;
    hal.stream.write = hal.stream.write_all = stream_write_null;

    system_execute_line(cmd);

    plan_data.feed_rate = 4000.0f;
    target.values[X_AXIS] = settings.axis[X_AXIS].max_travel; //
    target.values[Y_AXIS] = 0.0f;
    process = mc_line(target.values, &plan_data) ? await_homed : NULL;
}
dresco commented 2 years ago

In alarm state you can send $X directly to the system command parser

Oh cool, wasn't aware of that function - will try it that way instead.. Thanks!

dresco commented 2 years ago

Thanks, that works just fine..