2018-05-19 16:31:55 +01:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
"""
|
2019-10-27 11:04:08 +00:00
|
|
|
decode-status.py - decode status for Tasmota
|
2018-05-19 16:31:55 +01:00
|
|
|
|
2020-01-01 14:13:58 +00:00
|
|
|
Copyright (C) 2020 Theo Arends
|
2018-05-19 16:31:55 +01:00
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
Requirements:
|
|
|
|
- Python
|
2020-07-04 16:39:56 +01:00
|
|
|
- pip json requests
|
2018-05-19 16:31:55 +01:00
|
|
|
|
|
|
|
Instructions:
|
|
|
|
Execute command with option -d to retrieve status report from device or
|
|
|
|
get a copy of the status message with http command http://sonoff/cm?cmnd=status%200
|
|
|
|
and store it in file status.json
|
|
|
|
|
|
|
|
Usage:
|
2018-09-14 15:39:06 +01:00
|
|
|
./decode-status.py -d <hostname or IP address> [-u username] [-p password]
|
2018-05-19 16:31:55 +01:00
|
|
|
or
|
|
|
|
./decode-status.py -f <JSON status information file>
|
|
|
|
|
|
|
|
Example:
|
|
|
|
./decode-status.py -d sonoff1
|
2018-09-14 15:39:06 +01:00
|
|
|
./decode-status.py -d sonoff1 -p 12345678
|
2018-05-19 16:31:55 +01:00
|
|
|
or
|
|
|
|
./decode-status.py -f status.json
|
|
|
|
"""
|
|
|
|
|
|
|
|
import io
|
|
|
|
import os.path
|
|
|
|
import json
|
2020-07-04 16:39:56 +01:00
|
|
|
import requests
|
|
|
|
import urllib
|
2018-05-19 16:31:55 +01:00
|
|
|
from sys import exit
|
|
|
|
from optparse import OptionParser
|
|
|
|
|
|
|
|
a_on_off = ["OFF","ON "]
|
|
|
|
|
2018-07-25 11:42:53 +01:00
|
|
|
a_setoption = [[
|
2018-05-19 16:31:55 +01:00
|
|
|
"Save power state and use after restart",
|
|
|
|
"Restrict button actions to single, double and hold",
|
2019-10-22 17:34:41 +01:00
|
|
|
"(not used) Show value units in JSON messages",
|
2018-07-25 11:42:53 +01:00
|
|
|
"MQTT enabled",
|
2018-05-19 16:31:55 +01:00
|
|
|
"Respond as Command topic instead of RESULT",
|
|
|
|
"MQTT retain on Power",
|
|
|
|
"MQTT retain on Button",
|
|
|
|
"MQTT retain on Switch",
|
|
|
|
"Convert temperature to Fahrenheit",
|
|
|
|
"MQTT retain on Sensor",
|
|
|
|
"MQTT retained LWT to OFFLINE when topic changes",
|
|
|
|
"Swap Single and Double press Button",
|
|
|
|
"Do not use flash page rotate",
|
|
|
|
"Button single press only",
|
|
|
|
"Power interlock mode",
|
|
|
|
"Do not allow PWM control",
|
|
|
|
"Reverse clock",
|
|
|
|
"Allow entry of decimal color values",
|
|
|
|
"CO2 color to light signal",
|
|
|
|
"HASS discovery",
|
|
|
|
"Do not control Power with Dimmer",
|
|
|
|
"Energy monitoring while powered off",
|
|
|
|
"MQTT serial",
|
2018-07-31 10:49:23 +01:00
|
|
|
"MQTT serial binary",
|
2018-11-04 15:55:12 +00:00
|
|
|
"Convert pressure to mmHg",
|
2018-07-25 11:42:53 +01:00
|
|
|
"KNX enabled",
|
2018-05-19 16:31:55 +01:00
|
|
|
"Use Power device index on single relay devices",
|
|
|
|
"KNX enhancement",
|
2018-06-26 10:38:30 +01:00
|
|
|
"RF receive decimal",
|
|
|
|
"IR receive decimal",
|
2018-07-15 16:30:38 +01:00
|
|
|
"Enforce HASS light group",
|
2018-07-25 11:42:53 +01:00
|
|
|
"Do not show Wifi and Mqtt state using Led"
|
|
|
|
],[
|
2019-02-04 00:04:42 +00:00
|
|
|
"Key hold time (ms)",
|
|
|
|
"Sonoff POW Max_Power_Retry",
|
2019-10-31 11:12:48 +00:00
|
|
|
"Backlog delay (ms)",
|
2019-02-04 10:41:51 +00:00
|
|
|
"(not used) mDNS delayed start (Sec)",
|
|
|
|
"Boot loop retry offset (0 = disable)",
|
2019-03-28 10:25:38 +00:00
|
|
|
"RGBWW remap",
|
2019-08-01 14:42:58 +01:00
|
|
|
"IR Unknown threshold",
|
|
|
|
"CSE7766 invalid power margin",
|
|
|
|
"Ignore hold time (s)",
|
2020-04-10 15:05:43 +01:00
|
|
|
"Gratuitous ARP repeat time",
|
2019-08-01 14:42:58 +01:00
|
|
|
"Over temperature threshold (celsius)",
|
2019-10-18 14:18:39 +01:00
|
|
|
"(not used) Tuya MCU max dimmer value",
|
2019-09-08 10:26:54 +01:00
|
|
|
"(not used) Tuya MCU voltage Id",
|
|
|
|
"(not used) Tuya MCU current Id",
|
|
|
|
"(not used) Tuya MCU power Id",
|
2019-10-31 11:12:48 +00:00
|
|
|
"(not used) Energy Tariff1 start hour",
|
|
|
|
"(not used) Energy Tariff2 start hour",
|
2019-08-01 14:42:58 +01:00
|
|
|
"",
|
2019-02-04 00:04:42 +00:00
|
|
|
],[
|
2018-07-25 11:42:53 +01:00
|
|
|
"Timers enabled",
|
2018-09-06 17:08:10 +01:00
|
|
|
"Generic ESP8285 GPIO enabled",
|
|
|
|
"Add UTC time offset to JSON message",
|
2018-11-04 15:55:12 +00:00
|
|
|
"Show hostname and IP address in GUI",
|
2018-11-20 14:00:24 +00:00
|
|
|
"Apply SetOption20 to Tuya",
|
2019-01-03 17:07:03 +00:00
|
|
|
"mDNS enabled",
|
2018-11-20 14:00:24 +00:00
|
|
|
"Use wifi network scan at restart",
|
|
|
|
"Use wifi network rescan regularly",
|
2018-11-21 15:36:10 +00:00
|
|
|
"Add IR raw data to JSON message",
|
2018-11-27 10:04:45 +00:00
|
|
|
"Change state topic from tele/STATE to stat/RESULT",
|
2018-12-01 17:58:30 +00:00
|
|
|
"Enable normal sleep instead of dynamic sleep",
|
2019-01-03 17:07:03 +00:00
|
|
|
"Force local operation when button/switch topic is set",
|
2019-03-28 10:25:38 +00:00
|
|
|
"Do not use retain flag on HOLD messages",
|
2019-05-20 14:09:42 +01:00
|
|
|
"Do not scan relay power state at restart",
|
|
|
|
"Use _ instead of - as sensor index separator",
|
2019-10-18 14:18:39 +01:00
|
|
|
"Disable fast power cycle detection for device reset",
|
2019-10-28 12:36:04 +00:00
|
|
|
"Enable TuyaMcuReceived messages over Mqtt",
|
2019-08-01 14:42:58 +01:00
|
|
|
"Enable buzzer when available",
|
2019-08-07 11:08:13 +01:00
|
|
|
"Enable multi-channels PWM instead of Color PWM",
|
2019-10-18 14:18:39 +01:00
|
|
|
"(not used) Limits Tuya MCU dimmers to minimum of 10% (25) when enabled",
|
2019-09-08 10:26:54 +01:00
|
|
|
"Enable Weekend Energy Tariff",
|
2019-10-02 10:24:51 +01:00
|
|
|
"Select different Modbus registers for Active Energy",
|
2019-10-31 16:41:54 +00:00
|
|
|
"Enable hardware energy total counter as reference",
|
2020-04-28 10:09:56 +01:00
|
|
|
"Detach buttons from relays and enable MQTT action state for multipress",
|
2019-10-30 21:22:18 +00:00
|
|
|
"Enable internal pullup for single DS18x20 sensor",
|
2019-10-31 16:41:54 +00:00
|
|
|
"GroupTopic replaces %topic% (0) or fixed topic cmnd/grouptopic (1)",
|
2019-11-29 12:11:35 +00:00
|
|
|
"Enable incrementing bootcount when deepsleep is enabled",
|
|
|
|
"Do not power off if slider moved to far left",
|
2019-12-23 14:39:07 +00:00
|
|
|
"Bypass Compatibility check",
|
2019-12-30 13:24:00 +00:00
|
|
|
"Enable resetting of counters after telemetry was sent",
|
2019-10-01 15:45:53 +01:00
|
|
|
"Enable shutter support",
|
|
|
|
"Invert PCF8574 ports"
|
2019-10-31 11:12:48 +00:00
|
|
|
],[
|
2020-02-07 09:50:06 +00:00
|
|
|
"Reduced CT range for Alexa",
|
|
|
|
"Use FriendlyNames instead of ShortAddresses when possible",
|
|
|
|
"(AWS IoT) publish MQTT state to a device shadow",
|
2020-02-27 14:10:42 +00:00
|
|
|
"Enable Device Groups",
|
|
|
|
"PWM Dimmer Turn brightness LED's off 5 seconds after last change",
|
|
|
|
"PWM Dimmer Turn red LED on when powered off",
|
|
|
|
"PWM Dimmer Buttons control remote devices",
|
2020-03-05 13:00:47 +00:00
|
|
|
"Distinct MQTT topics per device for Zigbee",
|
2020-04-10 15:05:43 +01:00
|
|
|
"Disable non-json MQTT response",
|
|
|
|
"Enable light fading at start/power on",
|
2020-07-04 16:39:56 +01:00
|
|
|
"Set PWM Mode from regular PWM to ColorTemp control",
|
2020-05-22 14:16:01 +01:00
|
|
|
"Keep uncompressed rules in memory to avoid CPU load of uncompressing at each tick",
|
2020-06-07 16:21:29 +01:00
|
|
|
"Implement simpler MAX6675 protocol instead of MAX31855",
|
2020-07-04 16:39:56 +01:00
|
|
|
"Enable Wifi",
|
|
|
|
"Enable Ethernet (ESP32)",
|
|
|
|
"Set Baud rate for TuyaMCU serial communication (0 = 9600 or 1 = 115200)",
|
|
|
|
"Rotary encoder uses rules instead of light control",
|
2020-07-21 11:17:29 +01:00
|
|
|
"Enable zerocross dimmer on PWM DIMMER",
|
|
|
|
"Remove ZbReceived form JSON message",
|
|
|
|
"Add the source endpoint as suffix to attributes",
|
2019-10-31 11:12:48 +00:00
|
|
|
"","","","",
|
|
|
|
"","","","",
|
|
|
|
"","","",""
|
2018-07-25 11:42:53 +01:00
|
|
|
]]
|
2018-05-19 16:31:55 +01:00
|
|
|
|
|
|
|
a_features = [[
|
2019-08-01 14:42:58 +01:00
|
|
|
"USE_ENERGY_MARGIN_DETECTION","USE_LIGHT","USE_I2C","USE_SPI",
|
2018-05-19 16:31:55 +01:00
|
|
|
"USE_DISCOVERY","USE_ARDUINO_OTA","USE_MQTT_TLS","USE_WEBSERVER",
|
2019-05-20 14:09:42 +01:00
|
|
|
"WEBSERVER_ADVERTISE","USE_EMULATION_HUE","MQTT_PUBSUBCLIENT","MQTT_TASMOTAMQTT",
|
2018-05-19 16:31:55 +01:00
|
|
|
"MQTT_ESPMQTTARDUINO","MQTT_HOST_DISCOVERY","USE_ARILUX_RF","USE_WS2812",
|
|
|
|
"USE_WS2812_DMA","USE_IR_REMOTE","USE_IR_HVAC","USE_IR_RECEIVE",
|
|
|
|
"USE_DOMOTICZ","USE_DISPLAY","USE_HOME_ASSISTANT","USE_SERIAL_BRIDGE",
|
|
|
|
"USE_TIMERS","USE_SUNRISE","USE_TIMERS_WEB","USE_RULES",
|
2019-08-01 14:42:58 +01:00
|
|
|
"USE_KNX","USE_WPS","USE_SMARTCONFIG","USE_ENERGY_POWER_LIMIT"
|
2018-06-26 10:38:30 +01:00
|
|
|
],[
|
2019-02-08 13:55:45 +00:00
|
|
|
"USE_CONFIG_OVERRIDE","FIRMWARE_MINIMAL","FIRMWARE_SENSORS","FIRMWARE_CLASSIC",
|
|
|
|
"FIRMWARE_KNX_NO_EMULATION","USE_DISPLAY_MODES1TO5","USE_DISPLAY_GRAPH","USE_DISPLAY_LCD",
|
2018-08-25 11:26:36 +01:00
|
|
|
"USE_DISPLAY_SSD1306","USE_DISPLAY_MATRIX","USE_DISPLAY_ILI9341","USE_DISPLAY_EPAPER",
|
2018-10-21 11:44:45 +01:00
|
|
|
"USE_DISPLAY_SH1106","USE_MP3_PLAYER","USE_PCA9685","USE_TUYA_DIMMER",
|
2019-05-20 14:09:42 +01:00
|
|
|
"USE_RC_SWITCH","USE_ARMTRONIX_DIMMERS","USE_SM16716","USE_SCRIPT",
|
2019-08-10 16:52:26 +01:00
|
|
|
"USE_EMULATION_WEMO","USE_SONOFF_IFAN","USE_ZIGBEE","NO_EXTRA_4K_HEAP",
|
2018-09-09 13:31:40 +01:00
|
|
|
"VTABLES_IN_IRAM","VTABLES_IN_DRAM","VTABLES_IN_FLASH","PIO_FRAMEWORK_ARDUINO_LWIP_HIGHER_BANDWIDTH",
|
2018-06-26 10:38:30 +01:00
|
|
|
"PIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY","PIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH","DEBUG_THEO","USE_DEBUG_DRIVER"
|
|
|
|
],[
|
2019-08-01 14:42:58 +01:00
|
|
|
"USE_COUNTER","USE_ADC_VCC","USE_ENERGY_SENSOR","USE_PZEM004T",
|
2018-05-19 16:31:55 +01:00
|
|
|
"USE_DS18B20","USE_DS18x20_LEGACY","USE_DS18x20","USE_DHT",
|
|
|
|
"USE_SHT","USE_HTU","USE_BMP","USE_BME680",
|
|
|
|
"USE_BH1750","USE_VEML6070","USE_ADS1115_I2CDEV","USE_ADS1115",
|
|
|
|
"USE_INA219","USE_SHT3X","USE_MHZ19","USE_TSL2561",
|
|
|
|
"USE_SENSEAIR","USE_PMS5003","USE_MGS","USE_NOVA_SDS",
|
|
|
|
"USE_SGP30","USE_SR04","USE_SDM120","USE_SI1145",
|
2018-06-29 10:15:27 +01:00
|
|
|
"USE_SDM630","USE_LM75AD","USE_APDS9960","USE_TM1638"
|
2018-06-26 10:38:30 +01:00
|
|
|
],[
|
2018-07-31 10:49:23 +01:00
|
|
|
"USE_MCP230xx","USE_MPR121","USE_CCS811","USE_MPU6050",
|
2018-09-06 17:08:10 +01:00
|
|
|
"USE_MCP230xx_OUTPUT","USE_MCP230xx_DISPLAYOUTPUT","USE_HLW8012","USE_CSE7766",
|
2018-10-17 11:27:05 +01:00
|
|
|
"USE_MCP39F501","USE_PZEM_AC","USE_DS3231","USE_HX711",
|
2018-12-11 13:24:52 +00:00
|
|
|
"USE_PZEM_DC","USE_TX20_WIND_SENSOR","USE_MGC3130","USE_RF_SENSOR",
|
2019-01-01 12:45:44 +00:00
|
|
|
"USE_THEO_V2","USE_ALECTO_V2","USE_AZ7798","USE_MAX31855",
|
2019-03-28 10:25:38 +00:00
|
|
|
"USE_PN532_I2C","USE_MAX44009","USE_SCD30","USE_HRE",
|
2019-08-01 14:42:58 +01:00
|
|
|
"USE_ADE7953","USE_SPS30","USE_VL53L0X","USE_MLX90614",
|
2019-08-19 10:47:59 +01:00
|
|
|
"USE_MAX31865","USE_CHIRP","USE_SOLAX_X1","USE_PAJ7620"
|
2019-08-10 16:52:26 +01:00
|
|
|
],[
|
2019-09-08 10:26:54 +01:00
|
|
|
"USE_BUZZER","USE_RDM6300","USE_IBEACON","USE_SML_M",
|
2019-10-17 14:28:46 +01:00
|
|
|
"USE_INA226","USE_A4988_STEPPER","USE_DDS2382","USE_SM2135",
|
2019-10-14 16:01:24 +01:00
|
|
|
"USE_SHUTTER","USE_PCF8574","USE_DDSU666","USE_DEEPSLEEP",
|
2019-10-18 16:29:19 +01:00
|
|
|
"USE_SONOFF_SC","USE_SONOFF_RF","USE_SONOFF_L1","USE_EXS_DIMMER",
|
2020-05-22 14:16:01 +01:00
|
|
|
"USE_TASMOTA_SLAVE","USE_HIH6","USE_HPMA","USE_TSL2591",
|
2019-12-30 13:24:00 +00:00
|
|
|
"USE_DHT12","USE_DS1624","USE_GPS","USE_HOTPLUG",
|
2020-02-10 14:18:11 +00:00
|
|
|
"USE_NRF24","USE_MIBLE","USE_HM10","USE_LE01MR",
|
2020-02-27 14:10:42 +00:00
|
|
|
"USE_AHT1x","USE_WEMOS_MOTOR_V1","USE_DEVICE_GROUPS","USE_PWM_DIMMER"
|
2020-02-10 14:18:11 +00:00
|
|
|
],[
|
2020-03-14 11:43:02 +00:00
|
|
|
"USE_KEELOQ","USE_HRXL","USE_SONOFF_D1","USE_HDC1080",
|
2020-04-11 13:51:08 +01:00
|
|
|
"USE_IAQ","USE_DISPLAY_SEVENSEG","USE_AS3935","USE_PING",
|
2020-05-22 14:16:01 +01:00
|
|
|
"USE_WINDMETER","USE_OPENTHERM","USE_THERMOSTAT","USE_VEML6075",
|
2020-06-11 16:30:33 +01:00
|
|
|
"USE_VEML7700","USE_MCP9808","USE_BL0940","USE_TELEGRAM",
|
2020-06-17 16:22:41 +01:00
|
|
|
"USE_HP303B","USE_TCP_BRIDGE","USE_TELEINFO","USE_LMT01",
|
2020-07-14 16:37:14 +01:00
|
|
|
"USE_PROMETHEUS","USE_IEM3000","","",
|
2020-02-10 14:18:11 +00:00
|
|
|
"","","","",
|
2020-06-15 17:27:04 +01:00
|
|
|
"","","USE_ETHERNET","USE_WEBCAM"
|
2019-08-10 16:52:26 +01:00
|
|
|
]]
|
2018-05-19 16:31:55 +01:00
|
|
|
|
|
|
|
usage = "usage: decode-status {-d | -f} arg"
|
|
|
|
parser = OptionParser(usage)
|
|
|
|
parser.add_option("-d", "--dev", action="store", type="string",
|
|
|
|
dest="device", help="device to retrieve status from")
|
2018-09-14 15:39:06 +01:00
|
|
|
parser.add_option("-u", "--username", action="store", type="string",
|
|
|
|
dest="username", help="username for login", default="admin")
|
|
|
|
parser.add_option("-p", "--password", action="store", type="string",
|
|
|
|
dest="password", help="password for login", default=None)
|
2018-05-19 16:31:55 +01:00
|
|
|
parser.add_option("-f", "--file", metavar="FILE",
|
|
|
|
dest="jsonfile", default="status.json", help="status json file (default: status.json)")
|
|
|
|
(options, args) = parser.parse_args()
|
|
|
|
|
|
|
|
if (options.device):
|
2018-09-14 15:39:06 +01:00
|
|
|
loginstr = ""
|
|
|
|
if options.password is not None:
|
2020-07-04 16:39:56 +01:00
|
|
|
loginstr = "user={}&password={}&".format(urllib.parse.quote(options.username), urllib.parse.quote(options.password))
|
2018-09-14 15:39:06 +01:00
|
|
|
url = str("http://{}/cm?{}cmnd=status%200".format(options.device, loginstr))
|
2020-07-04 16:39:56 +01:00
|
|
|
res = requests.get(url)
|
|
|
|
obj = json.loads(res.content)
|
2018-05-19 16:31:55 +01:00
|
|
|
else:
|
|
|
|
jsonfile = options.jsonfile
|
2019-02-04 10:41:51 +00:00
|
|
|
with open(jsonfile, "r") as fp:
|
2019-02-04 00:04:42 +00:00
|
|
|
obj = json.load(fp)
|
2018-05-19 16:31:55 +01:00
|
|
|
|
|
|
|
def StartDecode():
|
2020-07-21 11:17:29 +01:00
|
|
|
print ("\n*** decode-status.py v20200721 by Theo Arends and Jacek Ziolkowski ***")
|
2018-07-25 11:42:53 +01:00
|
|
|
|
2018-05-19 16:31:55 +01:00
|
|
|
# print("Decoding\n{}".format(obj))
|
|
|
|
|
2019-02-04 00:04:42 +00:00
|
|
|
if "StatusSNS" in obj:
|
|
|
|
if "Time" in obj["StatusSNS"]:
|
2018-07-17 15:07:03 +01:00
|
|
|
time = str(" from status report taken at {}".format(obj["StatusSNS"]["Time"]))
|
|
|
|
|
2019-02-04 00:04:42 +00:00
|
|
|
if "Status" in obj:
|
|
|
|
if "FriendlyName" in obj["Status"]:
|
2018-07-25 11:42:53 +01:00
|
|
|
print("Decoding information for device {}{}".format(obj["Status"]["FriendlyName"][0], time))
|
2018-07-17 15:07:03 +01:00
|
|
|
|
2019-02-04 00:04:42 +00:00
|
|
|
if "StatusLOG" in obj:
|
|
|
|
if "SetOption" in obj["StatusLOG"]:
|
2018-07-17 15:07:03 +01:00
|
|
|
options = []
|
2019-02-04 10:41:51 +00:00
|
|
|
|
2019-02-04 00:04:42 +00:00
|
|
|
i = 0
|
2019-02-04 10:41:51 +00:00
|
|
|
for r,opt_group in enumerate(a_setoption):
|
2019-02-04 00:04:42 +00:00
|
|
|
register = obj["StatusLOG"]["SetOption"][r]
|
2019-02-04 10:41:51 +00:00
|
|
|
|
2019-02-04 00:04:42 +00:00
|
|
|
if r > 0 and len(obj["StatusLOG"]["SetOption"]) == 2: # old firmware: array consisted only of SetOptions 0..31 and resolution
|
2019-02-04 10:41:51 +00:00
|
|
|
break
|
|
|
|
|
2019-02-04 00:04:42 +00:00
|
|
|
if r == 1:
|
|
|
|
if len(register) == 8: # pre 6.1.1.14: array consisted of SetOptions 0..31, resolution, and SetOptions 50..81
|
|
|
|
i += 18 # adjust option index and skip 2nd register
|
|
|
|
continue
|
2019-02-04 10:41:51 +00:00
|
|
|
|
|
|
|
elif len(register) == 36: # 6.1.1.14: array consists of SetOptions 0..31, SetOptions 32..49, and SetOptions 50..81
|
2019-02-04 00:04:42 +00:00
|
|
|
split_register = [int(register[opt*2:opt*2+2],16) for opt in range(18)] # split register into 18 values
|
2019-02-04 10:41:51 +00:00
|
|
|
|
2019-02-04 00:04:42 +00:00
|
|
|
for opt_idx, option in enumerate(opt_group):
|
2019-02-04 10:41:51 +00:00
|
|
|
options.append(str("{0:2d} ({1:3d}) {2}".format(i, split_register[opt_idx], option)))
|
2019-02-04 00:04:42 +00:00
|
|
|
i += 1
|
2019-02-04 10:41:51 +00:00
|
|
|
|
2019-10-31 11:12:48 +00:00
|
|
|
if r in (0, 2, 3): #registers 1 and 3 hold binary values
|
2019-02-04 00:04:42 +00:00
|
|
|
for opt_idx, option in enumerate(opt_group):
|
|
|
|
i_register = int(register,16)
|
|
|
|
state = (i_register >> opt_idx) & 1
|
2019-02-04 10:41:51 +00:00
|
|
|
options.append(str("{0:2d} ({1}) {2}".format(i, a_on_off[state], option)))
|
2019-02-04 00:04:42 +00:00
|
|
|
i += 1
|
2019-02-04 10:41:51 +00:00
|
|
|
|
2018-07-17 15:07:03 +01:00
|
|
|
print("\nOptions")
|
2019-02-04 00:04:42 +00:00
|
|
|
for o in options:
|
|
|
|
print(" {}".format(o))
|
2018-07-17 15:07:03 +01:00
|
|
|
|
2019-02-04 00:04:42 +00:00
|
|
|
if "StatusMEM" in obj:
|
|
|
|
if "Features" in obj["StatusMEM"]:
|
2018-07-17 15:07:03 +01:00
|
|
|
features = []
|
2019-08-10 16:52:26 +01:00
|
|
|
for f in range(6):
|
2018-07-17 15:07:03 +01:00
|
|
|
feature = obj["StatusMEM"]["Features"][f]
|
|
|
|
i_feature = int(feature,16)
|
2019-02-04 00:04:42 +00:00
|
|
|
if f == 0:
|
2018-07-17 15:07:03 +01:00
|
|
|
features.append(str("Language LCID = {}".format(i_feature & 0xFFFF)))
|
|
|
|
else:
|
|
|
|
for i in range(len(a_features[f -1])):
|
2019-02-04 00:04:42 +00:00
|
|
|
if (i_feature >> i) & 1:
|
2018-07-17 15:07:03 +01:00
|
|
|
features.append(a_features[f -1][i])
|
|
|
|
|
|
|
|
features.sort()
|
|
|
|
print("\nFeatures")
|
2019-02-04 00:04:42 +00:00
|
|
|
for f in features:
|
|
|
|
print(" {}".format(f))
|
2018-05-19 16:31:55 +01:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
try:
|
|
|
|
StartDecode()
|
|
|
|
except Exception as e:
|
2018-09-14 15:39:06 +01:00
|
|
|
print("E: {}".format(e))
|