i'm hoping make use of intelhex
, not understanding needs passed convert entire file.
in test-usage.py
:
import os import sys intelhex import hex2bin open("foo.hex", "r") fin: start = 0 end = 218 size = none pad = none print("start: {}\nend: {}\nsize: {}\npad: {}".format(start, end, size, pad)) hex2bin(fin, sys.stdout, start, end, size, pad)
error:
start: 0 end: 218 size: none pad: none traceback (most recent call last): file "./test-usage.py", line 19, in <module> hex2bin(fin, sys.stdout, start, end, size, pad) file "/home/me/myvenv/lib/python3.4/site-packages/intelhex/__init__.py", line 1001, in hex2bin h.tobinfile(fout, start, end) file "/home/me/myvenv/lib/python3.4/site-packages/intelhex/__init__.py", line 412, in tobinfile fobj.write(self._tobinstr_really(start, end, pad, size)) typeerror: must str, not bytes
foo.hex
borrowed here:
:10001300ac12ad13ae10af1112002f8e0e8f0f2244 :10000300e50b250df509e50a350cf5081200132259 :03000000020023d8 :0c002300787fe4f6d8fd7581130200031d :10002f00eff88df0a4ffedc5f0cea42efeec88f016 :04003f00a42efe22cb :00000001ff
http://python-intelhex.readthedocs.org/en/latest/part3-1.html
support doesn't seem quite yet there python3. creating new virtual environment python2 (a little outside scope of question), i'm able execute without error.
env_name=testenv virtualenv -p /usr/bin/python2 ${env_name} source ${env_name}/bin/activate pip install intelhex==2.0 ./test-usage.py start: 0 end: 218 size: none pad: none #� � % 5 "����/"x����u����������Τ.�����.�"��������������������������������������������������������������������������������������������������������������������������������������������������������
i should note convert entire file, should leave non-file parameters default. example:
hex2bin(fin, sys.stdout)
Comments
Post a Comment