Options
All
  • Public
  • Public/Protected
  • All
Menu

Module ihex

Generate and process Intel Hex records.

Variables

Const MAX_RECORD_STR_LEN

MAX_RECORD_STR_LEN: number = MIN_RECORD_STR_LEN - DATA_STR_LEN_MIN + RECORD_DATA_MAX_BYTES * 2

Functions

blockEndRecord

  • blockEndRecord(padBytesLen: number): string
  • Create Block End (custom) Intel Hex Record.

    The Data field in this Record will be ignored and can be used for padding.

    Parameters

    • padBytesLen: number

      Number of bytes to add to the Data field.

    Returns string

    A Block End (custom) Intel Hex record.

blockStartRecord

  • blockStartRecord(boardId: number): string
  • Creates a Block Start (custom) Intel Hex Record.

    Parameters

    • boardId: number

      Board ID to embed into the record, 0 to 0xFFF.

    Returns string

    A Block Start (custom) Intel Hex record.

convertExtSegToLinAddressRecord

  • convertExtSegToLinAddressRecord(iHexRecord: string): string
  • Converts and Extended Segment Linear Address record to an Extended Linear Address record.

    throws

    {Error} When the record does not contain exactly 2 bytes.

    throws

    {Error} When the Segmented Address is not a multiple of 0x1000.

    Parameters

    • iHexRecord: string

      Intel hex record line without line terminator.

    Returns string

convertRecordTo

  • convertRecordTo(iHexRecord: string, recordType: RecordType): string
  • Changes the record type of a Record to a Custom Data type.

    The data field is kept, but changing the record type will trigger the checksum to be updated as well.

    Parameters

    • iHexRecord: string

      Intel hex record line without line terminator.

    • recordType: RecordType

    Returns string

    A Custom Data Intel Hex record with the same data field.

createRecord

  • createRecord(address: number, recordType: RecordType, dataBytes: Uint8Array): string
  • Creates an Intel Hex record with normal or custom record types.

    Parameters

    • address: number

      The two least significant bytes for the data address.

    • recordType: RecordType

      Record type, could be one of the standard types or any of the custom types created for forming a Universal Hex.

    • dataBytes: Uint8Array

      Byte array with the data to include in the record.

    Returns string

    A string with the Intel Hex record.

endOfFileRecord

  • endOfFileRecord(): string
  • Creates an End Of File Intel Hex record.

    Returns string

    End of File record with new line.

extLinAddressRecord

  • extLinAddressRecord(address: number): string
  • Creates an Extended Linear Address record from a 4 byte address.

    Parameters

    • address: number

      Full 32 bit address.

    Returns string

    The Extended Linear Address Intel Hex record.

findDataFieldLength

  • findDataFieldLength(iHexRecords: string[]): number
  • Iterates through the beginning of an array of Intel Hex records to find the longest record data field length.

    Once it finds 12 records at the maximum size found so far (starts at 16 bytes) it will stop iterating.

    This is useful to identify the expected max size of the data records for an Intel Hex, and then be able to generate new custom records of the same size.

    Parameters

    • iHexRecords: string[]

      Array of Intel Hex Records.

    Returns number

    Number of data bytes in a full record.

getRecordData

  • getRecordData(iHexRecord: string): Uint8Array
  • Retrieves the data field from a record.

    Parameters

    • iHexRecord: string

      Intel Hex record string.

    Returns Uint8Array

    The record Data in a byte array.

getRecordType

  • Retrieves the Record Type form an Intel Hex record line.

    Parameters

    • iHexRecord: string

      Intel hex record line without line terminator.

    Returns RecordType

    The RecordType value.

iHexToRecordStrs

  • iHexToRecordStrs(iHexStr: string): string[]
  • Separates an Intel Hex file (string) into an array of Record strings.

    Parameters

    • iHexStr: string

      Intel Hex file as a string.

    Returns string[]

    Array of Records in string format.

paddedDataRecord

  • paddedDataRecord(padBytesLen: number): string
  • Create a Padded Data (custom) Intel Hex Record. This record is used to add padding data, to be ignored by DAPLink, to be able to create blocks of 512-bytes.

    Parameters

    • padBytesLen: number

      Number of bytes to add to the Data field.

    Returns string

    A Padded Data (custom) Intel Hex record.

parseRecord

  • parseRecord(iHexRecord: string): Record
  • Parses an Intel Hex record into an Record object with its respective fields.

    Parameters

    • iHexRecord: string

      Intel hex record line without line terminator.

    Returns Record

    New object with the Record interface.

Generated using TypeDoc