to_strings¶
- hexrec.formats.sqtp.to_strings(file, retlw=False)[source]¶
Extracts byte strings from a file.
Given a Microchip SQTP file (as special Intel HEX format), it extracts byte strings from data records.
Warning
This algorithm ignores addressing. It just takes data records. Please provide valid Microchip SQTP files only.
- Parameters:
file (
IhexFile) – Microchip SQTP file as special Intel HEX format.retlw (bool) – The
RETLWbyte is put after each byte of the byte string. If true, it ignores theRETLWbytes.
- Returns:
list of int – Sequence of byte strings.
Examples
>>> from hexrec import IhexFile >>> from hexrec.formats.sqtp import to_strings
>>> file = IhexFile.parse(b''' ... :020000040000FA ... :0D0000006162636465666768696A6B6C6DB8 ... :0D0000006E6F707172737475767778797A0F ... :0D0000004142434445464748494A4B4C4D58 ... :0D0000004E4F505152535455565758595AAF ... :00000001FF ... ''') >>> to_strings(file) [b'abcdefghijklm', b'nopqrstuvwxyz', b'ABCDEFGHIJKLM', b'NOPQRSTUVWXYZ']
>>> file = IhexFile.parse(b''' ... :020000047F007B ... :0DBFC0006162636465666768696A6B6C6D39 ... :0DBFC0006E6F707172737475767778797A90 ... :0DBFC0004142434445464748494A4B4C4DD9 ... :0DBFC0004E4F505152535455565758595A30 ... :00000001FF ... ''') >>> to_strings(file) [b'abcdefghijklm', b'nopqrstuvwxyz', b'ABCDEFGHIJKLM', b'NOPQRSTUVWXYZ']
>>> file = IhexFile.parse(b''' ... :020000040001F9 ... :1A0000006134623463346434653466346734683469346A346B346C346D3407 ... :1A0000006E346F3470347134723473347434753476347734783479347A345E ... :1A0000004134423443344434453446344734483449344A344B344C344D34A7 ... :1A0000004E344F3450345134523453345434553456345734583459345A34FE ... :00000001FF ... ''') >>> to_strings(file, retlw=True) [b'abcdefghijklm', b'nopqrstuvwxyz', b'ABCDEFGHIJKLM', b'NOPQRSTUVWXYZ']