def PGMFlags(count, start_index_from=1): return DictArray( count, start_index_from, Bitwise( Struct( "_index" / Computed(this._index + start_index_from), "fire_2_wires" / Default(Flag, False), "normally_closed" / Default(Flag, False), "_unknown1" / BitsInteger(1), "disabled" / ExprSymmetricAdapter( Default(Flag, False), lambda obj, ctx: not obj ), # False when a relay is assigned "_unknown2" / BitsInteger(2), "timer_active" / Default(Flag, False), # when timer is active "on" / Default(Flag, False), # when is activated "time_left" / Bytewise(ByteSwapped(Default(Int24ub, 0))), # byte in seconds ), ), )
Struct( "po" / BitStruct( "command" / Const(0x5, Nibble), "block" / Default(Nibble, 0), ), "packet_length" / PacketLength(Int8ub), "control" / BitStruct("ram_access" / Default(Flag, False), "alarm_reporting_pending" / Default(Flag, False), "Winload_connected" / Default(Flag, False), "NeWare_connected" / Default(Flag, False), "_not_used" / Default(BitsInteger(2), 0), "eeprom_address_bits" / Default(BitsInteger(2), 0)), "bus_address" / Default(Int8ub, 0x00), # 00 - Panel, 01-FF - Modules "address" / ExprSymmetricAdapter(Int16ub, obj_ & 0xffff), "length" / Int8ub))), "checksum" / PacketChecksum(Bytes(1))) ReadEEPROMResponse = Struct( "fields" / RawCopy( Struct( "po" / BitStruct( "command" / Const(0x5, Nibble), "status" / Struct("reserved" / Flag, "alarm_reporting_pending" / Flag, "Winload_connected" / Flag, "NeWare_connected" / Flag)), "packet_length" / PacketLength(Int8ub), "control" / BitStruct( "ram_access" / Flag, # RAM = 0 or EEPROM = 1 "_not_used" / Padding(5), "eeprom_address_bits" /
"po" / BitStruct( "command" / Const(0x5, Nibble), "block" / Default(Nibble, 0), ), "packet_length" / PacketLength(Int8ub), "control" / BitStruct( "ram_access" / Default(Flag, False), "alarm_reporting_pending" / Default(Flag, False), "Winload_connected" / Default(Flag, False), "NeWare_connected" / Default(Flag, False), "_not_used" / Default(BitsInteger(2), 0), "_eeprom_address_bits" / Default(BitsInteger(2), 0), ), "bus_address" / Default(Int8ub, 0x00), # 00 - Panel, 01-FF - Modules "address" / ExprSymmetricAdapter(Int16ub, obj_ & 0xFFFF), "length" / Int8ub, ) ) ), "checksum" / PacketChecksum(Bytes(1)), ) ReadEEPROMResponse = Struct( "fields" / RawCopy( EvoEEPROMAddressAdapter( Struct( "po" / BitStruct( "command" / Const(0x5, Nibble),
"base_address" / PVoid, "size" / Int32ul, "path" / StringIndex, "version" / StringIndex, "company" / StringIndex, "description" / StringIndex, "timestamp" / Int32ul, "reserved2" / Int64ul * "!!Unknown field!!", "reserved3" / Int64ul * "!!Unknown field!!", "unknown_time" / Filetime * "!!Unknown field!!", ) ModuleStruct = ExprSymmetricAdapter( RawModuleStruct, lambda obj, ctx: Module(base_address=obj.base_address, size=obj.size, path=obj.path, version=obj.version, company=obj.company, description=obj.company, timestamp=obj.timestamp)) RawProcessStruct = """ Struct that describes a process. """ * Struct( "is_64bit" / Computed(lambda ctx: ctx._.is_64bit), # keep this in order to use PVoid "strings_table" / Computed(lambda ctx: ctx._.strings_table ), # keep the reference to the strings table "process_index" / Int32ul, "process_id" / Int32ul, "parent_process_id" / Int32ul, "reserved1" / Int32ul * "!!Unknown field!!",