I downloaded the script to combine the roms from XDEVS.
When I ran it I got:
File "D:\Electronics\HP-Agilent-Keysight\3458A\Rev 9 Firmware\bincomp.py", line 6
print "Combine tool for 6 FW ROMs into 1 512KB ROM, hardcoded filenames in code\r\n (C) 2016 xDevs.com https://xdevs.com/fix/hp3458a\r\n Output is
generated into output_rev9.bin"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
So I wrapped the print command in () and moved to the next error:
Combine tool for 6 FW ROMs into 1 512KB ROM, hardcoded filenames in code
(C) 2016 xDevs.com https://xdevs.com/fix/hp3458a
Output is generated into output_rev9.bin
Traceback (most recent call last):
File "D:\Electronics\HP-Agilent-Keysight\3458A\Rev 9 Firmware\bincomp.py", line 15, in <module>
x.write ("%c%c" % (a.read(1),b.read(1)))
~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
TypeError: %c requires int or char
As I'm not Python literate, what do I need to change to accommodate the difference between (I assume) Python 2 and Python 3 so the script will work?
Thanks
David
Wrap a.read(1) and b.read(1) into int(). Like int(a.read(1)).
Not quite I fear - unless I misunderstood you:
Traceback (most recent call last):
File "D:\Electronics\HP-Agilent-Keysight\3458A\Rev 9 Firmware\bincomp.py", line 15, in <module>
x.write ("%c%c" % (int(a.read(1)),int(b.read(1))))
^^^^^^^^^^^^^^
ValueError: invalid literal for int() with base 10: b'\x01'
Well, it really depends on what those reads return. In this case they return byte string. So, you need to do more complicated stuff. I think something like this should work:
int.from_bytes(a.read(1), 'big'). Last part is byte order, but for 1 byte it does not matter.
I fear that doesn't work either:
Traceback (most recent call last):
File "D:\Electronics\HP-Agilent-Keysight\3458A\Rev 9 Firmware\bincomp.py", line 15, in <module>
x.write ("%c%c" % (int.from_bytes(a.read(1), 'big'),int.from_bytes(b.read(1), 'big')))
TypeError: a bytes-like object is required, not 'str'
D.
What version of Python do you have?
Since it is a single byte, you can just try a.read(1)[0]. I think this would return integer.
What are 'a' and 'b'? Regular files? How they were opened?
Did a.read(1)[0] work?
with open('03458_88890_061108_rev9_u110.bin','rb') as a:
with open('03458_88891_061108_rev9_u111.bin','rb') as b:
with open('03458_88892_061108_rev9_u112.bin','rb') as c:
with open('03458_88893_061108_rev9_u113.bin','rb') as d:
with open('03458_88894_061108_rev9_u114.bin','rb') as e:
with open('03458_88895_061108_rev9_u115.bin','rb') as f:
with open('output_rev9.bin','wb') as x:
Ah, the complaint now is not on building the string, but on writing it back. You need to convert the resulting string into a byte stream:
x.write (bytes("%c%c" % (......), 'ascii'))
perdrix, can you check if this works?
# xDevs.com Firmware combine tool
# https://xdevs.com/fix/hp3245a/
import os
print("Combine tool for 6 FW ROMs into 1 512KB ROM, hardcoded filenames in code\r\n (C) 2016 xDevs.com https://xdevs.com/fix/hp3458a\r\n Output is generated into output_rev9.bin")
with open('03458_88890_061108_rev9_u110.bin','rb') as a:
with open('03458_88891_061108_rev9_u111.bin','rb') as b:
with open('03458_88892_061108_rev9_u112.bin','rb') as c:
with open('03458_88893_061108_rev9_u113.bin','rb') as d:
with open('03458_88894_061108_rev9_u114.bin','rb') as e:
with open('03458_88895_061108_rev9_u115.bin','rb') as f:
with open('output_rev9.bin','wb') as x:
for cnt in range(0, 65536):
x.write(a.read(1) + b.read(1))
for cnt in range(0, 65536):
x.write(c.read(1) + d.read(1))
for cnt in range(0, 65536):
x.write(e.read(1) + f.read(1))
for cnt in range(0, 65536):
x.write(b'\xff\xff')
Python 3.11.3
That's your problem. It's a python 2 script, you should run it on the last version of 2.7 and it will likely just work, unless you really want to port it to python 3.