Project

General

Profile

Bug #10698 » mod_custom_freq_ranges.py

UV Mod Kitchen Freq Ranges .py - Ham Oppo, 07/08/2023 03:40 AM

 
1
# change below sets to new ones, values are in Hz
2
new_freq_low_limit =   [18_000_000, 25_000_000, 400_000_000, 420_000_000, 430_000_000, 440_000_000, 470_000_000]
3
new_freq_high_limit =  [24_999_900, 399_999_900, 419_999_900, 429_999_900, 439_999_900, 469_999_900, 1300_000_000]
4

    
5

    
6

    
7
##--------------------- do not modify below this line ---------------------------------------------------
8
import os,sys,struct
9

    
10
print('Running',os.path.basename(sys.argv[0]),'mod...')
11

    
12
if len(new_freq_low_limit)!=7: print('Do not change number of entries! Exiting'); exit(0)
13
if len(new_freq_high_limit)!=7: print('Do not change number of entries! Exiting'); exit(0)
14

    
15

    
16
fw =  bytearray(open(sys.argv[1],'rb').read())
17
current_steps = struct.unpack_from('<IIIIIII', fw, offset=0xE074) ; print('Old freq ranges:', [f'{i*10} Hz' for i in current_steps])
18
current_steps = struct.unpack_from('<IIIIIII', fw, offset=0xE090) ; print('Old freq ranges:', [f'{i*10} Hz' for i in current_steps])
19

    
20

    
21
## REPLACE LOW FREQS
22
if fw[0xE074:0xE074+(4*7)] == bytearray(struct.pack('<IIIIIII', *[5000000, 10800000, 13600000, 17400000, 35000000, 40000000, 47000000])):
23
    print('OK, lofreq table found, replacing')
24
    fw[0xE074:0xE074+(4*7)] = bytearray(struct.pack('<IIIIIII', *[i//10 for i in new_freq_low_limit]))
25
else:
26
    print('Error, orginal lofreq table doesnt match default values. Wrong fw ver?')
27
    
28
    
29

    
30
if fw[0xE090:0xE090+(4*7)] == bytearray(struct.pack('<IIIIIII', *[7600000, 13599990, 17399990, 34999990, 39999990, 46999990, 60000000])):
31
    print('OK, hifrew table found, replacing')
32
    fw[0xE090:0xE090+(4*7)] = bytearray(struct.pack('<IIIIIII', *[i//10 for i in new_freq_high_limit]))
33
else:
34
    print('Error, orginal lofreq table doesnt match default values. Wrong fw ver?')
35

    
36
current_steps = struct.unpack_from('<IIIIIII', fw, offset=0xE074) ; print('New freq ranges:', [f'{i*10} Hz' for i in current_steps])
37
current_steps = struct.unpack_from('<IIIIIII', fw, offset=0xE090) ; print('New freq ranges:', [f'{i*10} Hz' for i in current_steps])
38

    
39

    
40

    
41
open(sys.argv[1],'wb').write(fw)
(9-9/14)