📄 usrmot.c
字号:
} else if (!strcmp(cmd, "phl")) { emcmotCommand.axisFlag = EMCMOT_AXIS_MAX_HARD_LIMIT_BIT; } else if (!strcmp(cmd, "homedir")) { emcmotCommand.axisFlag = EMCMOT_AXIS_HOMING_BIT; } else if (!strcmp(cmd, "homesw")) { emcmotCommand.axisFlag = EMCMOT_AXIS_HOME_SWITCH_BIT; } else if (!strcmp(cmd, "fault")) { emcmotCommand.axisFlag = EMCMOT_AXIS_FAULT_BIT; } else { valid = 0; } if (valid) { emcmotCommand.command = EMCMOT_SET_POLARITY; if (usrmotWriteEmcmotCommand(&emcmotCommand) == -1) { fprintf(stderr, "Can't send a command to RT-task\n"); } } else { printf ("syntax: pol <axis 0..n-1> <enable nhl phl homedir homesw fault> <0 1>\n"); } } } else if (!strcmp(cmd, "pid")) { if (1 != sscanf(input, "%*s %d", &emcmotCommand.axis) || emcmotCommand.axis < 0 || emcmotCommand.axis >= EMCMOT_MAX_AXIS || 1 != sscanf(input, "%*s %*s %s", filename)) { printf("syntax: pid <n> <ini file>\n"); } else { /* load params into pid struct from inifile */ if (0 != pidIniLoad(&emcmotCommand.pid, filename)) { fprintf(stderr, "error loading pid params from %s\n", filename); } else { emcmotCommand.command = EMCMOT_SET_PID; if (usrmotWriteEmcmotCommand(&emcmotCommand) == -1) { fprintf(stderr, "Can't send a command to RT-task\n"); } } }#endif } else if (!strcmp(cmd, "limit")) { if (3 != sscanf(input, "%*s %d %lf %lf", &emcmotCommand.axis, &emcmotCommand.minLimit, &emcmotCommand.maxLimit)) { printf("syntax: limit <axis> <min> <max>\n"); } else { emcmotCommand.command = EMCMOT_SET_POSITION_LIMITS; if (usrmotWriteEmcmotCommand(&emcmotCommand) == -1) { fprintf(stderr, "Can't send a command to RT-task\n"); } }/*! \todo Another #if 0 */#if 0 /* obsolete command */ } else if (!strcmp(cmd, "clamp")) { if (3 != sscanf(input, "%*s %d %lf %lf", &emcmotCommand.axis, &emcmotCommand.minLimit, &emcmotCommand.maxLimit)) { printf("syntax: clamp <axis> <min> <max>\n"); } else { emcmotCommand.command = EMCMOT_SET_OUTPUT_LIMITS; if (usrmotWriteEmcmotCommand(&emcmotCommand) == -1) { fprintf(stderr, "Can't send a command to RT-task\n"); } }#endif } else if (!strcmp(cmd, "ferror")) { if (2 != sscanf(input, "%*s %d %lf", &emcmotCommand.axis, &emcmotCommand.maxFerror)) { printf("syntax: ferror <axis> <ferror>\n"); } else { emcmotCommand.command = EMCMOT_SET_MAX_FERROR; if (usrmotWriteEmcmotCommand(&emcmotCommand) == -1) { fprintf(stderr, "Can't send a command to RT-task\n"); } } } else if (!strcmp(cmd, "live")) { if (1 != sscanf(input, "%*s %d", &emcmotCommand.axis) || emcmotCommand.axis < 0 || emcmotCommand.axis >= EMCMOT_MAX_AXIS) { printf("syntax: live <n>\n"); } else { emcmotCommand.command = EMCMOT_ENABLE_AMPLIFIER; if (usrmotWriteEmcmotCommand(&emcmotCommand) == -1) { fprintf(stderr, "Can't send a command to RT-task\n"); } } } else if (!strcmp(cmd, "kill")) { if (1 != sscanf(input, "%*s %d", &emcmotCommand.axis) || emcmotCommand.axis < 0 || emcmotCommand.axis >= EMCMOT_MAX_AXIS) { printf("syntax: kill <n>\n"); } else { emcmotCommand.command = EMCMOT_DISABLE_AMPLIFIER; if (usrmotWriteEmcmotCommand(&emcmotCommand) == -1) { fprintf(stderr, "Can't send a command to RT-task\n"); } } } else if (!strcmp(cmd, "activate")) { if (1 != sscanf(input, "%*s %d", &emcmotCommand.axis) || emcmotCommand.axis < 0 || emcmotCommand.axis >= EMCMOT_MAX_AXIS) { printf("syntax: activate <n>\n"); } else { emcmotCommand.command = EMCMOT_ACTIVATE_JOINT; if (usrmotWriteEmcmotCommand(&emcmotCommand) == -1) { fprintf(stderr, "Can't send a command to RT-task\n"); } } } else if (!strcmp(cmd, "deactivate")) { if (1 != sscanf(input, "%*s %d", &emcmotCommand.axis) || emcmotCommand.axis < 0 || emcmotCommand.axis >= EMCMOT_MAX_AXIS) { printf("syntax: deactivate <n>\n"); } else { emcmotCommand.command = EMCMOT_DEACTIVATE_JOINT; if (usrmotWriteEmcmotCommand(&emcmotCommand) == -1) { fprintf(stderr, "Can't send a command to RT-task\n"); } }/*! \todo Another #if 0 */#if 0 } else if (!strcmp(cmd, "dac")) { if (2 == sscanf(input, "%*s %d %lf", &emcmotCommand.axis, &emcmotCommand.dacOut)) { emcmotCommand.command = EMCMOT_DAC_OUT; if (usrmotWriteEmcmotCommand(&emcmotCommand) == -1) { fprintf(stderr, "Can't send a command to RT-task\n"); } } else { printf("syntax: dac <num> <-10.0 .. 10.0>\n"); }#endif } else if (!strcmp(cmd, "home")) { if (1 == sscanf(input, "%*s %d", &emcmotCommand.axis)) { emcmotCommand.command = EMCMOT_HOME; if (usrmotWriteEmcmotCommand(&emcmotCommand) == -1) { fprintf(stderr, "Can't send a command to RT-task\n"); } } else { printf("syntax: home <axis>\n"); } } else if (!strcmp(cmd, "nolim")) { emcmotCommand.command = EMCMOT_OVERRIDE_LIMITS; if (usrmotWriteEmcmotCommand(&emcmotCommand) == -1) { fprintf(stderr, "Can't send a command to RT-task\n"); } }#ifdef ENABLE_PROBING else if (!strcmp(cmd, "probeclear")) { emcmotCommand.command = EMCMOT_CLEAR_PROBE_FLAGS; if (usrmotWriteEmcmotCommand(&emcmotCommand) == -1) { fprintf(stderr, "Can't send a command to RT-task\n"); }/*! \todo Another #if 0 */#if 0 } else if (!strcmp(cmd, "probeindex")) { if (1 == sscanf(input, "%*s %d", &emcmotCommand.probeIndex)) { emcmotCommand.command = EMCMOT_SET_PROBE_INDEX; if (usrmotWriteEmcmotCommand(&emcmotCommand) == -1) { fprintf(stderr, "Can't send a command to RT-task\n"); } } else { printf("syntax: probeindex <index>\n"); } } else if (!strcmp(cmd, "probepolarity")) { if (1 == sscanf(input, "%*s %d", &emcmotCommand.level)) { emcmotCommand.command = EMCMOT_SET_PROBE_POLARITY; if (usrmotWriteEmcmotCommand(&emcmotCommand) == -1) { fprintf(stderr, "Can't send a command to RT-task\n"); } } else { printf("syntax: probepolarity <polarity>\n"); }#endif } else if (!strcmp(cmd, "probe")) { if (3 == sscanf(input, "%*s %lf %lf %lf", &emcmotCommand.pos.tran.x, &emcmotCommand.pos.tran.y, &emcmotCommand.pos.tran.z)) { emcmotCommand.command = EMCMOT_PROBE; emcmotCommand.id = motionId++; if (usrmotWriteEmcmotCommand(&emcmotCommand) == -1) { fprintf(stderr, "Can't send a command to RT-task\n"); } } else { printf("syntax: probe <x> <y> <z>\n"); } }#endif /* ENABLE_PROBING */ else if (!strcmp(cmd, "wd")) { valid = 0; if (1 == sscanf(input, "%*s %s", cmd)) { if (!strcmp(cmd, "on")) { if (1 != sscanf(input, "%*s %*s %d", &emcmotCommand.wdWait) || emcmotCommand.wdWait < 0) { /* no or bad submultiple arg-- use 1 */ emcmotCommand.wdWait = 0; } emcmotCommand.command = EMCMOT_ENABLE_WATCHDOG; valid = 1; } else if (!strcmp(cmd, "off")) { emcmotCommand.command = EMCMOT_DISABLE_WATCHDOG; valid = 1; } } if (valid) { if (usrmotWriteEmcmotCommand(&emcmotCommand) == -1) { fprintf(stderr, "Can't send a command to RT-task\n"); } } else { printf("syntax: wd on {<waits>} | off\n"); } } else if (!strcmp(cmd, "comp")) { if (1 != sscanf(input, "%*s %d", &axis)) { fprintf(stderr, "syntax: comp <axis> {<file>}\n"); } else { /* try a string for the compfile, else it's blank which means print */ if (1 == sscanf(input, "%*s %*d %s", compfile)) { if (0 != usrmotLoadComp(axis, compfile)) { fprintf(stderr, "Can't load comp file %s\n", compfile); } } else { if (0 != usrmotPrintComp(axis)) { fprintf(stderr, "Can't print comp table\n"); } } } } else if (!strcmp(cmd, "alter")) { if (1 != sscanf(input, "%*s %d", &axis)) { fprintf(stderr, "syntax: alter <axis> {<value>}\n"); } else { /* try a double for the alter val, else it's blank which means print */ if (1 == sscanf(input, "%*s %*d %lf", &alter)) { if (0 != usrmotAlter(axis, alter)) { fprintf(stderr, "Can't set alter value %f\n", alter); } } else { if (0 != usrmotQueryAlter(axis, &alter)) { fprintf(stderr, "Can't print alter value\n"); } else { printf("axis %d alter: %f\n", axis, alter); } } } } else { if (anyprintable(input)) { printf("huh? : %s", input); /* input will have newline */ } else { /* blank line was typed */ /* print status */ switch (statconfigdebug) { case 0:/*! \todo Another #if 0 */#if 0 if (0 == (errCode = usrmotReadEmcmotStatus(&emcmotStatus))) { usrmotPrintEmcmotStatus(emcmotStatus, lastPrint); } else { fprintf(stderr, "can't read status: %s\n", errCode == EMCMOT_COMM_ERROR_CONNECT ? "EMCMOT_COMM_ERROR_CONNECT" : errCode == EMCMOT_COMM_ERROR_TIMEOUT ? "EMCMOT_COMM_ERROR_TIMEOUT" : errCode == EMCMOT_COMM_ERROR_COMMAND ? "EMCMOT_COMM_ERROR_COMMAND" : errCode == EMCMOT_COMM_SPLIT_READ_TIMEOUT ? "EMCMOT_COMM_SPLIT_READ_TIMEOUT" : "?"); }#endif break; case 1: if (0 == (errCode = usrmotReadEmcmotDebug(&emcmotDebug))) { usrmotPrintEmcmotDebug(emcmotDebug, lastPrint); } else { fprintf(stderr, "can't read debug: %s\n", errCode == EMCMOT_COMM_ERROR_CONNECT ? "EMCMOT_COMM_ERROR_CONNECT" : errCode == EMCMOT_COMM_ERROR_TIMEOUT ? "EMCMOT_COMM_ERROR_TIMEOUT" : errCode == EMCMOT_COMM_ERROR_COMMAND ? "EMCMOT_COMM_ERROR_COMMAND" : errCode == EMCMOT_COMM_SPLIT_READ_TIMEOUT ? "EMCMOT_COMM_SPLIT_READ_TIMEOUT" : "?"); } break; case 2: if (0 == (errCode = usrmotReadEmcmotConfig(&emcmotConfig))) { usrmotPrintEmcmotConfig(emcmotConfig, lastPrint); } else { fprintf(stderr, "can't read config: %s\n", errCode == EMCMOT_COMM_ERROR_CONNECT ? "EMCMOT_COMM_ERROR_CONNECT" : errCode == EMCMOT_COMM_ERROR_TIMEOUT ? "EMCMOT_COMM_ERROR_TIMEOUT" : errCode == EMCMOT_COMM_ERROR_COMMAND ? "EMCMOT_COMM_ERROR_COMMAND" : errCode == EMCMOT_COMM_SPLIT_READ_TIMEOUT ? "EMCMOT_COMM_SPLIT_READ_TIMEOUT" : "?"); } break; default: break; } /* end of switch */ } /* end of else blank line */ } /* end of big-if input matching */ } /* end of non-number input processing */ } /* end of while stdin */ usrmotExit(); exit(0);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -