Skip to content

Commit 764655e

Browse files
committed
moving all IO handling from iocontrol to task
1 parent 6fa1f25 commit 764655e

File tree

13 files changed

+618
-522
lines changed

13 files changed

+618
-522
lines changed

configs/common/client.nml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,3 @@ B emcError SHMEM 192.168.0.4 8192 0 0 3
2222
P xemc emcCommand REMOTE 192.168.0.4 W 0 10.0 0 10
2323
P xemc emcStatus REMOTE 192.168.0.4 R 0 10.0 0 10
2424
P xemc emcError REMOTE 192.168.0.4 R 0 10.0 0 10
25-
P xemc toolCmd REMOTE 192.168.0.4 W 0 10.0 0 10
26-
P xemc toolSts REMOTE 192.168.0.4 R 0 10.0 0 10

configs/common/linuxcnc.nml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,18 @@ B emcCommand SHMEM localhost 8192 0 0 1
1010
B emcError SHMEM localhost 8192 0 0 3 16 1003 TCP=5005 xdr queue
1111
B emcStatus SHMEM localhost 20480 0 0 2 16 1002 TCP=5005 xdr
1212

13-
# These are for the IO controller, EMCIO
14-
B toolCmd SHMEM localhost 1024 0 0 4 16 1004 TCP=5005 xdr
15-
B toolSts SHMEM localhost 1024 0 0 5 16 1005 TCP=5005 xdr
16-
1713
# Processes
1814
# Name Buffer Type Host Ops server? timeout master? cnum
1915

2016
P emc emcCommand LOCAL localhost RW 0 1.0 0 0
2117
P emc emcStatus LOCAL localhost W 0 1.0 0 0
2218
P emc emcError LOCAL localhost W 0 1.0 0 0
23-
P emc toolCmd LOCAL localhost W 0 1.0 0 0
24-
P emc toolSts LOCAL localhost R 0 1.0 0 0
2519

2620
P emcsvr emcCommand LOCAL localhost W 1 1.0 1 2
2721
P emcsvr emcStatus LOCAL localhost R 1 1.0 1 2
2822
P emcsvr emcError LOCAL localhost R 1 1.0 1 2
29-
P emcsvr toolCmd LOCAL localhost W 1 1.0 1 2
30-
P emcsvr toolSts LOCAL localhost R 1 1.0 1 2
3123
P emcsvr default LOCAL localhost RW 1 1.0 1 2
3224

33-
P tool emcError LOCAL localhost W 0 1.0 0 3
34-
P tool toolCmd LOCAL localhost R 0 1.0 0 3
35-
P tool toolSts LOCAL localhost W 0 1.0 0 3
3625

3726
P xemc emcCommand LOCAL localhost W 0 10.0 0 10
3827
P xemc emcStatus LOCAL localhost R 0 10.0 0 10

configs/common/linuxcnc_big.nml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,18 @@ B emcCommand SHMEM localhost 8192 0 0 1
1010
B emcError SHMEM localhost 8192 0 0 3 16 1003 TCP=5005 xdr queue
1111
B emcStatus SHMEM localhost 170000 0 0 2 16 1002 TCP=5005 xdr
1212

13-
# These are for the IO controller, EMCIO
14-
B toolCmd SHMEM localhost 2048 0 0 4 16 1004 TCP=5005 xdr
15-
B toolSts SHMEM localhost 155648 0 0 5 16 1005 TCP=5005 xdr
16-
1713
# Processes
1814
# Name Buffer Type Host Ops server? timeout master? cnum
1915

2016
P emc emcCommand LOCAL localhost RW 0 1.0 0 0
2117
P emc emcStatus LOCAL localhost W 0 1.0 0 0
2218
P emc emcError LOCAL localhost W 0 1.0 0 0
23-
P emc toolCmd LOCAL localhost W 0 1.0 0 0
24-
P emc toolSts LOCAL localhost R 0 1.0 0 0
2519

2620
P emcsvr emcCommand LOCAL localhost W 1 1.0 1 2
2721
P emcsvr emcStatus LOCAL localhost R 1 1.0 1 2
2822
P emcsvr emcError LOCAL localhost R 1 1.0 1 2
29-
P emcsvr toolCmd LOCAL localhost W 1 1.0 1 2
30-
P emcsvr toolSts LOCAL localhost R 1 1.0 1 2
3123
P emcsvr default LOCAL localhost RW 1 1.0 1 2
3224

