objutils package#
Subpackages#
- objutils.elf package
- Subpackages
- Submodules
- objutils.elf.attributes module
- objutils.elf.defs module
AVRMachineTypeAVRMachineType.E_AVR_MACH_AVR1AVRMachineType.E_AVR_MACH_AVR2AVRMachineType.E_AVR_MACH_AVR25AVRMachineType.E_AVR_MACH_AVR3AVRMachineType.E_AVR_MACH_AVR31AVRMachineType.E_AVR_MACH_AVR35AVRMachineType.E_AVR_MACH_AVR4AVRMachineType.E_AVR_MACH_AVR5AVRMachineType.E_AVR_MACH_AVR51AVRMachineType.E_AVR_MACH_AVR6AVRMachineType.E_AVR_MACH_AVRTINYAVRMachineType.E_AVR_MACH_XMEGA1AVRMachineType.E_AVR_MACH_XMEGA2AVRMachineType.E_AVR_MACH_XMEGA3AVRMachineType.E_AVR_MACH_XMEGA4AVRMachineType.E_AVR_MACH_XMEGA5AVRMachineType.E_AVR_MACH_XMEGA6AVRMachineType.E_AVR_MACH_XMEGA7
ArmMachineDataAvrMachineDataELFAbiTypeELFAbiType.ELFOSABI_AIXELFAbiType.ELFOSABI_ARMELFAbiType.ELFOSABI_AROSELFAbiType.ELFOSABI_C6000_ELFABIELFAbiType.ELFOSABI_C6000_LINUXELFAbiType.ELFOSABI_FENIXOSELFAbiType.ELFOSABI_FREEBSDELFAbiType.ELFOSABI_GNUELFAbiType.ELFOSABI_HPUXELFAbiType.ELFOSABI_IRIXELFAbiType.ELFOSABI_LINUXELFAbiType.ELFOSABI_MODESTOELFAbiType.ELFOSABI_NETBSDELFAbiType.ELFOSABI_NONEELFAbiType.ELFOSABI_NSKELFAbiType.ELFOSABI_OPENBSDELFAbiType.ELFOSABI_OPENVMSELFAbiType.ELFOSABI_SOLARISELFAbiType.ELFOSABI_STANDALONEELFAbiType.ELFOSABI_TRU64
ELFClassELFDataEncodingELFMachineTypeELFMachineType.EM_386ELFMachineType.EM_68HC05ELFMachineType.EM_68HC08ELFMachineType.EM_68HC11ELFMachineType.EM_68HC12ELFMachineType.EM_68HC16ELFMachineType.EM_68KELFMachineType.EM_860ELFMachineType.EM_88KELFMachineType.EM_960ELFMachineType.EM_AARCH64ELFMachineType.EM_ADAPTEVA_EPIPHANYELFMachineType.EM_ALPHAELFMachineType.EM_ALPHA_NO_ABIELFMachineType.EM_ALTERA_NIOS2ELFMachineType.EM_ARCELFMachineType.EM_ARCAELFMachineType.EM_ARC_A5ELFMachineType.EM_ARMELFMachineType.EM_AVRELFMachineType.EM_AVR32ELFMachineType.EM_AVR_OLDELFMachineType.EM_BLACKFINELFMachineType.EM_C166ELFMachineType.EM_CEELFMachineType.EM_COLDFIREELFMachineType.EM_COOLRISC_C816ELFMachineType.EM_CRELFMachineType.EM_CR16ELFMachineType.EM_CRAYNV2ELFMachineType.EM_CRISELFMachineType.EM_CRXELFMachineType.EM_CUDAELFMachineType.EM_CYGNUS_D10VELFMachineType.EM_CYGNUS_D30VELFMachineType.EM_CYGNUS_FR30ELFMachineType.EM_CYGNUS_FRVELFMachineType.EM_CYGNUS_M32RELFMachineType.EM_CYGNUS_MEPELFMachineType.EM_CYGNUS_MN10200ELFMachineType.EM_CYGNUS_MN10300ELFMachineType.EM_CYGNUS_POWERPCELFMachineType.EM_CYGNUS_V850ELFMachineType.EM_CYPRESS_M8CELFMachineType.EM_D10VELFMachineType.EM_D30VELFMachineType.EM_DLXELFMachineType.EM_DSP24ELFMachineType.EM_DSPIC30FELFMachineType.EM_DXPELFMachineType.EM_ECOG1ELFMachineType.EM_ECOG16ELFMachineType.EM_ECOG1XELFMachineType.EM_ECOG2ELFMachineType.EM_ETPUELFMachineType.EM_EXCESSELFMachineType.EM_F2MC16ELFMachineType.EM_FIREPATHELFMachineType.EM_FR20ELFMachineType.EM_FR30ELFMachineType.EM_FX66ELFMachineType.EM_H8SELFMachineType.EM_H8_300ELFMachineType.EM_H8_300HELFMachineType.EM_H8_500ELFMachineType.EM_HUANYELFMachineType.EM_I8051ELFMachineType.EM_IA_64ELFMachineType.EM_IP2KELFMachineType.EM_IP2K_OLDELFMachineType.EM_IQ2000ELFMachineType.EM_JAVELINELFMachineType.EM_L1OMELFMachineType.EM_LATTICEMICO32ELFMachineType.EM_M16CELFMachineType.EM_M32ELFMachineType.EM_M32CELFMachineType.EM_M32C_OLDELFMachineType.EM_M32RELFMachineType.EM_MANIKELFMachineType.EM_MAXELFMachineType.EM_MAXQ30ELFMachineType.EM_MCST_ELBRUSELFMachineType.EM_ME16ELFMachineType.EM_METAGELFMachineType.EM_MICROBLAZEELFMachineType.EM_MICROBLAZE_OLDELFMachineType.EM_MIPSELFMachineType.EM_MIPS_RS3_LEELFMachineType.EM_MIPS_XELFMachineType.EM_MMAELFMachineType.EM_MMDSP_PLUSELFMachineType.EM_MMIXELFMachineType.EM_MN10200ELFMachineType.EM_MN10300ELFMachineType.EM_MOXIEELFMachineType.EM_MSP430ELFMachineType.EM_MSP430_OLDELFMachineType.EM_MTELFMachineType.EM_NCPUELFMachineType.EM_NDR1ELFMachineType.EM_NDS32ELFMachineType.EM_NEC_V850ELFMachineType.EM_NIOS32ELFMachineType.EM_NONEELFMachineType.EM_NS32KELFMachineType.EM_OPENRISCELFMachineType.EM_OPENRISC_OLDELFMachineType.EM_OR32ELFMachineType.EM_PARISCELFMachineType.EM_PCPELFMachineType.EM_PDP10ELFMachineType.EM_PDP11ELFMachineType.EM_PDSPELFMachineType.EM_PJELFMachineType.EM_PPCELFMachineType.EM_PPC64ELFMachineType.EM_PRISMELFMachineType.EM_QDSP6ELFMachineType.EM_R32CELFMachineType.EM_RCEELFMachineType.EM_RH32ELFMachineType.EM_RS08ELFMachineType.EM_RXELFMachineType.EM_S370ELFMachineType.EM_S390ELFMachineType.EM_S390_OLDELFMachineType.EM_SCOREELFMachineType.EM_SCORE7ELFMachineType.EM_SEPELFMachineType.EM_SE_C17ELFMachineType.EM_SE_C33ELFMachineType.EM_SHELFMachineType.EM_SLE9XELFMachineType.EM_SNP1KELFMachineType.EM_SPARCELFMachineType.EM_SPARC32PLUSELFMachineType.EM_SPARCV9ELFMachineType.EM_SPUELFMachineType.EM_ST100ELFMachineType.EM_ST19ELFMachineType.EM_ST200ELFMachineType.EM_ST7ELFMachineType.EM_ST9PLUSELFMachineType.EM_STARCOREELFMachineType.EM_STM8ELFMachineType.EM_STXP7XELFMachineType.EM_SVXELFMachineType.EM_TILE64ELFMachineType.EM_TILEGXELFMachineType.EM_TILEPROELFMachineType.EM_TINYJELFMachineType.EM_TI_ARP32ELFMachineType.EM_TI_C2000ELFMachineType.EM_TI_C5500ELFMachineType.EM_TI_C6000ELFMachineType.EM_TI_PRUELFMachineType.EM_TMM_GPPELFMachineType.EM_TPCELFMachineType.EM_TRICOREELFMachineType.EM_TRIMEDIAELFMachineType.EM_TSK3000ELFMachineType.EM_UNICOREELFMachineType.EM_V800ELFMachineType.EM_V850ELFMachineType.EM_VAXELFMachineType.EM_VIDEOCOREELFMachineType.EM_VIDEOCORE3ELFMachineType.EM_VPP500ELFMachineType.EM_X86_64ELFMachineType.EM_XC16XELFMachineType.EM_XGATEELFMachineType.EM_XIMO16ELFMachineType.EM_XSTORMY16ELFMachineType.EM_XTENSAELFMachineType.EM_XTENSA_OLDELFMachineType.EM_ZSPELFMachineType.RESERVED
ELFTypeElf32_EhdrElf32_Ehdr._asdict()Elf32_Ehdr._field_defaultsElf32_Ehdr._fieldsElf32_Ehdr._make()Elf32_Ehdr._replace()Elf32_Ehdr.e_ehsizeElf32_Ehdr.e_entryElf32_Ehdr.e_flagsElf32_Ehdr.e_machineElf32_Ehdr.e_phentsizeElf32_Ehdr.e_phnumElf32_Ehdr.e_phoffElf32_Ehdr.e_shentsizeElf32_Ehdr.e_shnumElf32_Ehdr.e_shoffElf32_Ehdr.e_shstrndxElf32_Ehdr.e_typeElf32_Ehdr.e_version
Elf32_SymElf64_SymElf_ShdrMachineDataNoteSegmentDescriptorCoreNoteSegmentDescriptorCore.NT_386_IOPERMNoteSegmentDescriptorCore.NT_386_TLSNoteSegmentDescriptorCore.NT_ASRSNoteSegmentDescriptorCore.NT_AUXVNoteSegmentDescriptorCore.NT_FPREGSETNoteSegmentDescriptorCore.NT_GWINDOWSNoteSegmentDescriptorCore.NT_LWPSINFONoteSegmentDescriptorCore.NT_LWPSTATUSNoteSegmentDescriptorCore.NT_PLATFORMNoteSegmentDescriptorCore.NT_PPC_SPENoteSegmentDescriptorCore.NT_PPC_VMXNoteSegmentDescriptorCore.NT_PPC_VSXNoteSegmentDescriptorCore.NT_PRCREDNoteSegmentDescriptorCore.NT_PRFPXREGNoteSegmentDescriptorCore.NT_PRPSINFONoteSegmentDescriptorCore.NT_PRSTATUSNoteSegmentDescriptorCore.NT_PRXFPREGNoteSegmentDescriptorCore.NT_PRXREGNoteSegmentDescriptorCore.NT_PSINFONoteSegmentDescriptorCore.NT_PSTATUSNoteSegmentDescriptorCore.NT_TASKSTRUCTNoteSegmentDescriptorCore.NT_UTSNAMENoteSegmentDescriptorCore.NT_X86_XSTATE
NoteSegmentDescriptorObjectProgramHeaderProgramHeader.PT_ARM_EXIDXProgramHeader.PT_DYNAMICProgramHeader.PT_GNU_EH_FRAMEProgramHeader.PT_GNU_PROPERTYProgramHeader.PT_GNU_RELROProgramHeader.PT_GNU_STACKProgramHeader.PT_HIOSProgramHeader.PT_HIPROCProgramHeader.PT_HISUNWProgramHeader.PT_INTERPProgramHeader.PT_LOADProgramHeader.PT_LOOSProgramHeader.PT_LOPROCProgramHeader.PT_LOSUNWProgramHeader.PT_NOTEProgramHeader.PT_NULLProgramHeader.PT_NUMProgramHeader.PT_PHDRProgramHeader.PT_SHLIBProgramHeader.PT_SUNWBSSProgramHeader.PT_SUNWSTACKProgramHeader.PT_TLS
SectionFlagsSectionFlags.SHF_ALLOCSectionFlags.SHF_COMPRESSEDSectionFlags.SHF_EXCLUDESectionFlags.SHF_EXECINSTRSectionFlags.SHF_GROUPSectionFlags.SHF_INFO_LINKSectionFlags.SHF_LINK_ORDERSectionFlags.SHF_MASKOSSectionFlags.SHF_MASKPROCSectionFlags.SHF_MERGESectionFlags.SHF_ORDEREDSectionFlags.SHF_OS_NONCONFORMINGSectionFlags.SHF_STRINGSSectionFlags.SHF_TLSSectionFlags.SHF_WRITE
SectionNameSectionName.SHN_ABSSectionName.SHN_AFTERSectionName.SHN_BEFORESectionName.SHN_COMMONSectionName.SHN_HIOSSectionName.SHN_HIPROCSectionName.SHN_HIRESERVESectionName.SHN_IA_64_ANSI_COMMONSectionName.SHN_LOOSSectionName.SHN_LOPROCSectionName.SHN_LORESERVESectionName.SHN_UNDEFSectionName.SHN_XINDEX
SectionTypeSectionType.SHT_ARM_ATTRIBUTESSectionType.SHT_ARM_DEBUGOVERLAYSectionType.SHT_ARM_EXIDXSectionType.SHT_ARM_OVERLAYSECTIONSectionType.SHT_ARM_PREEMPTMAPSectionType.SHT_CHECKSUMSectionType.SHT_DYNAMICSectionType.SHT_DYNSYMSectionType.SHT_FINI_ARRAYSectionType.SHT_GNU_ATTRIBUTESSectionType.SHT_GNU_HASHSectionType.SHT_GNU_INCREMENTAL_INPUTSSectionType.SHT_GNU_LIBLISTSectionType.SHT_GNU_verdefSectionType.SHT_GNU_verneedSectionType.SHT_GNU_versymSectionType.SHT_GROUPSectionType.SHT_HASHSectionType.SHT_HIOSSectionType.SHT_HIPROCSectionType.SHT_HISUNWSectionType.SHT_HIUSERSectionType.SHT_INIT_ARRAYSectionType.SHT_LOOSSectionType.SHT_LOPROCSectionType.SHT_LOSUNWSectionType.SHT_LOUSERSectionType.SHT_NOBITSSectionType.SHT_NOTESectionType.SHT_NULLSectionType.SHT_NUMSectionType.SHT_PREINIT_ARRAYSectionType.SHT_PROGBITSSectionType.SHT_RELSectionType.SHT_RELASectionType.SHT_SHLIBSectionType.SHT_STRTABSectionType.SHT_SUNW_COMDATSectionType.SHT_SUNW_moveSectionType.SHT_SUNW_syminfoSectionType.SHT_SYMTABSectionType.SHT_SYMTAB_SHNDX
SymbolBindingSymbolTypeSymbolVisibilityprogram_header_flags_name()program_header_name()special_section_name()
- objutils.elf.elfcons module
- objutils.elf.relocs module
- objutils.elf.testblocks module
- Module contents
DBAPIDebugInfoElfFileStructElfParserElfParser.BasicHeaderElfParser.DATATYPES32ElfParser.DATATYPES64ElfParser.EI_NIDENTElfParser._parse_comment()ElfParser._parse_note()ElfParser._parse_program_headers()ElfParser._parse_section_headers()ElfParser._parse_symbol_section()ElfParser._parser_extended_header()ElfParser.arm_attributesElfParser.commentElfParser.create_db_on_demand()ElfParser.create_image()ElfParser.create_section_to_segment_mapping()ElfParser.debug_sections()ElfParser.e_ehsizeElfParser.e_entryElfParser.e_flagsElfParser.e_machineElfParser.e_phentsizeElfParser.e_phnumElfParser.e_phoffElfParser.e_shentsizeElfParser.e_shnumElfParser.e_shoffElfParser.e_shstrndxElfParser.e_typeElfParser.e_versionElfParser.ei_abiversionElfParser.ei_classElfParser.ei_dataElfParser.ei_osabiElfParser.ei_versionElfParser.endianessElfParser.get_basic_header_field()ElfParser.get_extended_header_field()ElfParser.get_string()ElfParser.header_bytesElfParser.load_data()ElfParser.machine_dataElfParser.notesElfParser.queryElfParser.section_in_segment()ElfParser.section_in_segment1()ElfParser.section_in_segment_strict()ElfParser.section_size()ElfParser.segmentsElfParser.set_data_types()ElfParser.tbss_special()
ListToBytesAdapterPrintContextSectionAPISymbolAPIUTCTimeStamp()UTCTimeStampAdaptercalculate_crypto_hash()
- Subpackages
Submodules#
objutils.ash module#
- class objutils.ash.Reader(address_pattern='^(?:(?P<stx>[\\x02])\\s+)?\\$A(?P<address>[0-9a-zA-Z]{2,8})[,.]\\s*$', data_pattern='^(?:[0-9a-zA-Z]{{2,4}}[{0}]?)*\\s*$', etx_pattern='^q.*$')[source]#
Bases:
ASCIIHexReader- VALID_CHARS = re.compile("^[a-fA-F0-9 %,\\'\\$\\x02\\x03\\n\\r]*$")#
- codecName = 'ash'#
objutils.binfile module#
Reader/Writer for plain binfiles.
- class objutils.binfile.BinZipWriter[source]#
Bases:
object- MANIFEST_FILE_NAME = 'IMAGES.mf'#
- SECTION_FILE_NAME = 'image{0:d}.bin'#
- codecName = 'binzip'#
objutils.cc2vmc module#
objutils.checksums module#
- objutils.checksums.ADD11(frame)#
- objutils.checksums.ADD12(frame)#
- objutils.checksums.ADD14(frame)#
- objutils.checksums.ADD22(frame)#
- objutils.checksums.ADD24(frame)#
- objutils.checksums.ADD44(frame)#
- class objutils.checksums.Algorithm(*values)[source]#
Bases:
IntEnumEnumerates available checksum algorithms
- CHK_ADD_11 = 1#
- CHK_ADD_12 = 2#
- CHK_ADD_14 = 3#
- CHK_ADD_22 = 4#
- CHK_ADD_24 = 5#
- CHK_ADD_44 = 6#
- CHK_CRC_16 = 7#
- CHK_CRC_16_CCITT = 8#
- CHK_CRC_32 = 9#
- CHK_USER_DEFINED = 10#
- class objutils.checksums.Crc16(table, initalRemainder, finalXorValue, reflectData, reflectRemainder)[source]#
Bases:
objectCalculate CRC (16-bit)
- Parameters:
- table: list-like
lookup table for CRC calculation
- initalRemainderint
value to start with
- finalXorValueint
final XOR value
- reflectDatabool
reflect input data
- reflectRemainderbool
reflect output data
- .. [1] A PAINLESS GUIDE TO CRC ERROR DETECTION ALGORITHMS
- .. [2] Understanding and implementing CRC (Cyclic Redundancy Check)
calculation http://www.sunshine2k.de/articles/coding/crc/understanding_crc.html
- .. [3] Online CRC calculator
- WIDTH = 16#
- objutils.checksums.ROTATE_LEFT(value)#
Rotate byte left.
- objutils.checksums.ROTATE_RIGHT(value)#
Rotate byte right.
- objutils.checksums.adder(modulus)[source]#
Factory function for modulus adders
- Parameters:
- modulusint
modulus to use
- Returns:
- function
adder function
Examples
>>> a256=adder(256) >>> a256([11, 22, 33, 44, 55, 66, 77, 88, 99]) 239
- objutils.checksums.check(frame, algo)[source]#
Calculate checksum using given algorithm
- Parameters:
- framelist of integers
- algoALGO
- Returns:
- int
- objutils.checksums.reflect(data, nBits)[source]#
Reflect data, i.e. reverse bit order.
- Parameters:
- dataint
- nBitsint
width in bits of data
objutils.cosmac module#
objutils.emon52 module#
objutils.etek module#
objutils.exceptions module#
- exception objutils.exceptions.FeatureNotAvailableError[source]#
Bases:
ExceptionRaised if something is missing, e.g. Numpy for certain operations.
objutils.fpc module#
- class objutils.fpc.Reader[source]#
Bases:
Reader- FORMAT_SPEC = ((1, 'CCLL0000AAAAAAAADD'), (2, 'CCLL0001DD'), (3, 'CCLL0002AAAAAAAADD'), (4, '00000000'))#
- codecName = 'fpc'#
- probe(fp)[source]#
Determine if object is likely valid for this codec.
Strategy (robust, production-grade): - Quickly reject binary-looking content. - Sample up to 50 non-empty lines (or 8KB), decoding safely. - Count how many lines match this codec’s patterns. - Accept when we see sufficient evidence (>= 2 matches), or when
there’s exactly one non-empty sampled line and it matches (tiny files).
Always restore the file pointer to the beginning before returning.
objutils.hexdiff module#
objutils.hexdump module#
- class objutils.hexdump.CanonicalDumper(fp: ~typing.TextIO = <_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>, num_address_bits: int = 32)[source]#
Bases:
Dumper- LINE_LENGTH: int = 16#
objutils.hexfile module#
- class objutils.hexfile.ASCIIHexReader(address_pattern: str, data_pattern: str, etx_pattern: str, separators: str = ', ')[source]#
Bases:
Reader- FORMAT_SPEC = None#
- class objutils.hexfile.ASCIIHexWriter(address_designator: str)[source]#
Bases:
Writer- MAX_ADDRESS_BITS = 16#
- previous_address: int | None = None#
- class objutils.hexfile.FormatParser(fmt: str, data_separator: str | None = None)[source]#
Bases:
object
- class objutils.hexfile.MetaRecord(format_type: str, address: int | None, chunk: bytearray | None)[source]#
Bases:
object- address: int | None#
- chunk: bytearray | None#
- format_type: str#
- class objutils.hexfile.Reader[source]#
Bases:
BaseType- ALIGMENT = 0#
- DATA_SEPARATOR: str | None = None#
- VALID_CHARS = re.compile('^[a-fA-F0-9 :/;,%\\n\\r!?S]*$')#
- probe(fp: Any) bool[source]#
Determine if object is likely valid for this codec.
Strategy (robust, production-grade): - Quickly reject binary-looking content. - Sample up to 50 non-empty lines (or 8KB), decoding safely. - Count how many lines match this codec’s patterns. - Accept when we see sufficient evidence (>= 2 matches), or when
there’s exactly one non-empty sampled line and it matches (tiny files).
Always restore the file pointer to the beginning before returning.
- class objutils.hexfile.Statistics(record_types: collections.Counter[int] = <factory>, data_bytes: collections.Counter[int] = <factory>)[source]#
Bases:
object- data_bytes: Counter[int]#
- record_types: Counter[int]#
objutils.ihex module#
objutils.image module#
- class objutils.image.AddressSpace(*values)[source]#
Bases:
IntEnumAdress-space constants.
- AS_16 = 0#
- AS_24 = 1#
- AS_32 = 2#
- AS_64 = 3#
- class objutils.image.Image(sections=None, join=True, meta=None)[source]#
Bases:
objectManage images.
An image is a collection of :class:`Section`s and meta-data.
- Parameters:
- sections: iteratable (typically `list`or `tuple`
The sections the image should initialized with.
- meta: object
Arbitrary meta-data.
- _address_contained(address, length)[source]#
Check if address space exists.
- Parameters:
- address: int
- length: int
- Returns:
- bool
- get_section(address)[source]#
Get
Sectioncontaining address. Parameters ———- address: int- Returns:
Section
- Raises:
InvalidAddressError
- insert_section(data: bytes | bytearray | memoryview | str, start_address: int | None = None, join: bool = True)[source]#
Insert/add a new section to image.
- Parameters:
- data: convertible to bytearray() – s. :func:`_data_converter`.
Bytes making up the section.
- start_address: int
- join: bool
Join/merge adjacent section.
- Raises:
InvalidAddressError
Notes
Overlapping sections are not supported. To update/replace a section use
update_section().
- read(addr, length, **kws)[source]#
Read bytes from image.
- Parameters:
- addr: int
Startaddress.
- length: int
Number of bytes to read.
- Returns:
- bytes
- Raises:
InvalidAddressErrorif addr is out of range
- property sections#
objutils.logger module#
objutils.mostec module#
objutils.pickleif module#
objutils.rca module#
- class objutils.rca.Reader[source]#
Bases:
Reader- FORMAT_SPEC = ((1, 'AAAA DD;'), (2, ':0000'))#
- codecName = 'rca'#
- class objutils.rca.Writer[source]#
Bases:
Writer- MAX_ADDRESS_BITS = 16#
- SEPARATOR = '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\r\n'#
- codecName = 'rca'#
objutils.readers module#
objutils.registry module#
- class objutils.registry.Codec(Reader, Writer, description)[source]#
Bases:
NamedTuple- Reader: Type[Any]#
Alias for field number 0
- Writer: Type[Any]#
Alias for field number 1
- _asdict()#
Return a new dict which maps field names to their values.
- _field_defaults = {}#
- _fields = ('Reader', 'Writer', 'description')#
- classmethod _make(iterable)#
Make a new Codec object from a sequence or iterable
- _replace(**kwds)#
Return a new Codec object replacing specified fields with new values
- description: str#
Alias for field number 2
- class objutils.registry.Registry(*args, **kws)[source]#
Bases:
SingletonBase- _instance = <objutils.registry.Registry object>#
- property formats: list[str]#
objutils.section module#
- class objutils.section.NumberRange(lower, upper)#
Bases:
tuple- _asdict()#
Return a new dict which maps field names to their values.
- _field_defaults = {}#
- _fields = ('lower', 'upper')#
- classmethod _make(iterable)#
Make a new NumberRange object from a sequence or iterable
- _replace(**kwds)#
Return a new NumberRange object replacing specified fields with new values
- lower#
Alias for field number 0
- upper#
Alias for field number 1
- class objutils.section.Section(start_address: int = 0, data: bytearray = <factory>)[source]#
Bases:
objectManage sections.
A section is a continuous block of bytes, with a start-address and known length.
- property address: int#
- data: bytearray#
- property length: int#
- read_ndarray(addr: int, length: int, dtype: str, shape: tuple = None, order: str = None, **kws) ndarray[source]#
- start_address: int = 0#
- class objutils.section.TypeInformation(type, byte_order, size)#
Bases:
tuple- _asdict()#
Return a new dict which maps field names to their values.
- _field_defaults = {}#
- _fields = ('type', 'byte_order', 'size')#
- classmethod _make(iterable)#
Make a new TypeInformation object from a sequence or iterable
- _replace(**kwds)#
Return a new TypeInformation object replacing specified fields with new values
- byte_order#
Alias for field number 1
- size#
Alias for field number 2
- type#
Alias for field number 0
- objutils.section.filler(ch: int, n: int) bytearray[source]#
Create an bytearray consisting of n `ch`s.
- Parameters:
- ch: int (0 <= ch <= 255)
fill char
- n: int
repetition count
- Returns:
- bytearray
- objutils.section.fortran_array_from_buffer(arr: bytearray, shape: tuple, dtype: str) ndarray[source]#
- objutils.section.signed_range(x: int) NumberRange[source]#
- objutils.section.unsigned_range(x: int) NumberRange[source]#
objutils.sig module#
objutils.srec module#
- class objutils.srec.Reader[source]#
Bases:
Reader- FORMAT_SPEC = ((1, 'S0LLAAAADDCC'), (2, 'S1LLAAAADDCC'), (3, 'S2LLAAAAAADDCC'), (4, 'S3LLAAAAAAAADDCC'), (5, 'S5LLAAAACC'), (6, 'S7LLAAAAAAAACC'), (7, 'S8LLAAAAAACC'), (8, 'S9LLAAAACC'))#
- codecName = 'srec'#
- class objutils.srec.Writer[source]#
Bases:
Writer- MAX_ADDRESS_BITS = 32#
- static checksum(data, *, width=8, comp=1)#
Longitudinal redundancy check.
- codecName = 'srec'#
- compose_header(meta: Mapping[int, Sequence[MetaRecord]]) str[source]#
- record_type: int | None = None#
- s5record: bool = False#
- srecord(record_type: int, length: int, address: int, data: Sequence[int] | None = None) str[source]#
- start_address: int | None = None#
objutils.tek module#
objutils.titxt module#
- class objutils.titxt.Reader(address_pattern='^@(?P<address>[0-9a-zA-Z]{2,8})\\s*$', data_pattern='^(?:[0-9a-zA-Z]{{2,4}}[{0}]?)*\\s*$', etx_pattern='^q.*$')[source]#
Bases:
ASCIIHexReader- codecName = 'titxt'#
- class objutils.titxt.Writer(address_designator='@')[source]#
Bases:
ASCIIHexWriter- codecName = 'titxt'#
objutils.utils module#
- class objutils.utils.SingletonBase(*args, **kws)[source]#
Bases:
object- _lock = <unlocked _thread.lock object>#
- class objutils.utils.StructureWithEnums[source]#
Bases:
StructureAdd missing enum feature to ctypes Structures.
- _map = {}#
- objutils.utils.create_string_buffer(*args)[source]#
Create a string with file-like behaviour (StringIO on Python 2.x).
Module contents#
Package entry-point.
Registers CODECS and implements an interface to them.
The first parameter is always the codec name.
- class objutils.Image(sections=None, join=True, meta=None)[source]#
Bases:
objectManage images.
An image is a collection of :class:`Section`s and meta-data.
- Parameters:
- sections: iteratable (typically `list`or `tuple`
The sections the image should initialized with.
- meta: object
Arbitrary meta-data.
- _address_contained(address, length)[source]#
Check if address space exists.
- Parameters:
- address: int
- length: int
- Returns:
- bool
- get_section(address)[source]#
Get
Sectioncontaining address. Parameters ———- address: int- Returns:
- Raises:
InvalidAddressError
- insert_section(data: bytes | bytearray | memoryview | str, start_address: int | None = None, join: bool = True)[source]#
Insert/add a new section to image.
- Parameters:
- data: convertible to bytearray() – s. :func:`_data_converter`.
Bytes making up the section.
- start_address: int
- join: bool
Join/merge adjacent section.
- Raises:
InvalidAddressError
Notes
Overlapping sections are not supported. To update/replace a section use
update_section().
- read(addr, length, **kws)[source]#
Read bytes from image.
- Parameters:
- addr: int
Startaddress.
- length: int
Number of bytes to read.
- Returns:
- bytes
- Raises:
InvalidAddressErrorif addr is out of range
- property sections#
- class objutils.Section(start_address: int = 0, data: bytearray = <factory>)[source]#
Bases:
objectManage sections.
A section is a continuous block of bytes, with a start-address and known length.
- property address: int#
- data: bytearray#
- property length: int#
- read_ndarray(addr: int, length: int, dtype: str, shape: tuple = None, order: str = None, **kws) ndarray[source]#
- start_address: int = 0#
- objutils.dump(codec_name: str, *args: Any, **kws: Any) None[source]#
Save hex data to file.
- Parameters:
- codec_name: str
Name of a registered codec.
- Returns:
- bytes
- objutils.dumps(codec_name: str, *args: Any, **kws: Any) bytes[source]#
Save hex data to bytes.
- Parameters:
- codec_name: str
Name of a registered codec.
- Returns:
- bytes
- objutils.load(codec_name: str, *args: Any, **kws: Any) Image[source]#
Load hex data from file.
- Parameters:
- codec_name: str
Name of a registered codec.
- Returns:
- class:Image
- objutils.loads(codec_name: str, *args: Any, **kws: Any) Image[source]#
Load hex data from bytes.
- Parameters:
- codec_name: str
Name of a registered codec.
- Returns:
- class:Image