1 /*******************************************************************
2 Motion and Robotic System (MARS) aplication components
4 appl_cmds.c - application specific commands
6 Copyright (C) 2001-2015 by Pavel Pisa - originator
8 (C) 2001-2015 by PiKRON Ltd. - originator
11 This file can be used and copied according to next
13 - GPL - GNU Public License
14 - other license provided by project originators
16 *******************************************************************/
19 #include <system_def.h>
25 #include "appl_defs.h"
28 #define __STRINGIFY(x) #x /* stringify without expanding x */
31 #define STRINGIFY(x) __STRINGIFY(x) /* expand x, then stringify */
34 int cmd_do_ioecho(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
39 if((opchar=cmd_opchar_check(cmd_io, des, param))<0) return opchar;
43 cmd_io->priv.ed_line.in->flg &= ~FL_ELB_ECHO;
45 cmd_io->priv.ed_line.in->flg |= FL_ELB_ECHO;
46 else return -CMDERR_BADPAR;
48 cmd_io_write(cmd_io, param[0], param[2]-param[0]);
49 cmd_io_putc(cmd_io,'=');
50 cmd_io_putc(cmd_io,cmd_io->priv.ed_line.in->flg & FL_ELB_ECHO?'1':'0');
55 const char software_ver[]="LX_DAD v"STRINGIFY(SW_VER_MAJOR)"."STRINGIFY(SW_VER_MINOR)
56 " build Pi "__DATE__" "__TIME__;
58 int cmd_do_ver(cmd_io_t *cmd_io, const struct cmd_des *des, char *param[])
60 if(*param[2]!='?') return -CMDERR_OPCHAR;
61 cmd_io_write(cmd_io,param[0],param[2]-param[0]);
62 cmd_io_putc(cmd_io,'=');
63 cmd_io_write(cmd_io,software_ver,strlen(software_ver));
67 cmd_des_t const cmd_des_stamp={0, CDESM_OPCHR,
68 "STAMP","host communication stamp",
70 cmd_des_t const cmd_des_echo={0, CDESM_OPCHR|CDESM_RW,
71 "ECHO","enable echoing of received character",cmd_do_ioecho,{}};
72 cmd_des_t const cmd_des_ver={0, CDESM_OPCHR|CDESM_RD,
73 "VER","software version",cmd_do_ver,{}};
75 cmd_des_t const *const cmd_appl_specific[]={