33-
P tool emcError LOCAL localhost W 0 1.0 0 3
34-
P tool toolCmd LOCAL localhost R 0 1.0 0 3
35-
P tool toolSts LOCAL localhost W 0 1.0 0 3
3625

3726
P xemc emcCommand LOCAL localhost W 0 10.0 0 10
3827
P xemc emcStatus LOCAL localhost R 0 10.0 0 10

configs/common/server.nml

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,34 +13,19 @@ B emcCommand SHMEM localhost 8192 0 0 1
1313
B emcStatus SHMEM localhost 10240 0 0 2 16 1002 TCP=5005 xdr
1414
B emcError SHMEM localhost 8192 0 0 3 16 1003 TCP=5005 xdr queue
1515

16-
# These are for the IO controller, EMCIO
17-
B toolCmd SHMEM localhost 1024 0 0 4 16 1004 TCP=5005 xdr
18-
B toolSts SHMEM localhost 4096 0 0 5 16 1005 TCP=5005 xdr
19-
B spindleCmd SHMEM localhost 1024 0 0 6 16 1006 TCP=5005 xdr
20-
B spindleSts SHMEM localhost 1024 0 0 7 16 1007 TCP=5005 xdr
21-
2216
# Processes
2317
# Name Buffer Type Host Ops server? timeout master? cnum
2418

2519
P emc emcCommand LOCAL localhost RW 0 1.0 0 0
2620
P emc emcStatus LOCAL localhost W 0 1.0 0 0
2721
P emc emcError LOCAL localhost W 0 1.0 0 0
28-
P emc toolCmd LOCAL localhost W 0 1.0 0 0
29-
P emc toolSts LOCAL localhost R 0 1.0 0 0
3022

3123
P emcsvr emcCommand LOCAL localhost W 1 1.0 1 2
3224
P emcsvr emcStatus LOCAL localhost R 1 1.0 1 2
3325
P emcsvr emcError LOCAL localhost R 1 1.0 1 2
34-
P emcsvr toolCmd LOCAL localhost W 1 1.0 1 2
35-
P emcsvr toolSts LOCAL localhost R 1 1.0 1 2
3626
P emcsvr default LOCAL localhost RW 1 1.0 1 2
3727

38-
P tool emcError LOCAL localhost W 0 1.0 0 3
39-
P tool toolCmd LOCAL localhost RW 0 1.0 0 3
40-
P tool toolSts LOCAL localhost W 0 1.0 0 3
4128

4229
P xemc emcCommand REMOTE 192.168.0.14 W 0 10.0 0 10
4330
P xemc emcStatus REMOTE 192.168.0.14 R 0 10.0 0 10
4431
P xemc emcError REMOTE 192.168.0.14 R 0 10.0 0 10
45-
P xemc toolCmd REMOTE 192.168.0.14 W 0 10.0 0 10
46-
P xemc toolSts REMOTE 192.168.0.14 R 0 10.0 0 10

scripts/linuxcnc.in

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -541,11 +541,6 @@ if [ -z "$HOMEMOD" ] ; then
541541
HOMEMOD=${retval:-homemod} #use default if not found
542542
fi
543543

544-
545-
# 2.4. get io information
546-
GetFromIniEx IO IO EMCIO EMCIO io
547-
EMCIO=$retval
548-
549544
# 2.5. get task information
550545
GetFromIni TASK TASK
551546
EMCTASK=$retval
@@ -830,19 +825,16 @@ fi
830825
# "halcmd loadrt" can find them
831826
export HAL_RTMOD_DIR=$LINUXCNC_RTLIB_DIR
832827

833-
# 4.3.4. Run io in background if so defined in INI
834-
if [ "$EMCIO" != "" ] ; then
835-
echo "Starting LinuxCNC IO program: $EMCIO" >>$PRINT_FILE
836-
if ! program_available $EMCIO ; then
837-
echo "Can't execute IO program $EMCIO"
838-
Cleanup
839-
exit 1
840-
fi
841-
$HALCMD loadusr -Wn iocontrol $EMCIO -ini "$INIFILE"
842-
else
843-
echo "Skipping LinuxCNC IO program >>$PRINT_FILE"
828+
# 4.3.7. Run task in background
829+
echo "Starting TASK program: $EMCTASK" >>$PRINT_FILE
830+
if ! program_available $EMCTASK ; then
831+
echo "Can't execute TASK program $EMCTASK"
832+
Cleanup
833+
exit 1
844834
fi
845835

836+
halcmd loadusr -Wn iocontrol $EMCTASK -ini "$INIFILE" &
837+
846838
# 4.3.5. Run halui in background, if necessary
847839
if [ -n "$HALUI" ] ; then
848840
echo "Starting HAL User Interface program: $HALUI" >>$PRINT_FILE
@@ -936,17 +928,6 @@ else
936928
done
937929
fi
938930

939-
940-
# 4.3.7. Run task in background
941-
echo "Starting TASK program: $EMCTASK" >>$PRINT_FILE
942-
if ! program_available $EMCTASK ; then
943-
echo "Can't execute TASK program $EMCTASK"
944-
Cleanup
945-
exit 1
946-
fi
947-
948-
halcmd loadusr -Wn inihal $EMCTASK -ini "$INIFILE" &
949-
950931
# 4.3.8. execute discrete HAL commands from INI file (if any)
951932
# get first command from INI file
952933
NUM=1

src/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ SUBDIRS := \
181181
emc/usr_intf/axis emc/usr_intf/touchy emc/usr_intf/stepconf emc/usr_intf/pncconf \
182182
emc/usr_intf/gremlin emc/usr_intf/gscreen emc/usr_intf/pyui emc/usr_intf/qtvcp \
183183
emc/usr_intf/gmoccapy emc/usr_intf/qtplasmac emc/usr_intf/mdro\
184-
emc/usr_intf emc/nml_intf emc/task emc/iotask emc/kinematics emc/tp emc/canterp \
184+
emc/usr_intf emc/nml_intf emc/task emc/kinematics emc/tp emc/canterp \
185185
emc/motion emc/ini emc/rs274ngc emc/sai emc/pythonplugin \
186186
emc/motion-logger \
187187
emc/tooldata \

src/emc/nml_intf/emc.hh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -527,8 +527,6 @@ extern int emcIoAbort(int reason);
527527
extern int emcIoSetCycleTime(double cycleTime);
528528
extern int emcIoSetDebug(int debug);
529529

530-
extern int emcIoUpdate(EMC_IO_STAT * stat);
531-
532530
// implementation functions for EMC aggregate types
533531

534532
extern int emcInit();

src/emc/task/emcsvr.cc

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@
3131
#include "nml_srv.hh" // run_nml_servers()
3232
#include <rtapi_string.h>
3333

34-
static int tool_channels = 1;
35-
3634
static int iniLoad(const char *filename)
3735
{
3836
IniFile inifile;
@@ -63,7 +61,6 @@ static int iniLoad(const char *filename)
6361
} else {
6462
// not found, use default
6563
}
66-
inifile.Find(&tool_channels,"TOOL_CHANNELS","EMC");
6764
// close it
6865
inifile.Close();
6966

@@ -99,8 +96,6 @@ static void daemonize()
9996
static RCS_CMD_CHANNEL *emcCommandChannel = NULL;
10097
static RCS_STAT_CHANNEL *emcStatusChannel = NULL;
10198
static NML *emcErrorChannel = NULL;
102-
static RCS_CMD_CHANNEL *toolCommandChannel = NULL;
103-
static RCS_STAT_CHANNEL *toolStatusChannel = NULL;
10499

105100
int main(int argc, char *argv[])
106101
{
@@ -123,7 +118,6 @@ int main(int argc, char *argv[])
123118

124119
while (fabs(etime() - start_time) < 10.0 &&
125120
(emcCommandChannel == NULL || emcStatusChannel == NULL
126-
|| (tool_channels && (toolCommandChannel == NULL || toolStatusChannel == NULL))
127121
|| emcErrorChannel == NULL)
128122
) {
129123
if (NULL == emcCommandChannel) {
@@ -142,18 +136,6 @@ int main(int argc, char *argv[])
142136
emcErrorChannel =
143137
new NML(nmlErrorFormat, "emcError", "emcsvr", emc_nmlfile);
144138
}
145-
if (tool_channels) {
146-
if (NULL == toolCommandChannel) {
147-
toolCommandChannel =
148-
new RCS_CMD_CHANNEL(emcFormat, "toolCmd", "emcsvr",
149-
emc_nmlfile);
150-
}
151-
if (NULL == toolStatusChannel) {
152-
toolStatusChannel =
153-
new RCS_STAT_CHANNEL(emcFormat, "toolSts", "emcsvr",
154-
emc_nmlfile);
155-
}
156-
}
157139

158140
if (!emcCommandChannel->valid()) {
159141
delete emcCommandChannel;
@@ -167,16 +149,6 @@ int main(int argc, char *argv[])
167149
delete emcErrorChannel;
168150
emcErrorChannel = NULL;
169151
}
170-
if (tool_channels) {
171-
if (!toolCommandChannel->valid()) {
172-
delete toolCommandChannel;
173-
toolCommandChannel = NULL;
174-
}
175-
if (!toolStatusChannel->valid()) {
176-
delete toolStatusChannel;
177-
toolStatusChannel = NULL;
178-
}
179-
}
180152
esleep(0.200);
181153
}
182154

@@ -196,18 +168,6 @@ int main(int argc, char *argv[])
196168
emcErrorChannel =
197169
new NML(nmlErrorFormat, "emcError", "emcsvr", emc_nmlfile);
198170
}
199-
if (tool_channels) {
200-
if (NULL == toolCommandChannel) {
201-
toolCommandChannel =
202-
new RCS_CMD_CHANNEL(emcFormat, "toolCmd", "emcsvr",
203-
emc_nmlfile);
204-
}
205-
if (NULL == toolStatusChannel) {
206-
toolStatusChannel =
207-
new RCS_STAT_CHANNEL(emcFormat, "toolSts", "emcsvr",
208-
emc_nmlfile);
209-
}
210-
}
211171
daemonize();
212172
run_nml_servers();
213173

src/emc/task/emctaskmain.cc

Lines changed: 12 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -840,7 +840,7 @@ static int emcTaskPlan(void)
840840
case EMC_MOTION_SET_AOUT_TYPE:
841841
case EMC_TRAJ_RIGID_TAP_TYPE:
842842
case EMC_TRAJ_SET_TELEOP_ENABLE_TYPE:
843-
case EMC_SET_DEBUG_TYPE:
843+
case EMC_SET_DEBUG_TYPE:
844844
retval = emcTaskIssueCommand(emcCommand);
845845
break;
846846

@@ -962,7 +962,7 @@ static int emcTaskPlan(void)
962962
case EMC_MOTION_ADAPTIVE_TYPE:
963963
case EMC_TRAJ_RIGID_TAP_TYPE:
964964
case EMC_TRAJ_SET_TELEOP_ENABLE_TYPE:
965-
case EMC_SET_DEBUG_TYPE:
965+
case EMC_SET_DEBUG_TYPE:
966966
retval = emcTaskIssueCommand(emcCommand);
967967
break;
968968

@@ -1318,7 +1318,7 @@ static int emcTaskPlan(void)
13181318
case EMC_TRAJ_PROBE_TYPE:
13191319
case EMC_AUX_INPUT_WAIT_TYPE:
13201320
case EMC_TRAJ_RIGID_TAP_TYPE:
1321-
case EMC_SET_DEBUG_TYPE:
1321+
case EMC_SET_DEBUG_TYPE:
13221322
case EMC_COOLANT_MIST_ON_TYPE:
13231323
case EMC_COOLANT_MIST_OFF_TYPE:
13241324
case EMC_COOLANT_FLOOD_ON_TYPE:
@@ -1416,7 +1416,7 @@ static int emcTaskPlan(void)
14161416
case EMC_MOTION_SET_AOUT_TYPE:
14171417
case EMC_MOTION_ADAPTIVE_TYPE:
14181418
case EMC_TRAJ_RIGID_TAP_TYPE:
1419-
case EMC_SET_DEBUG_TYPE:
1419+
case EMC_SET_DEBUG_TYPE:
14201420
retval = emcTaskIssueCommand(emcCommand);
14211421
break;
14221422

@@ -1548,7 +1548,7 @@ static int emcTaskCheckPreconditions(NMLmsg * cmd)
15481548
return EMC_TASK_EXEC_WAITING_FOR_MOTION_AND_IO;
15491549
break;
15501550

