Python Component issueing errors or warnings to LinuxCNC

More
02 May 2021 14:06 #207625 by Roiki
You can read the nml source. There are messages for error messages there. They are used internally by the application but are not included in the linuxcnc.command method for sending them on the command channel to the nml error channel. As Andy Pugh pointed out.

I haven't looked at the source enough to see if these would be difficult to implement or not. Or if they exist on the c++ api that's under the python one.

Please Log in or Create an account to join the conversation.

More
06 May 2021 13:47 #208108 by Stormholt
I don't know if its a very elegant way but, for my axis tabs I have created a hal pin only to print an error/warning using the "message" hal real time component.

Please Log in or Create an account to join the conversation.

More
10 May 2021 21:00 #208500 by cmorley
So I slapped together some code to test with:
PyObject *MESSAGE_(pyErrorChannel *s,  PyObject *args ) {
    char *m;
    EMC_OPERATOR_DISPLAY operator_display_msg;

    if(!PyArg_ParseTuple(args, "s", &m)) return NULL;
    if(!s->c->valid()) {
        PyErr_Format( error, "Error buffer invalid" );
        return NULL;
    }
    operator_display_msg.id = 0;
    strncpy(operator_display_msg.display, m, LINELEN);
    operator_display_msg.display[LINELEN - 1] = 0;
    s->c->write(operator_display_msg);
    Py_RETURN_NONE;
}

static PyMethodDef Error_methods[] = {
    {"poll", (PyCFunction)Error_poll, METH_NOARGS, "Poll for errors"},
    {"MESSAGE_", (PyCFunction)MESSAGE_, METH_VARARGS, "Send message"},
    {NULL}
};

and the message is accepted but never sent it seems.
I can't find much examples of sending messages on the error channel other then emctaskmain.cc

Please Log in or Create an account to join the conversation.

More
11 May 2021 13:46 #208549 by Roiki
I don't think you send it on the error channel but the command channel. Try it that way and see what happens?

Please Log in or Create an account to join the conversation.

More
11 May 2021 14:58 #208560 by cmorley
Yes that did the trick - thanks.
Unfortunately all display messages can only be accepted in auto mode.

There is an NML_ERROR message but I don't understand how to send this NML message

More research needed..

Please Log in or Create an account to join the conversation.

More
11 May 2021 23:58 #208605 by cmorley
Well it seems EMC_OPERATOR_ERROR_TYPE messages can be made to always display by modifying emctaskmain.cc to accept them.

I just don't understand if there is a disadvantage to always accepting them.

Please Log in or Create an account to join the conversation.

More
12 May 2021 21:32 #208654 by andypugh
Do it and see who complains? :-)

Please Log in or Create an account to join the conversation.

More
12 May 2021 23:53 #208673 by cmorley
lol You know you are right.
Thanks Andy

Please Log in or Create an account to join the conversation.

More
13 May 2021 00:52 #208679 by cmorley
Ok in master you can use python's linuxcnc module to send messages to the operator.
import linuxcnc
c = linuxcnc.command()

c.error_msg('Error')
c.text_msg('Text')
c.display_msg('Display')

Please let me know if you test it.

Please Log in or Create an account to join the conversation.

More
13 May 2021 15:17 #208737 by mwinterm
Hello @cmorley,

just tried it out. Works like a charm :)

Exactly what I was looking for.

Thank you very much!

Regards,

Marc

Please Log in or Create an account to join the conversation.

Time to create page: 0.088 seconds
Powered by Kunena Forum