TOC PREV NEXT INDEX

LinuxCNC.org


Handbook - Adding Tcl/Tk commands using emcsh


Adding Commands


The C++ program emc/src/emctask/emcsh.cc is the back-end of tkemc. This is a replacement for "wish", the default Tcl/Tk "windowing shell" that is used to run Tcl/Tk scripts. emcsh does everything that wish does, plus connects to the EMC's communication buffers, and provides new functions like emc_mode, emc_estop to send commands, and emc_abs_act_pos, emc_rel_cmd_pos to get status.

You can add new commands to emcsh.cc, following an example like emc_estop or emc_rel_cmd_pos for sending a command or retrieving status, respectively. The strings and their corresponding C++ functions have the same names, so you can search through the file and see what's going on. The complete list of available commands and status items provided by the EMC is in emc/src/emcnml/emc.hh. Many of these aren't yet in emcsh.cc, and therefore not accessible via tkemc. I only put in the ones that I thought would be needed in the GUI at first.

NML itself can be extended. This is done when new capabilities are added to the controller, so extending NML really means extending the EMC. The last one I added was the ability to override limits temporarily, to support homing off a limit switch. This involved coding it up in the motion controller (emc/src/emcmot/emcmot.c), adding a new message and status item for this (emc/src/emcmot/emcmot.h), adding it to NML (emc/src/emcnml/emc.hh), handling this in the EMC task controller (emc/src/emctask/emctaskmain.cc), adding it to the EMC windowing shell (emc/src/emctask/emcsh.cc), then updating the tkemc script to use it. Whew.

--Fred Proctor


TOC PREV NEXT INDEX