1551-
case EMC_TOOL_PREPARE_TYPE:
1551+
case EMC_TOOL_PREPARE_TYPE:
15521552
case EMC_LUBE_ON_TYPE:
15531553
case EMC_LUBE_OFF_TYPE:
15541554
return EMC_TASK_EXEC_WAITING_FOR_IO;
@@ -2470,7 +2470,7 @@ static int emcTaskCheckPostconditions(NMLmsg * cmd)
24702470
case EMC_SPINDLE_ON_TYPE:
24712471
case EMC_SPINDLE_OFF_TYPE:
24722472
case EMC_SPINDLE_ORIENT_TYPE:
2473-
case EMC_COOLANT_MIST_ON_TYPE:
2473+
case EMC_COOLANT_MIST_ON_TYPE:
24742474
case EMC_COOLANT_MIST_OFF_TYPE:
24752475
case EMC_COOLANT_FLOOD_ON_TYPE:
24762476
case EMC_COOLANT_FLOOD_OFF_TYPE:
@@ -3015,26 +3015,6 @@ static int emctask_startup()
30153015
return -1;
30163016
}
30173017

3018-
end = RETRY_TIME;
3019-
good = 0;
3020-
do {
3021-
if (0 == emcIoUpdate(&emcStatus->io)) {
3022-
good = 1;
3023-
break;
3024-
}
3025-
esleep(RETRY_INTERVAL);
3026-
end -= RETRY_INTERVAL;
3027-
if (done) {
3028-
emctask_shutdown();
3029-
exit(1);
3030-
}
3031-
} while (end > 0.0);
3032-
if (!good) {
3033-
rcs_print_error("can't read IO status\n");
3034-
return -1;
3035-
}
3036-
3037-
30383018
// now motion
30393019

30403020
end = RETRY_TIME;
@@ -3337,16 +3317,14 @@ int main(int argc, char *argv[])
33373317
// moved up from emc_startup so we can expose it in Python right away
33383318
emcStatus = new EMC_STAT;
33393319

3340-
#ifdef TOOL_NML //{
3341-
tool_nml_register( (CANON_TOOL_TABLE*)&emcStatus->io.tool.toolTable);
3342-
#else //}{
3343-
tool_mmap_user();
3344-
// initialize database tool finder:
3345-
#endif //}
33463320
// get the Python plugin going
33473321

33483322
// inistantiate task methods object, too
3349-
emcTaskOnce(emc_inifile);
3323+
if (emcTaskOnce(emc_inifile, emcStatus->io)) {
3324+
rcs_print_error("can't initialize task object / HAL\n");
3325+
emctask_shutdown();
3326+
exit(1);
3327+
}
33503328
rtapi_strxcpy(emcStatus->task.ini_filename, emc_inifile);
33513329
if (task_methods == NULL) {
33523330
set_rcs_print_destination(RCS_PRINT_TO_STDOUT); // restore diag
@@ -3408,7 +3386,6 @@ int main(int argc, char *argv[])
34083386
}
34093387
// update subordinate status
34103388

3411-
emcIoUpdate(&emcStatus->io);
34123389
emcMotionUpdate(&emcStatus->motion);
34133390
// synchronize subordinate states
34143391
if (emcStatus->io.aux.estop) {
@@ -3596,6 +3573,7 @@ int main(int argc, char *argv[])
35963573
} else {
35973574
timer->wait();
35983575
}
3576+
task_methods->run();
35993577
}
36003578
// end of while (! done)
36013579

src/emc/task/task.hh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ extern int steppingWait;
2222
extern int emcTaskQueueCommand(NMLmsg *cmd);
2323
extern int emcPluginCall(EMC_EXEC_PLUGIN_CALL *call_msg);
2424
extern int emcIoPluginCall(EMC_IO_PLUGIN_CALL *call_msg);
25-
extern int emcTaskOnce(const char *inifile);
25+
extern int emcTaskOnce(const char *inifile, EMC_IO_STAT &emcioStatus);
2626
extern int emcRunHalFiles(const char *filename);
2727

2828
// Returns 0 if all joints are homed, 1 if any joints are un-homed.

0 commit comments

Comments
 (0)