Author Topic: why I get errors from siglent magic script?  (Read 768 times)

0 Members and 1 Guest are viewing this topic.

Offline ali_asadzadehTopic starter

  • Super Contributor
  • ***
  • Posts: 1914
  • Country: ca
why I get errors from siglent magic script?
« on: March 07, 2023, 03:37:06 pm »
Hi
Here is the magic script,

Code: [Select]

import hashlib

SCOPEID = '0000000000000000'
Model   = 'SDS2000X+'

# Note that 'AWG' should be used for the 'FG' option
# If you have the 100 MHz model, then first upgrade it to 200 MHz, then 350 MHz and finally 500 MHz
bwopt = ('25M', '40M', '50M', '60M', '70M', '100M', '150M', '200M', '250M', '300M', '350M', '500M', '750M', '1000M', 'MAX', 'AWG', 'WIFI', 'MSO', 'FLX', 'CFD', 'I2S', '1553', 'PWA')

hashkey = '5zao9lyua01pp7hjzm3orcq90mds63z6zi5kv7vmv3ih981vlwn06txnjdtas3u2wa8msx61i12ueh14t7kqwsfskg032nhyuy1d9vv2wm925rd18kih9xhkyilobbgy'

def gen(x):
    h = hashlib.md5((
        hashkey +
        (Model+'\n').ljust(32, '\x00') +
        x.ljust(5, '\x00') +
        2*((SCOPEID + '\n').ljust(32, '\x00')) +
        '\x00'*16).encode('ascii')
    ).digest()
    key = ''
    for b in h:
        if (b <= 0x2F or b > 0x39) and (b <= 0x60 or b > 0x7A):
            m = b % 0x24
            b = m + (0x57 if m > 9 else 0x30)
        if b == 0x30: b = 0x32
        if b == 0x31: b = 0x33
        if b == 0x6c: b = 0x6d
        if b == 0x6f: b = 0x70
        key += chr(b)
    return key.upper()

for opt in bwopt:
    n = 4
    line = gen(opt)
    print('{:5} {}'.format(opt, [line[i:i+n] for i in range(0, len(line), n)]))

When I run it it would generate errors?

Quote
python scipt.py
Traceback (most recent call last):
  File "scipt.py", line 34, in <module>
    line = gen(opt)
  File "scipt.py", line 23, in gen
    m = b % 0x24
TypeError: not all arguments converted during string formatting

What am I missing?
Note I'm a noob in python
ASiDesigner, Stands for Application specific intelligent devices
I'm a Digital Expert from 8-bits to 64-bits
 

Offline TomKatt

  • Frequent Contributor
  • **
  • Posts: 524
  • Country: us
Re: why I get errors from siglent magic script?
« Reply #1 on: March 07, 2023, 03:44:00 pm »
I'm a linux noob myself and got similar errors when I ran the code.  Eventually I tried a different compiler and it worked fine.  Not sure what the problem was.

In any case, copy and paste your code into another compiler, like this online version: https://www.online-python.com/

I just tried it and it successfully completes.

Quote
25M   ['H3HM', '367P', 'XI5W', '4IFF']
40M   ['PYGM', 'FR4N', 'X9JQ', 'M773']
50M   ['4QT2', 'XCK5', 'KQGI', 'FVF2']
60M   ['2AK5', 'FCIM', '5V95', 'SSZU']
70M   ['K2VU', 'TKS5', 'HZ7K', 'HIPF']
100M  ['RQMM', 'HN26', '3YAZ', 'PP42']
150M  ['FYIR', 'YCWC', '93RB', '8D6Y']
200M  ['XAQY', 'K3EG', 'IWVB', '2JM5']
250M  ['IHY2', 'RJ23', 'U38A', 'DBZ3']
300M  ['MNPU', 'I696', 'AG7V', 'Q97M']
350M  ['PG4V', 'RZWZ', 'HR82', '2VGK']
500M  ['EQBR', 'ESJY', '5M2B', 'CYUG']
750M  ['MBMS', '697U', 'BJF3', 'DM5F']
1000M ['GDS3', 'BGYZ', 'ZPS3', '3GVP']
MAX   ['FI38', '72M2', 'CJDC', '2QKP']
AWG   ['5M2Z', '3J36', 'YFSK', 'BP4K']
WIFI  ['T2SF', 'DJT2', 'MGPG', 'V9RV']
MSO   ['CZBI', 'Z8BE', 'ZV8K', '9CPX']
FLX   ['K4Y8', 'PG5I', 'E3SC', '92C8']
CFD   ['YX2S', 'NZKM', 'W4W2', '4JDM']
I2S   ['2M2Y', '2M2Q', '2KHY', 'E5PK']
1553  ['6F3N', '5BVJ', 'MPDS', 'IMXU']
PWA   ['FFZU', 'MAUP', '7PQQ', '84V4']


** Process exited - Return Code: 0 **
Press Enter to exit terminal
« Last Edit: March 07, 2023, 06:56:37 pm by TomKatt »
Several Species of Small Furry Animals Gathered Together in a Cave and Grooving with a PICt
 

Offline colorado.rob

  • Frequent Contributor
  • **
  • Posts: 419
  • Country: us
Re: why I get errors from siglent magic script?
« Reply #2 on: March 07, 2023, 04:58:56 pm »
What version of Python are you using, 2 or 3?
 

Offline tautech

  • Super Contributor
  • ***
  • Posts: 28963
  • Country: nz
  • Taupaki Technologies Ltd. Siglent Distributor NZ.
    • Taupaki Technologies Ltd.
Re: why I get errors from siglent magic script?
« Reply #3 on: March 07, 2023, 06:52:10 pm »
Hi
Here is the magic script,

Code: [Select]
..............................


When I run it it would generate errors?

What am I missing?
Yours has lots of unnecessary  :blah:
It's very different to one I have saved so I suggest you look for another version.
Avid Rabid Hobbyist.
Siglent Youtube channel: https://www.youtube.com/@SiglentVideo/videos
 

Online abeyer

  • Frequent Contributor
  • **
  • Posts: 328
  • Country: us
Re: why I get errors from siglent magic script?
« Reply #4 on: March 07, 2023, 09:44:59 pm »
There's nothing wrong with that one, it's just python 3 and won't work as-is in python 2.

Adding
Code: [Select]
b = ord(b) between line 19 and 20 (the first line of the for loop) should get it to work in 2 if you need to, I think.
 

Offline ali_asadzadehTopic starter

  • Super Contributor
  • ***
  • Posts: 1914
  • Country: ca
Re: why I get errors from siglent magic script?
« Reply #5 on: March 08, 2023, 08:02:21 am »
my python version is Python 2.7.18
ASiDesigner, Stands for Application specific intelligent devices
I'm a Digital Expert from 8-bits to 64-bits
 

Offline ali_asadzadehTopic starter

  • Super Contributor
  • ***
  • Posts: 1914
  • Country: ca
Re: why I get errors from siglent magic script?
« Reply #6 on: March 08, 2023, 08:03:43 am »
I have changed to the latest python and it just works ^-^
ASiDesigner, Stands for Application specific intelligent devices
I'm a Digital Expert from 8-bits to 64-bits
 
The following users thanked this post: colorado.rob


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf