hi! that is what exactly what im trying to do. now im stuck else where
so, now, i have a list of hex values that i want to pack using struct.pack. so here's what i did after reading from the hex file
Code:
import sys,getopt
filename = file_location
blocksize = 1444352
opts,args = getopt.getopt(sys.argv[1:],'f:b:')
for o,a in opts:
if o == '-f':
filename = a
if o == '-b':
blocksize = a
offset = 0
with open(filename,"rb") as f:
block = f.read(blocksize)
str = ""
for ch in block:
str += hex(ord(ch))+" "
sector = []
c = 0
for s in str.split(' ') :
sector.append(s)
c += 1
if c == 128 :
sector.append("")
c = 0
sector = ', '.join(sector)
print sector
#struct.pack('B', sector)
sector = sector.split(',')
for items in sector[0:127] :
items = int(items, 16)
#print items
struct.pack('B', sector)
break
but i keep getting error message "struct error : cannot convert argument to integer"
but ive already converted to int