/*----------------------------------------------------------------------------+ | | | Enhanced HEYU Functionality | | Copyright 2002-2007 Charles W. Sullivan | | All Rights Reserved | | | | | | This software is licensed free of charge for non-commercial distribution | | and for personal and internal business use only. Inclusion of this | | software or any part thereof in a commercial product is prohibited | | without the prior written permission of the author. You may copy, use, | | and distribute this software subject to the following restrictions: | | | | 1) You may not charge money for it. | | 2) You may not remove or alter this license, copyright notice, or the | | included disclaimers. | | 3) You may not claim you wrote it. | | 4) If you make improvements (or other changes), you are requested | | to send them to the Heyu maintainer so there's a focal point for | | distributing improved versions. | | | | As used herein, HEYU is a trademark of Daniel B. Suthers. | | X10, CM11A, and ActiveHome are trademarks of X-10 (USA) Inc. | | The author is not affiliated with either entity. | | | | Charles W. Sullivan | | Co-author and Maintainer | | Greensboro, North Carolina | | Email ID: cwsulliv01 | | Email domain: -at- heyu -dot- org | | | | Disclaimers: | | THERE IS NO ASSURANCE THAT THIS SOFTWARE IS FREE OF DEFECTS AND IT MUST | | NOT BE USED IN ANY SITUATION WHERE THERE IS ANY CHANCE THAT ITS | | PERFORMANCE OR FAILURE TO PERFORM AS EXPECTED COULD RESULT IN LOSS OF | | LIFE, INJURY TO PERSONS OR PROPERTY, FINANCIAL LOSS, OR LEGAL LIABILITY. | | | | TO THE EXTENT ALLOWED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED "AS IS",| | WITH NO EXPRESS OR IMPLIED WARRANTY, INCLUDING, BUT NOT LIMITED TO, THE | | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.| | | | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW WILL THE AUTHOR BE LIABLE | | FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL | | DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THIS SOFTWARE EVEN IF | | THE AUTHOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. | | | +----------------------------------------------------------------------------*/ #include #include #include #include #include #include #if defined(SYSV) || defined(FREEBSD) || defined(OPENBSD) #include #else #include #endif #if (defined(NSLEEP) || defined(ATTSVR4)) #include #endif /* NSLEEP | ATTSVR4 */ #include #include "x10.h" #include "process.h" extern int tty, tty_aux; extern int line_no; extern int sptty, i_am_relay, i_am_aux; extern int heyu_parent; extern int verbose; extern int xwrite(), exread(), sxread(), check4poll(); extern int is_modem_support(void); extern CONFIG config; extern CONFIG *configp; unsigned char alert_cmd[6]; unsigned char alert_ack[3]; int special_func = 0; char *typename[] = {"???", "Scene", "Usersyn"}; #if 0 /* Reference - Flags for parse_addr() function */ #define A_VALID 1 #define A_HCODE 2 #define A_BMAP 4 #define A_PLUS 8 #define A_MINUS 16 #define A_ALIAS 32 #define A_DUMMY 64 #define A_MULT 128 #endif /* Reference */ /* Arguments for the various commands */ static char *helparg[] = { "[H]", /* 0 HC optional */ "H", /* 1 HC only */ "Hu", /* 2 HC | single unit */ "HU", /* 3 HC | unit string */ "HU ", /* 4 Dim/Bright level*/ "HU ", /* 5 Preset dim level*/ "", /* 6 Preset dim level only */ "HU ", /* 7 Extended Preset level*/ " HU ", /* 8 Arbitrary extended code command (hex)*/ "", /* 9 Send HC|Funct only, no address */ "xx xx xx ...", /* 10 Arbitrary hex bytes */ "H <\"text\">", /* 11 Arbitrary quoted text message */ "", /* 12 No arguments */ "[]", /* 13 For help command */ "N.NNN", /* 14 Pause delay */ "HU [HU [...]]", /* 15 Multiple addresses */ "HU ", /* 16 For Turn command */ "", /* 17 Special functions */ "HU ", /* 18 Preset for macros */ "H ", /* 19 Ext status_ack mode */ "<\"text\">", /* 20 Message to log file */ "NNN", /* 21 Delay in minutes */ "H[U] ", /* 22 RF Dim/Bright */ "xx xx ", /* 23 Two hex bytes */ "HU ", /* 24 RF Dimbo */ "H[u]", /* 25 State commands */ "n[,n...]", /* 26 Flag set/clear commands */ "H[U]", /* 27 Status flag clear command */ "HU ", /* 28 Virtual data */ "N ", /* 29 Countdown timer */ "xxxx xxxx ...", /* 30 Multiple 16-bit hex words */ "", /* 31 Special for UX17/23 command */ "HU g ", /* 32 Include in group at level*/ "HU g[,g,...]", /* 33 Delete from group(s) */ "H G", /* 34 Execute group[.subgroup] functions */ "HU G", /* 35 Include in group[.subgroup] */ "H g[,g,...]", /* 36 Delete from group(s) */ "HU ", /* 37 Extended Preset level with ramp*/ }; static char *options[] = { "Usage: heyu [options] (Run 'heyu help' for commands)\n", " [Options]", " -v Enable verbose mode", " -c Specify full configuration file pathname", " -s Specify full schedule file pathname", " -0 ... -9 Config file is in subdirectory /0 ... /9", " of standard location, e.g., $HOME/.heyu/3/x10config", }; /* Descriptions of "administrative" commands */ static char *helpadmin[][3] = { {"info","","Display CM11A registers, clock, and upload status"}, {"help","[command]","This screen, or specific command help"}, {"start","","Start Heyu background processes (daemons)"}, {"stop","","Stop Heyu background processes"}, {"restart","","Reconfigure running Heyu background processes"}, {"engine","","Start the (optional) Heyu state engine daemon"}, {"aux","","Start the (optional) Heyu auxiliary RF input daemon"}, {"monitor","","Monitor X10 activity (end with )"}, {"date","","Return date in date(1) input format"}, {"erase","","Zero CM11A EEPROM, erasing all events and macros"}, {"syn","","Display built-in synonyms for direct commands"}, {"