1 /*******************************************************************
2 Motion and Robotic System (MARS) aplication components
4 appl_cmds.c - application specific commands - mainly global
5 PXMC state manipulation for RoCoN
7 Copyright (C) 2001-2014 by Pavel Pisa - originator
9 (C) 2001-2014 by PiKRON Ltd. - originator
12 This file can be used and copied according to next
14 - GPL - GNU Public License
15 - other license provided by project originators
17 *******************************************************************/
20 #include <system_def.h>
23 #include <pxmc_coordmv.h>
25 #include <pxmc_cmds.h>
28 #include "appl_defs.h"
30 int sqrtll_main(int argc, char *argv[]);
31 int cmd_do_stop_all(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[]);
32 int cmd_do_release_all(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[]);
33 int cmd_do_status_bsybits(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[]);
34 int cmd_do_axst_all(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[]);
35 int cmd_do_cer_all(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[]);
36 int cmd_do_clr_all(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[]);
38 unsigned short statchk_power_stop=0;
39 unsigned short statchk_power_off=0;
41 int cmd_do_status_all(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
48 if((opchar=cmd_opchar_check(cmd_io,des,param))<0) return opchar;
51 pxmc_for_each_mcs(i, mcs) {
55 if(pxmc_coordmv_checkst(&pxmc_coordmv_state)>=2)
56 val|=PXMS_CQF_m; /* coordinator coomand queue full */
59 if(statchk_power_stop)
63 return cmd_opchar_replong(cmd_io, param, val, 0, 0);
68 int cmd_do_pthalign(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
73 if((mcs=cmd_opchar_getreg(cmd_io,des,param))==NULL) return -CMDERR_BADREG;
76 return cmd_opchar_replong(cmd_io, param, (long)mcs->pxms_ptmark, 0, 0);
79 if(*param[2]!=':') return -CMDERR_OPCHAR;
81 res = pxmc_rocon_pthalalign(mcs, 20);
84 return -CMDERR_BADDIO;
90 * cmd_do_axis_mode - checks the command format and busy flag validity, calls pxmc_axis_mode
92 * if pxmc_axis_mode returns -1, cmd_do_axis_mode returns -1.
94 int cmd_do_axis_mode(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
99 if((mcs=cmd_opchar_getreg(cmd_io,des,param))==NULL) return -CMDERR_BADREG;
102 return cmd_opchar_replong(cmd_io, param, pxmc_axis_rdmode(mcs), 0, 0);
105 if(*param[2]!=':') return -CMDERR_OPCHAR;
107 if(mcs->pxms_flg&PXMS_BSY_m) return -CMDERR_BSYREG;
110 val=pxmc_axis_mode(mcs,val);
117 int cmd_do_sqrtll(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
121 sqrtll_main(!ps?1: !*ps? 1: 2, param);
125 cmd_des_t const cmd_des_cer_all={0, CDESM_OPCHR,"PURGE","clear error flags and release failded axes",
127 cmd_des_t const cmd_des_clr_all={0, CDESM_OPCHR,
128 "CLEAR",0,cmd_do_clr_all,{}};
129 cmd_des_t const cmd_des_stop_all={0, CDESM_OPCHR,
130 "STOP","stop all motions",cmd_do_stop_all,{}};
131 cmd_des_t const cmd_des_release_all={0, CDESM_OPCHR,
132 "RELEASE","releases all axes closed loop control",cmd_do_release_all,{}};
133 cmd_des_t const cmd_des_status_all={0, CDESM_OPCHR|CDESM_RD,
134 "ST","system status bits encoded in number",
135 cmd_do_status_all,{}};
136 cmd_des_t const cmd_des_status_bsybits={0, CDESM_OPCHR|CDESM_RD,
137 "STBSYBITS","busy bits of all axes in one number",
138 cmd_do_status_bsybits,{}};
139 cmd_des_t const cmd_des_stamp={0, CDESM_OPCHR,
140 "STAMP","host communication stamp",
142 cmd_des_t const cmd_des_pthalign={0, CDESM_OPCHR|CDESM_RW,"PTHALIGN?","run alignement of phase according to HAL",
145 cmd_des_t const cmd_des_axis_mode={0, CDESM_OPCHR|CDESM_WR,
146 "REGMODE?","axis working mode",cmd_do_axis_mode,
148 cmd_des_t const cmd_des_sqrtll={0, 0,"sqrtll","test 64-bit square root computation",
152 cmd_des_t const *const cmd_appl_specific[]={
155 &cmd_des_release_all,
157 &cmd_des_status_bsybits,