HCS-II Firmware Operand ByteCodes
Last Updated 6/15/00
Current to Firmware version 4.01
Green indicates proposed bytecodes for the Statlink in v4.1.  The Flexible command section may be moved from 0xA0 to 0xC0 to give the fixed commands some breathing room.  We currently have 5 fixed action bytecodes left.
The list below outlines the bytecodes used to control the HCS-II system board.  Any compiler written for the HCS-II must use these bytecodes in the order and length specificed.  This document may not be 100% complete and will be updated as I dive further into how the compiler and XPRESS work.  If you have suggestions or updates/corrections, send them to me at baptiste@cc-concepts.com
XPRESS Programs are made up of a variety of command types.  The main types are Condition Checks (IF/THEN) and actions which are the commands executed after a THEN or ELSE.  There are three types of actions outlined below
Command
Type
Bytecode
X-10 Commands < 0x80
Fixed Action >= 0x80
< 0xA0
Flexible Action >= 0xA0
< 0xAC
Byte Code XPRESS Routine Associated
XPRESS
Command
Behavior
Program Markers
These codes outline the structure of the XPRESS Bytecodes
0x0f0 ifa IF Always
0x0f1 ifn IF
0x0f2 elseop ELSE (If present - goes before 0xFE END)
0x0fc stopm End of Math Equation (to right of action assignment)
0x0fd stop End of IF Condition Evaluation
0x0fe last End of actions in THEN/ELSE
0x0ef endcont End of Continuous Section
Start of Sequential Section
0x0ee endpgm End of Program
0x0ff endtbl End of Events Offset Table
N/A domath Evaluate math expression in an assignment statement
Evaluation Parameters in IF conditions
An IF THEN statement in XPRESS is translated into a number of bytecodes.  These bytecodes represent things like math operators, comparison operands, system values (ie ADCs, time, etc), parentheses, etc.
AN IF starts with 0xF1 with eval bytecodes in between, ending with 0xFD and 3 0x00s. The then starts after that with action bytecodes and ends with 0xFE.  If an else is encountered, a 0xF2 is inserted with the ELSE action codes BEFORE the 0xFE.  AN IF offset table is compiled to point to each IF statement's actions.
0x30 var
0x31 adc
0x32 tmr
0x33 irc
0x34 c8
0x35 c16
0x36 tru
0x37 fls
0x38 rnd
0x39 month
0x3A day
0x3B year
0x3C week
0x3D hour
0x3E min
0x3F sec
0x40 getdig
0x41 getnum
0x42 rings
0x43 dtone
0x44 cprog
0x45 cidnew
0x46 cidmon
0x47 cidday
0x48 cidhour
0x49 cidmin
0x4A cidarea
0x4B cidexch
0x4C cidnum
0x4D logsize
0x4E netbyte
0x4F acp
0x50 acf
0x51 freq
0x52 total
0x53 getkey
0x54 getknum
0x55   HVACSetPoint(xx) Current Thermostat Set Point
0x56   HVACFan(xx) Current Fan Switch Mode
0x57   HVACMode(xx) Current Thermostat Mode
0x58   HVACStatus(xx) Current HVAC Operating Status
0x59   HVACTemp(xx) Current Thermostat Temp Reading
Generic Math and Logic Operators
0x00 noop Evaluate single operand for True/False
0x01 eq Check if Operand 1 = Operand 2
0x02 ne Check if Operand 1 != Operand 2
0x03 gt Check if Operand 1 > Operand 2
0x04 lt Check if Operand 1 < Operand 2
0x05 ge Check if Operand 1 >= Operand 2
0x06 le Check if Operand 1 <= Operand 2
0x70 oparen Open Paren
0x71 cparen Close Paren
0x72 andf AND Operator
0x73 orf OR Operator
0x74 notf NOT Operator
0x75 addf ADD Operator
0x76 subf Subtract Operator
0x77 mulf Multiply Operator
0x78 divf Divide Operator
Action Command Bytecodes
These are bytecodes included in THEN and ELSE sections of an XPRESS program
X-10 Commands
0x00 - 0x7F
1st Bytecode is the Housecode in ASCII ('A' to 'P' which is 0x41 - 0x50)
2nd Bytecode is the Module Number in hex (1 - 16 which is 0x01 - 0x10)
3rd Bytecode is the Function
0x01 All OFF
0x02 All ON
0x03 On
0x04 Off
0x05 Dim
0x06 Bright
0x83 ONA
4th Bytecode is the Repeat Count for Dim & Bright.  No range checking means you can send 0-255 (0x00 to 0xFF)
FIXED ACTIONS
0x80 - 0x9E
These routines are fixed in nature.  A constant value or resource is assigned.  No math equation can be to the right of the =
0x80 incvar Inc(variable_id) Increment a variable
0x81 decvar Dec(variable_id) Decrement a variable
0x82 onout Output(output_num)= Turn a local output on
0x83 offout Turn a local output off
0x84 ontmr Timer(timer_id) Reset and activate a timer
0x85 offtmr Turn a timer off
0x86 onnetb NetBit(netbit_id)= Turn on a network output
0x87 offnetb Turn off a network output
0x88 lcdmsg LCD(net_addr)="" Send a message/string to LCD-Link
0x89 diomsg LPT(net_addr)="" Send a message/string via a DIO-Link like to a printer
0x8A tvmsg TV(net_addr)="" Send a message/string to a TV-Link (NOT a PIC-TV!)
0X8B rstio ResetIO Clear local I/O bits
0X8C clrvar ClearVariables Clear all variables
0X8D clrtmr ClearTimers Clear all timers
0X8E clrlogm ClearLog Clear LOG memory
0X8F wait Wait
0X90 offhk OffHook Take phoneline offhook via HCS-DTMF
0X91 onhk OnHook Put phoneline onhook via HCS-DTMF (hangup)
0X92 dials DialString("") Dial digits in string
0X93 diald DialDigit(variable_id) Dial single digit stored in a variable. Variable must be between 0-15 correspondign to a given digit
0X94 dialn DialNumber(variable_id) Dial 1-4 digits based on variable value of 0-9999
0X95 say Say="" Send string to Voice board
0X96 sayw SayW="" Send string to Voice board and wait for board to finish speaking string.
0X97 conmsg Console="" Send message to HOST console
0X98 setinit ModemInit="" Store new init string for modem
0X99 netmsg Network="" Send raw network message with checksum
0X9A clrtot ClearTotal(aman_addr) Clear totalizer on an AMAN-Link network module
0x9B hvacled HVACLed(stat,led_number)=ON/OFF Turn a Statnet LED on or Off
0x9C hvacfan HVACFan(stat)=AUTO/ON Set the fan mode of a thermostat to AUTO (0) or ON (1)
0x9D hvacnet HVACNet = "" Send RAW string to HVAC network
0x9E hvacmode HVACMode(stat)= Set the mode of a thermostat to OFF, Heat, Cooling, or Auto (0-3)
FLEXIBLE ACTIONS
0xA0 - 0xAC
These actions are commands which take a byte value and assign them to a given resource.  They can have math equations to the right, unlike fixed commands
0xA0 setvr Variable= Set a variable to a given value
0xA1 setdaco Set DAC Output on AMAN-Link
0xA2 setref Set PL-Link refresh level
0xA3 setmcir Send IR code via MCIR-Link
0xA4 logdat Store Log Value to Log memory
0xA5 rcrings Set number of rings before answering modem
0xA6 cidenb Turn CID feature On/Off
0xA7 setnetb Set NetByte on DIO-Link
0xA8 pwmtot Set PWM Total Period on AMAN-Link
0xA9 pwmhi Set PWM Hi Period on AMAN-Link
0xAA bitdir Set I/O bit direction on AMAN-Link
0xAB keypto Set keypad timeout value on AMAN-Link
0xAC hvacssp HVACSetPoint(stat) = byte Set the setpoint of the specified thermostat to a given value