[LHA-misc] Sample Commands (was Line parsing routine)
Status: Beta
Brought to you by:
ncherry
From: Jay H. <jh...@fa...> - 2000-11-28 05:20:00
|
Ok, This is from memory and reviewing code since I can't find my paper copy of this and my HD died in March... I've included 2 things inline: - Command/Response document - Sample XML configuration for some of my devices. This is the "Master" defintion that controls the what/where of all devices that can be access by the control server. - Currently called '/usr/local/ha/conf/interface.conf' - Used by every agent. Start the agent with an 'id' code that is xrefed in this file to get port/address/device/password/etc. - The "id" is the prefix to addresses from the server application (ie ADDR="napco9600:device.domain.point") Sorry it is so long... I considered it as an attachment but I know how this group likes to debate inline. If you want it as an attachment next time just say so. Jay ----- Begin Command/Response Document --------- Sample telnet protocol for HA interfaces ************************************************************************** Commands and Syntax ************************************************************************** All commands are case insensitive and are entered one-per-line terminated by a CR or CR/LF. ---------------------------------------- Core "Agent-1.0" Commands ---------------------------------------- USER - Login Request Used to perform a basic login for control purposes. Format: USER <username> Expected Response(s): Notes: - The paramater of this command is case sensitive. PASS - Provide a password Supply a password for the pending USER login request. Format: PASS <password> Expected Response(s): Notes: - The paramater of this command is case sensitive. QUIT Terminate the management session. Format: QUIT Expected Response(s): Notes: - Allowed before User/Pass. IDENT - Identifies the module you are talking to Used to provide an application a method to identify what it has attached to in order to validate configuration data (ie, make sure IP/Port and Module match) Format: IDENT Expected Response(s): 1225 [Module Identifier] where [Module Identifier] could be: OCELOT-1.0, LEOPARD-1.0, ADICON-1.0, NAPCO9600, ... Notes: - Allowed before User/Pass. LANG Provide identification of the language subset supported by the management module. Format: LANG Expected Response(s): 1226 [Language Identifier] where [Language Identifier] can be one or more of the following separated by spaces: Agent-1.0 - Agent command syntax version 1.0 ModX - Module specific extensions Notes: - Login required. HELP Provide some level of help for basic commands since all of us forget things. Some of us more than others these days. Format: HELP [command] Expected Response(s): 1210-Supported commands: USER PASS LANG QUIT HELP SET GET DUMP WDOG EVENT 1210 Supported commands: 1211-Command help: HELP - Provide detailed information about commands If you need help this badly you shouldn't be playing with your home controls! 1211 Command help: Notes: - Login required. (anti-hack) SET Change the current values of controllable information. Format: SET ADDR="..." VALUE="..." Expected Response(s): TBD - Need Good/Bad. Probably also need to echo ADDR, VALUE in response to handle things like relative adjustments well. 1310 Invalid address. 1311 Invalid value. Notes: - Login required (obviously) GET Retrieve the current value of controllable information. Format: GET ADDR="..." Expected Response(s): TBD - Need Good/Bad. Needs to include ADDR and VALUE. Notes: - Login required (obviously) DUMP Used for dumping large amounts of information. This is designed primarily for manual command interface assitance but can be used by a program to enumerate supported addresses. Format: DUMP ADDR="<wildcard address>" where <wildcard address> can be in the format of: *, device.*, device.domain.*, *.*.*.* Expected Response(s): 1250-Configuration dump: Addr="..." Value="..." Desc="..." Range="#,#" Unit="..." ValueTypes="Absolute,Relative" 1250 Configuration dump: Notes: - Login required (obviously) WDOG Format: WDOG <timeout> where <timeout> is time in seconds with no response before a session is declared "dead" and the agent can take appropriate action to cleanup as necessary. Expected Response(s): 1222 Watchdog set. 1312 Invalid timeout. Notes: - An event 8010 will be generated at 1/2 the time to the timeout. ie, a 120 watchdog will generate an event at 60 seconds. - Any command will reset the watchdog. EVENT Sets the mask for events to be received. Format: EVENT [CLEAR|8XXX|9XXX|WDOG] Expected Response(s): 1213 Event mask set (Current mask is xxxxx) 1313 Unrecognized event mask. Response on expiration of timer: 1513 Watchdog timeout. Session closed. Notes: - This controls whether 8xxx/9xxx events are to be sent to this session. If WDOG events are not enabled you will not receive the WDOG timeout event at the midpoint but you will receive the 15xx code on expiration. ---------------------------------------- Module Specific "ModX" Commands ---------------------------------------- MODX - Module Specific implementation Used to provide special interfaces to modules. This is designed to be a "catch all" and the paramaters are defined as-needed on a module implementation basis. Purpose of this command include: - Firmware Download - Direct memory access - IR Download - Direct Serial command/response - Speech Download ************************************************************************** Standard Data Identifiers ************************************************************************** ADDR - Address device.domain.point -or- device.domain.group.point Note: The discussion of numeric vs text addresses is valid. I have considered the validity of the following (and plan on implementing): For an Ocelot: Addr="0.x10.A1" Addr="0.timer.0" TS - Timestamp YYYYMMDDHHMMSS VALUE - New value to assign This must cover a wide variety of options so ideas are: Value="100" - Absolute value (scaling based on device) Value="+1" "-1" - Relative scaling Value="On" "Off" - Textual names depending on device On receipt of events/commands you would get something like: Addr="0.x10.A1" Value="On" (Received X10 A1 On) Addr="0.IR.27" Value="On" (Received IR slot 27) ************************************************************************** Responses/Error Codes ************************************************************************** All responses follow the standard FTP/SMTP response format of a number, continuation identifer, and text. Responses are broken down into the following classes: 1XXX = Standard Command/Response 12XX Success 13xx Temp Failure (login password required) 15xx Perm Failure 8XXX Status Messages (events received) 9XXX Alarms (failures) in a form similar to 8XXX but not fully thought through. 1XXX response are generated in response to a command presented. 8XXX and 9XXX are unique in they can be generated at any point in time (including while waiting for a command response) to signal a significant event. These events can be, but not limited to, receipt of a command (IR/X10), expiration of the watchdog, change in status of a sensor (Alarm, temperature), or what would be considered a "management" alarm condition (9XXX) where contact is lost with a device. During the processing of command/response any 8XXX or 9XXX event received needs to be queued and handled after the command/response. On a multi-part received (XXXX-, data, XXXX) tbe events will not arrive within the message-enclosed data. 1XXX Series responses ---------------------------------------- 1210 Supported commands: 1211 Command help: 1213 Event mask set (Current mask is xxxxx) 1220 Initial logon message (Welcome to the CPUXA daemon v1.00) 1221 Goodbye. 1222 Watchdog set. 1225 [Module Identifier] 1226 [Language Identifiers] 1230 Login successful. 1250 Configuration dump: 1310 Invalid address. 1311 Invalid value. 1312 Invalid timeout. 1313 Unrecognized event mask. 1331 Password required.(response to USER when password required) 1513 Watchdog timeout. Session closed. 1530 Login failed. 8XXX Series responses ---------------------------------------- 8000 Generic event message. Contains at least the following data: YYYYMMDDHHMMSS.SSS TZ SEQ Addr=... Value=... 8010 Watchdog event. TS/TZ/Seq as 8000 but no data. 9XXX Series responses ---------------------------------------- 9000 Generic alarm event. Similar to 8000 but more thought is needed and probably really need to identify each error as an independant 9xxx series number to keep it easy. ----- End Command/Response Document --------- ----- Begin XML interface.conf --------- <!--- ***************************************************************** ---> <!--- ---> <!--- $HA/etc/interface.conf - Interface Definitions ---> <!--- ---> <!--- 02Jul00 Written. Jay Hogg ---> <!--- ---> <!--- ---> <!--- ---> <!--- ---> <!--- ***************************************************************** ---> <Interfaces> <!--- **************************************************** ---> <!--- ---> <!--- Device Interfaces with fixed physical interfaces ---> <!--- ---> <!--- **************************************************** ---> <interface id="napco9600" desc="Napco P9600 Security Panel" device="//1/dev/cti1" mastercode="123456" address="localhost:2001" /> <interface id="hvac1" desc="RCS HVAC/Front" device="//1/dev/cti2" address="localhost:2002" /> <interface id="hvac2" desc="RCS HVAC/Rear" device="//1/dev/cti3" address="localhost:2003" /> <interface id="ocelot" desc="Ocelot #1 - Main" device="//1/dev/cti4" address="localhost:2004" /> <interface id="adicon1" desc="ADICON RS485 Network #1 (relays)" device="//1/dev/cti5" address="localhost:2005" /> <interface id="lcd-keypad" desc="LCD+ w/keypad for testing" device="//1/dev/cti8" address="localhost:2008" /> <!--- **************************************************** ---> <!--- ---> <!--- Device Interfaces located on the network ---> <!--- ---> <!--- **************************************************** ---> <interface id="tini1" desc="Dallas Semi TINI #1" address="172.31.1.241:1200" /> <interface id="tini2" desc="Dallas Semi TINI #2" address="172.31.1.242:1200" /> <!--- **************************************************** ---> <!--- ---> <!--- Special Device Interfaces/Gateways ---> <!--- ---> <!--- **************************************************** ---> <interface id="weather" desc="Dallas Semi to UDP Gateway (arne)" address="localhost:2100" sourceaddr="0.0.0.0:8890" /> </Interfaces> ----- End XML interface.conf --------- |