mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-29 22:20:37 +00:00
update python scripts to python3
This commit is contained in:
parent
f508b9c49c
commit
6ccd824859
66
3rd-party/micro-ecc/scripts/mult_arm.py
vendored
66
3rd-party/micro-ecc/scripts/mult_arm.py
vendored
@ -1,9 +1,9 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import sys
|
||||
|
||||
if len(sys.argv) < 2:
|
||||
print "Provide the integer size in 32-bit words"
|
||||
print("Provide the integer size in 32-bit words")
|
||||
sys.exit(1)
|
||||
|
||||
size = int(sys.argv[1])
|
||||
@ -17,7 +17,7 @@ if init_size == 0:
|
||||
|
||||
def emit(line, *args):
|
||||
s = '"' + line + r' \n\t"'
|
||||
print s % args
|
||||
print(s % args)
|
||||
|
||||
rx = [3, 4, 5]
|
||||
ry = [6, 7, 8]
|
||||
@ -26,10 +26,10 @@ ry = [6, 7, 8]
|
||||
emit("add r0, %s", (size - init_size) * 4) # move z
|
||||
emit("add r2, %s", (size - init_size) * 4) # move y
|
||||
|
||||
emit("ldmia r1!, {%s}", ", ".join(["r%s" % (rx[i]) for i in xrange(init_size)]))
|
||||
emit("ldmia r2!, {%s}", ", ".join(["r%s" % (ry[i]) for i in xrange(init_size)]))
|
||||
emit("ldmia r1!, {%s}", ", ".join(["r%s" % (rx[i]) for i in range(init_size)]))
|
||||
emit("ldmia r2!, {%s}", ", ".join(["r%s" % (ry[i]) for i in range(init_size)]))
|
||||
|
||||
print ""
|
||||
print("")
|
||||
if init_size == 1:
|
||||
emit("umull r9, r10, r3, r6")
|
||||
emit("stmia r0!, {r9, r10}")
|
||||
@ -37,7 +37,7 @@ else:
|
||||
#### first two multiplications of initial block
|
||||
emit("umull r11, r12, r3, r6")
|
||||
emit("stmia r0!, {r11}")
|
||||
print ""
|
||||
print("")
|
||||
emit("mov r10, #0")
|
||||
emit("umull r11, r9, r3, r7")
|
||||
emit("adds r12, r11")
|
||||
@ -47,29 +47,29 @@ else:
|
||||
emit("adcs r9, r14")
|
||||
emit("adc r10, #0")
|
||||
emit("stmia r0!, {r12}")
|
||||
print ""
|
||||
print("")
|
||||
|
||||
#### rest of initial block, with moving accumulator registers
|
||||
acc = [9, 10, 11, 12, 14]
|
||||
if init_size == 3:
|
||||
emit("mov r%s, #0", acc[2])
|
||||
for i in xrange(0, 3):
|
||||
for i in range(0, 3):
|
||||
emit("umull r%s, r%s, r%s, r%s", acc[3], acc[4], rx[i], ry[2 - i])
|
||||
emit("adds r%s, r%s", acc[0], acc[3])
|
||||
emit("adcs r%s, r%s", acc[1], acc[4])
|
||||
emit("adc r%s, #0", acc[2])
|
||||
emit("stmia r0!, {r%s}", acc[0])
|
||||
print ""
|
||||
print("")
|
||||
acc = acc[1:] + acc[:1]
|
||||
|
||||
emit("mov r%s, #0", acc[2])
|
||||
for i in xrange(0, 2):
|
||||
for i in range(0, 2):
|
||||
emit("umull r%s, r%s, r%s, r%s", acc[3], acc[4], rx[i + 1], ry[2 - i])
|
||||
emit("adds r%s, r%s", acc[0], acc[3])
|
||||
emit("adcs r%s, r%s", acc[1], acc[4])
|
||||
emit("adc r%s, #0", acc[2])
|
||||
emit("stmia r0!, {r%s}", acc[0])
|
||||
print ""
|
||||
print("")
|
||||
acc = acc[1:] + acc[:1]
|
||||
|
||||
emit("umull r%s, r%s, r%s, r%s", acc[3], acc[4], rx[init_size-1], ry[init_size-1])
|
||||
@ -77,25 +77,25 @@ else:
|
||||
emit("adc r%s, r%s", acc[1], acc[4])
|
||||
emit("stmia r0!, {r%s}", acc[0])
|
||||
emit("stmia r0!, {r%s}", acc[1])
|
||||
print ""
|
||||
print("")
|
||||
|
||||
#### reset y and z pointers
|
||||
emit("sub r0, %s", (2 * init_size + 3) * 4)
|
||||
emit("sub r2, %s", (init_size + 3) * 4)
|
||||
|
||||
#### load y registers
|
||||
emit("ldmia r2!, {%s}", ", ".join(["r%s" % (ry[i]) for i in xrange(3)]))
|
||||
emit("ldmia r2!, {%s}", ", ".join(["r%s" % (ry[i]) for i in range(3)]))
|
||||
|
||||
#### load additional x registers
|
||||
if init_size != 3:
|
||||
emit("ldmia r1!, {%s}", ", ".join(["r%s" % (rx[i]) for i in xrange(init_size, 3)]))
|
||||
print ""
|
||||
emit("ldmia r1!, {%s}", ", ".join(["r%s" % (rx[i]) for i in range(init_size, 3)]))
|
||||
print("")
|
||||
|
||||
prev_size = init_size
|
||||
for row in xrange(full_rows):
|
||||
for row in range(full_rows):
|
||||
emit("umull r11, r12, r3, r6")
|
||||
emit("stmia r0!, {r11}")
|
||||
print ""
|
||||
print("")
|
||||
emit("mov r10, #0")
|
||||
emit("umull r11, r9, r3, r7")
|
||||
emit("adds r12, r11")
|
||||
@ -105,26 +105,26 @@ for row in xrange(full_rows):
|
||||
emit("adcs r9, r14")
|
||||
emit("adc r10, #0")
|
||||
emit("stmia r0!, {r12}")
|
||||
print ""
|
||||
print("")
|
||||
|
||||
acc = [9, 10, 11, 12, 14]
|
||||
emit("mov r%s, #0", acc[2])
|
||||
for i in xrange(0, 3):
|
||||
for i in range(0, 3):
|
||||
emit("umull r%s, r%s, r%s, r%s", acc[3], acc[4], rx[i], ry[2 - i])
|
||||
emit("adds r%s, r%s", acc[0], acc[3])
|
||||
emit("adcs r%s, r%s", acc[1], acc[4])
|
||||
emit("adc r%s, #0", acc[2])
|
||||
emit("stmia r0!, {r%s}", acc[0])
|
||||
print ""
|
||||
print("")
|
||||
acc = acc[1:] + acc[:1]
|
||||
|
||||
#### now we need to start shifting x and loading from z
|
||||
x_regs = [3, 4, 5]
|
||||
for r in xrange(0, prev_size):
|
||||
for r in range(0, prev_size):
|
||||
x_regs = x_regs[1:] + x_regs[:1]
|
||||
emit("ldmia r1!, {r%s}", x_regs[2])
|
||||
emit("mov r%s, #0", acc[2])
|
||||
for i in xrange(0, 3):
|
||||
for i in range(0, 3):
|
||||
emit("umull r%s, r%s, r%s, r%s", acc[3], acc[4], x_regs[i], ry[2 - i])
|
||||
emit("adds r%s, r%s", acc[0], acc[3])
|
||||
emit("adcs r%s, r%s", acc[1], acc[4])
|
||||
@ -134,16 +134,16 @@ for row in xrange(full_rows):
|
||||
emit("adcs r%s, #0", acc[1])
|
||||
emit("adc r%s, #0", acc[2])
|
||||
emit("stmia r0!, {r%s}", acc[0])
|
||||
print ""
|
||||
print("")
|
||||
acc = acc[1:] + acc[:1]
|
||||
|
||||
# done shifting x, start shifting y
|
||||
y_regs = [6, 7, 8]
|
||||
for r in xrange(0, prev_size):
|
||||
for r in range(0, prev_size):
|
||||
y_regs = y_regs[1:] + y_regs[:1]
|
||||
emit("ldmia r2!, {r%s}", y_regs[2])
|
||||
emit("mov r%s, #0", acc[2])
|
||||
for i in xrange(0, 3):
|
||||
for i in range(0, 3):
|
||||
emit("umull r%s, r%s, r%s, r%s", acc[3], acc[4], x_regs[i], y_regs[2 - i])
|
||||
emit("adds r%s, r%s", acc[0], acc[3])
|
||||
emit("adcs r%s, r%s", acc[1], acc[4])
|
||||
@ -153,18 +153,18 @@ for row in xrange(full_rows):
|
||||
emit("adcs r%s, #0", acc[1])
|
||||
emit("adc r%s, #0", acc[2])
|
||||
emit("stmia r0!, {r%s}", acc[0])
|
||||
print ""
|
||||
print("")
|
||||
acc = acc[1:] + acc[:1]
|
||||
|
||||
# done both shifts, do remaining corner
|
||||
emit("mov r%s, #0", acc[2])
|
||||
for i in xrange(0, 2):
|
||||
for i in range(0, 2):
|
||||
emit("umull r%s, r%s, r%s, r%s", acc[3], acc[4], x_regs[i + 1], y_regs[2 - i])
|
||||
emit("adds r%s, r%s", acc[0], acc[3])
|
||||
emit("adcs r%s, r%s", acc[1], acc[4])
|
||||
emit("adc r%s, #0", acc[2])
|
||||
emit("stmia r0!, {r%s}", acc[0])
|
||||
print ""
|
||||
print("")
|
||||
acc = acc[1:] + acc[:1]
|
||||
|
||||
emit("umull r%s, r%s, r%s, r%s", acc[3], acc[4], x_regs[2], y_regs[2])
|
||||
@ -172,7 +172,7 @@ for row in xrange(full_rows):
|
||||
emit("adc r%s, r%s", acc[1], acc[4])
|
||||
emit("stmia r0!, {r%s}", acc[0])
|
||||
emit("stmia r0!, {r%s}", acc[1])
|
||||
print ""
|
||||
print("")
|
||||
|
||||
prev_size = prev_size + 3
|
||||
if row < full_rows - 1:
|
||||
@ -182,7 +182,7 @@ for row in xrange(full_rows):
|
||||
emit("sub r2, %s", (prev_size + 3) * 4)
|
||||
|
||||
#### load x and y registers
|
||||
emit("ldmia r1!, {%s}", ",".join(["r%s" % (rx[i]) for i in xrange(3)]))
|
||||
emit("ldmia r2!, {%s}", ",".join(["r%s" % (ry[i]) for i in xrange(3)]))
|
||||
emit("ldmia r1!, {%s}", ",".join(["r%s" % (rx[i]) for i in range(3)]))
|
||||
emit("ldmia r2!, {%s}", ",".join(["r%s" % (ry[i]) for i in range(3)]))
|
||||
|
||||
print ""
|
||||
print("")
|
||||
|
72
3rd-party/micro-ecc/scripts/mult_avr.py
vendored
72
3rd-party/micro-ecc/scripts/mult_avr.py
vendored
@ -1,9 +1,9 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import sys
|
||||
|
||||
if len(sys.argv) < 2:
|
||||
print "Provide the integer size in bytes"
|
||||
print("Provide the integer size in bytes")
|
||||
sys.exit(1)
|
||||
|
||||
size = int(sys.argv[1])
|
||||
@ -23,19 +23,19 @@ def ry(i):
|
||||
|
||||
def emit(line, *args):
|
||||
s = '"' + line + r' \n\t"'
|
||||
print s % args
|
||||
print(s % args)
|
||||
|
||||
#### set up registers
|
||||
emit("adiw r30, %s", size - init_size) # move z
|
||||
emit("adiw r28, %s", size - init_size) # move y
|
||||
|
||||
for i in xrange(init_size):
|
||||
for i in range(init_size):
|
||||
emit("ld r%s, x+", rx(i))
|
||||
for i in xrange(init_size):
|
||||
for i in range(init_size):
|
||||
emit("ld r%s, y+", ry(i))
|
||||
|
||||
emit("ldi r25, 0")
|
||||
print ""
|
||||
print("")
|
||||
if init_size == 1:
|
||||
emit("mul r2, r12")
|
||||
emit("st z+, r0")
|
||||
@ -46,7 +46,7 @@ else:
|
||||
emit("mul r2, r12")
|
||||
emit("st z+, r0")
|
||||
emit("mov r22, r1")
|
||||
print ""
|
||||
print("")
|
||||
emit("ldi r24, 0")
|
||||
emit("mul r2, r13")
|
||||
emit("add r22, r0")
|
||||
@ -56,58 +56,58 @@ else:
|
||||
emit("adc r23, r1")
|
||||
emit("adc r24, r25")
|
||||
emit("st z+, r22")
|
||||
print ""
|
||||
print("")
|
||||
|
||||
#### rest of initial block, with moving accumulator registers
|
||||
acc = [23, 24, 22]
|
||||
for r in xrange(2, init_size):
|
||||
for r in range(2, init_size):
|
||||
emit("ldi r%s, 0", acc[2])
|
||||
for i in xrange(0, r+1):
|
||||
for i in range(0, r+1):
|
||||
emit("mul r%s, r%s", rx(i), ry(r - i))
|
||||
emit("add r%s, r0", acc[0])
|
||||
emit("adc r%s, r1", acc[1])
|
||||
emit("adc r%s, r25", acc[2])
|
||||
emit("st z+, r%s", acc[0])
|
||||
print ""
|
||||
print("")
|
||||
acc = acc[1:] + acc[:1]
|
||||
for r in xrange(1, init_size-1):
|
||||
for r in range(1, init_size-1):
|
||||
emit("ldi r%s, 0", acc[2])
|
||||
for i in xrange(0, init_size-r):
|
||||
for i in range(0, init_size-r):
|
||||
emit("mul r%s, r%s", rx(r+i), ry((init_size-1) - i))
|
||||
emit("add r%s, r0", acc[0])
|
||||
emit("adc r%s, r1", acc[1])
|
||||
emit("adc r%s, r25", acc[2])
|
||||
emit("st z+, r%s", acc[0])
|
||||
print ""
|
||||
print("")
|
||||
acc = acc[1:] + acc[:1]
|
||||
emit("mul r%s, r%s", rx(init_size-1), ry(init_size-1))
|
||||
emit("add r%s, r0", acc[0])
|
||||
emit("adc r%s, r1", acc[1])
|
||||
emit("st z+, r%s", acc[0])
|
||||
emit("st z+, r%s", acc[1])
|
||||
print ""
|
||||
print("")
|
||||
|
||||
#### reset y and z pointers
|
||||
emit("sbiw r30, %s", 2 * init_size + 10)
|
||||
emit("sbiw r28, %s", init_size + 10)
|
||||
|
||||
#### load y registers
|
||||
for i in xrange(10):
|
||||
for i in range(10):
|
||||
emit("ld r%s, y+", ry(i))
|
||||
|
||||
#### load additional x registers
|
||||
for i in xrange(init_size, 10):
|
||||
for i in range(init_size, 10):
|
||||
emit("ld r%s, x+", rx(i))
|
||||
print ""
|
||||
print("")
|
||||
|
||||
prev_size = init_size
|
||||
for row in xrange(full_rows):
|
||||
for row in range(full_rows):
|
||||
#### do x = 0-9, y = 0-9 multiplications
|
||||
emit("ldi r23, 0")
|
||||
emit("mul r2, r12")
|
||||
emit("st z+, r0")
|
||||
emit("mov r22, r1")
|
||||
print ""
|
||||
print("")
|
||||
emit("ldi r24, 0")
|
||||
emit("mul r2, r13")
|
||||
emit("add r22, r0")
|
||||
@ -117,27 +117,27 @@ for row in xrange(full_rows):
|
||||
emit("adc r23, r1")
|
||||
emit("adc r24, r25")
|
||||
emit("st z+, r22")
|
||||
print ""
|
||||
print("")
|
||||
|
||||
acc = [23, 24, 22]
|
||||
for r in xrange(2, 10):
|
||||
for r in range(2, 10):
|
||||
emit("ldi r%s, 0", acc[2])
|
||||
for i in xrange(0, r+1):
|
||||
for i in range(0, r+1):
|
||||
emit("mul r%s, r%s", rx(i), ry(r - i))
|
||||
emit("add r%s, r0", acc[0])
|
||||
emit("adc r%s, r1", acc[1])
|
||||
emit("adc r%s, r25", acc[2])
|
||||
emit("st z+, r%s", acc[0])
|
||||
print ""
|
||||
print("")
|
||||
acc = acc[1:] + acc[:1]
|
||||
|
||||
#### now we need to start shifting x and loading from z
|
||||
x_regs = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
|
||||
for r in xrange(0, prev_size):
|
||||
for r in range(0, prev_size):
|
||||
x_regs = x_regs[1:] + x_regs[:1]
|
||||
emit("ld r%s, x+", x_regs[9]) # load next byte of left
|
||||
emit("ldi r%s, 0", acc[2])
|
||||
for i in xrange(0, 10):
|
||||
for i in range(0, 10):
|
||||
emit("mul r%s, r%s", x_regs[i], ry(9 - i))
|
||||
emit("add r%s, r0", acc[0])
|
||||
emit("adc r%s, r1", acc[1])
|
||||
@ -147,16 +147,16 @@ for row in xrange(full_rows):
|
||||
emit("adc r%s, r25", acc[1])
|
||||
emit("adc r%s, r25", acc[2])
|
||||
emit("st z+, r%s", acc[0]) # store next byte (z increments)
|
||||
print ""
|
||||
print("")
|
||||
acc = acc[1:] + acc[:1]
|
||||
|
||||
# done shifting x, start shifting y
|
||||
y_regs = [12, 13, 14, 15, 16, 17, 18, 19, 20, 21]
|
||||
for r in xrange(0, prev_size):
|
||||
for r in range(0, prev_size):
|
||||
y_regs = y_regs[1:] + y_regs[:1]
|
||||
emit("ld r%s, y+", y_regs[9]) # load next byte of right
|
||||
emit("ldi r%s, 0", acc[2])
|
||||
for i in xrange(0, 10):
|
||||
for i in range(0, 10):
|
||||
emit("mul r%s, r%s", x_regs[i], y_regs[9 -i])
|
||||
emit("add r%s, r0", acc[0])
|
||||
emit("adc r%s, r1", acc[1])
|
||||
@ -166,26 +166,26 @@ for row in xrange(full_rows):
|
||||
emit("adc r%s, r25", acc[1])
|
||||
emit("adc r%s, r25", acc[2])
|
||||
emit("st z+, r%s", acc[0]) # store next byte (z increments)
|
||||
print ""
|
||||
print("")
|
||||
acc = acc[1:] + acc[:1]
|
||||
|
||||
# done both shifts, do remaining corner
|
||||
for r in xrange(1, 9):
|
||||
for r in range(1, 9):
|
||||
emit("ldi r%s, 0", acc[2])
|
||||
for i in xrange(0, 10-r):
|
||||
for i in range(0, 10-r):
|
||||
emit("mul r%s, r%s", x_regs[r+i], y_regs[9 - i])
|
||||
emit("add r%s, r0", acc[0])
|
||||
emit("adc r%s, r1", acc[1])
|
||||
emit("adc r%s, r25", acc[2])
|
||||
emit("st z+, r%s", acc[0])
|
||||
print ""
|
||||
print("")
|
||||
acc = acc[1:] + acc[:1]
|
||||
emit("mul r%s, r%s", x_regs[9], y_regs[9])
|
||||
emit("add r%s, r0", acc[0])
|
||||
emit("adc r%s, r1", acc[1])
|
||||
emit("st z+, r%s", acc[0])
|
||||
emit("st z+, r%s", acc[1])
|
||||
print ""
|
||||
print("")
|
||||
|
||||
prev_size = prev_size + 10
|
||||
if row < full_rows - 1:
|
||||
@ -195,9 +195,9 @@ for row in xrange(full_rows):
|
||||
emit("sbiw r26, %s", prev_size)
|
||||
|
||||
#### load x and y registers
|
||||
for i in xrange(10):
|
||||
for i in range(10):
|
||||
emit("ld r%s, x+", rx(i))
|
||||
emit("ld r%s, y+", ry(i))
|
||||
print ""
|
||||
print("")
|
||||
|
||||
emit("eor r1, r1")
|
||||
|
50
3rd-party/micro-ecc/scripts/square_arm.py
vendored
50
3rd-party/micro-ecc/scripts/square_arm.py
vendored
@ -1,15 +1,15 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import sys
|
||||
|
||||
if len(sys.argv) < 2:
|
||||
print "Provide the integer size in 32-bit words"
|
||||
print("Provide the integer size in 32-bit words")
|
||||
sys.exit(1)
|
||||
|
||||
size = int(sys.argv[1])
|
||||
|
||||
if size > 8:
|
||||
print "This script doesn't work with integer size %s due to laziness" % (size)
|
||||
print("This script doesn't work with integer size %s due to laziness" % (size))
|
||||
sys.exit(1)
|
||||
|
||||
init_size = 0
|
||||
@ -18,7 +18,7 @@ if size > 6:
|
||||
|
||||
def emit(line, *args):
|
||||
s = '"' + line + r' \n\t"'
|
||||
print s % args
|
||||
print(s % args)
|
||||
|
||||
def mulacc(acc, r1, r2):
|
||||
if size <= 6:
|
||||
@ -48,41 +48,41 @@ if init_size == 1:
|
||||
|
||||
emit("sub r0, %s", (size + init_size) * 4)
|
||||
emit("sub r1, %s", (size) * 4)
|
||||
print ""
|
||||
print("")
|
||||
elif init_size == 2:
|
||||
emit("ldmia r1!, {r2, r3}")
|
||||
emit("add r1, %s", (size - init_size * 2) * 4)
|
||||
emit("ldmia r1!, {r5, r6}")
|
||||
|
||||
emit("add r0, %s", (size - init_size) * 4)
|
||||
print ""
|
||||
print("")
|
||||
|
||||
emit("umull r8, r9, r2, r5")
|
||||
emit("stmia r0!, {r8}")
|
||||
print ""
|
||||
print("")
|
||||
|
||||
emit("umull r12, r10, r2, r6")
|
||||
emit("adds r9, r12")
|
||||
emit("adc r10, #0")
|
||||
emit("stmia r0!, {r9}")
|
||||
print ""
|
||||
print("")
|
||||
|
||||
emit("umull r8, r9, r3, r6")
|
||||
emit("adds r10, r8")
|
||||
emit("adc r11, r9, #0")
|
||||
emit("stmia r0!, {r10, r11}")
|
||||
print ""
|
||||
print("")
|
||||
|
||||
emit("sub r0, %s", (size + init_size) * 4)
|
||||
emit("sub r1, %s", (size) * 4)
|
||||
|
||||
# load input words
|
||||
emit("ldmia r1!, {%s}", ", ".join(["r%s" % (r[i]) for i in xrange(s)]))
|
||||
print ""
|
||||
emit("ldmia r1!, {%s}", ", ".join(["r%s" % (r[i]) for i in range(s)]))
|
||||
print("")
|
||||
|
||||
emit("umull r11, r12, r2, r2")
|
||||
emit("stmia r0!, {r11}")
|
||||
print ""
|
||||
print("")
|
||||
emit("mov r9, #0")
|
||||
emit("umull r10, r11, r2, r3")
|
||||
emit("adds r12, r10")
|
||||
@ -92,7 +92,7 @@ emit("adds r12, r10")
|
||||
emit("adcs r8, r11")
|
||||
emit("adc r9, #0")
|
||||
emit("stmia r0!, {r12}")
|
||||
print ""
|
||||
print("")
|
||||
emit("mov r10, #0")
|
||||
emit("umull r11, r12, r2, r4")
|
||||
emit("adds r11, r11")
|
||||
@ -106,11 +106,11 @@ emit("adds r8, r11")
|
||||
emit("adcs r9, r12")
|
||||
emit("adc r10, #0")
|
||||
emit("stmia r0!, {r8}")
|
||||
print ""
|
||||
print("")
|
||||
|
||||
acc = [8, 9, 10]
|
||||
old_acc = [11, 12]
|
||||
for i in xrange(3, s):
|
||||
for i in range(3, s):
|
||||
emit("mov r%s, #0", old_acc[1])
|
||||
tmp = [acc[1], acc[2]]
|
||||
acc = [acc[0], old_acc[0], old_acc[1]]
|
||||
@ -118,7 +118,7 @@ for i in xrange(3, s):
|
||||
|
||||
# gather non-equal words
|
||||
emit("umull r%s, r%s, r%s, r%s", acc[0], acc[1], r[0], r[i])
|
||||
for j in xrange(1, (i+1)//2):
|
||||
for j in range(1, (i+1)//2):
|
||||
mulacc(acc, r[j], r[i-j])
|
||||
# multiply by 2
|
||||
emit("adds r%s, r%s", acc[0], acc[0])
|
||||
@ -136,10 +136,10 @@ for i in xrange(3, s):
|
||||
|
||||
# store
|
||||
emit("stmia r0!, {r%s}", acc[0])
|
||||
print ""
|
||||
print("")
|
||||
|
||||
regs = list(r)
|
||||
for i in xrange(init_size):
|
||||
for i in range(init_size):
|
||||
regs = regs[1:] + regs[:1]
|
||||
emit("ldmia r1!, {r%s}", regs[5])
|
||||
|
||||
@ -151,7 +151,7 @@ for i in xrange(init_size):
|
||||
|
||||
# gather non-equal words
|
||||
emit("umull r%s, r%s, r%s, r%s", acc[0], acc[1], regs[0], regs[limit])
|
||||
for j in xrange(1, (limit+1)//2):
|
||||
for j in range(1, (limit+1)//2):
|
||||
mulacc(acc, regs[j], regs[limit-j])
|
||||
|
||||
emit("ldr r14, [r0]") # load stored value from initial block, and add to accumulator
|
||||
@ -175,9 +175,9 @@ for i in xrange(init_size):
|
||||
|
||||
# store
|
||||
emit("stmia r0!, {r%s}", acc[0])
|
||||
print ""
|
||||
print("")
|
||||
|
||||
for i in xrange(1, s-3):
|
||||
for i in range(1, s-3):
|
||||
emit("mov r%s, #0", old_acc[1])
|
||||
tmp = [acc[1], acc[2]]
|
||||
acc = [acc[0], old_acc[0], old_acc[1]]
|
||||
@ -185,7 +185,7 @@ for i in xrange(1, s-3):
|
||||
|
||||
# gather non-equal words
|
||||
emit("umull r%s, r%s, r%s, r%s", acc[0], acc[1], regs[i], regs[s - 1])
|
||||
for j in xrange(1, (s-i)//2):
|
||||
for j in range(1, (s-i)//2):
|
||||
mulacc(acc, regs[i+j], regs[s - 1 - j])
|
||||
|
||||
# multiply by 2
|
||||
@ -204,7 +204,7 @@ for i in xrange(1, s-3):
|
||||
|
||||
# store
|
||||
emit("stmia r0!, {r%s}", acc[0])
|
||||
print ""
|
||||
print("")
|
||||
|
||||
acc = acc[1:] + acc[:1]
|
||||
emit("mov r%s, #0", acc[2])
|
||||
@ -220,7 +220,7 @@ emit("adds r%s, r1", acc[0])
|
||||
emit("adcs r%s, r%s", acc[1], old_acc[1])
|
||||
emit("adc r%s, #0", acc[2])
|
||||
emit("stmia r0!, {r%s}", acc[0])
|
||||
print ""
|
||||
print("")
|
||||
|
||||
acc = acc[1:] + acc[:1]
|
||||
emit("mov r%s, #0", acc[2])
|
||||
@ -232,7 +232,7 @@ emit("adds r%s, r1", acc[0])
|
||||
emit("adcs r%s, r%s", acc[1], old_acc[1])
|
||||
emit("adc r%s, #0", acc[2])
|
||||
emit("stmia r0!, {r%s}", acc[0])
|
||||
print ""
|
||||
print("")
|
||||
|
||||
acc = acc[1:] + acc[:1]
|
||||
emit("umull r1, r%s, r%s, r%s", old_acc[1], regs[s - 1], regs[s - 1])
|
||||
|
74
3rd-party/micro-ecc/scripts/square_avr.py
vendored
74
3rd-party/micro-ecc/scripts/square_avr.py
vendored
@ -1,15 +1,15 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import sys
|
||||
|
||||
if len(sys.argv) < 2:
|
||||
print "Provide the integer size in bytes"
|
||||
print("Provide the integer size in bytes")
|
||||
sys.exit(1)
|
||||
|
||||
size = int(sys.argv[1])
|
||||
|
||||
if size > 40:
|
||||
print "This script doesn't work with integer size %s due to laziness" % (size)
|
||||
print("This script doesn't work with integer size %s due to laziness" % (size))
|
||||
sys.exit(1)
|
||||
|
||||
init_size = size - 20
|
||||
@ -27,7 +27,7 @@ def hi(i):
|
||||
|
||||
def emit(line, *args):
|
||||
s = '"' + line + r' \n\t"'
|
||||
print s % args
|
||||
print(s % args)
|
||||
|
||||
#### set up registers
|
||||
zero = "r25"
|
||||
@ -37,10 +37,10 @@ if init_size > 0:
|
||||
emit("movw r28, r26") # y = x
|
||||
h = (init_size + 1)//2
|
||||
|
||||
for i in xrange(h):
|
||||
for i in range(h):
|
||||
emit("ld r%s, x+", lo(i))
|
||||
emit("adiw r28, %s", size - init_size) # move y to other end
|
||||
for i in xrange(h):
|
||||
for i in range(h):
|
||||
emit("ld r%s, y+", hi(i))
|
||||
|
||||
emit("adiw r30, %s", size - init_size) # move z
|
||||
@ -51,72 +51,72 @@ if init_size > 0:
|
||||
emit("st z+, r1")
|
||||
else:
|
||||
#### first one
|
||||
print ""
|
||||
print("")
|
||||
emit("ldi r23, 0")
|
||||
emit("mul %s, %s", lo(0), hi(0))
|
||||
emit("st z+, r0")
|
||||
emit("mov r22, r1")
|
||||
print ""
|
||||
print("")
|
||||
|
||||
#### rest of initial block, with moving accumulator registers
|
||||
acc = [22, 23, 24]
|
||||
for r in xrange(1, h):
|
||||
for r in range(1, h):
|
||||
emit("ldi r%s, 0", acc[2])
|
||||
for i in xrange(0, (r+2)//2):
|
||||
for i in range(0, (r+2)//2):
|
||||
emit("mul r%s, r%s", lo(i), hi(r - i))
|
||||
emit("add r%s, r0", acc[0])
|
||||
emit("adc r%s, r1", acc[1])
|
||||
emit("adc r%s, %s", acc[2], zero)
|
||||
emit("st z+, r%s", acc[0])
|
||||
print ""
|
||||
print("")
|
||||
acc = acc[1:] + acc[:1]
|
||||
|
||||
lo_r = range(2, 2 + h)
|
||||
hi_r = range(12, 12 + h)
|
||||
|
||||
# now we need to start loading more from the high end
|
||||
for r in xrange(h, init_size):
|
||||
for r in range(h, init_size):
|
||||
hi_r = hi_r[1:] + hi_r[:1]
|
||||
emit("ld r%s, y+", hi_r[h-1])
|
||||
|
||||
emit("ldi r%s, 0", acc[2])
|
||||
for i in xrange(0, (r+2)//2):
|
||||
for i in range(0, (r+2)//2):
|
||||
emit("mul r%s, r%s", lo(i), hi_r[h - 1 - i])
|
||||
emit("add r%s, r0", acc[0])
|
||||
emit("adc r%s, r1", acc[1])
|
||||
emit("adc r%s, %s", acc[2], zero)
|
||||
emit("st z+, r%s", acc[0])
|
||||
print ""
|
||||
print("")
|
||||
acc = acc[1:] + acc[:1]
|
||||
|
||||
# loaded all of the high end bytes; now need to start loading the rest of the low end
|
||||
for r in xrange(1, init_size-h):
|
||||
for r in range(1, init_size-h):
|
||||
lo_r = lo_r[1:] + lo_r[:1]
|
||||
emit("ld r%s, x+", lo_r[h-1])
|
||||
|
||||
emit("ldi r%s, 0", acc[2])
|
||||
for i in xrange(0, (init_size+1 - r)//2):
|
||||
for i in range(0, (init_size+1 - r)//2):
|
||||
emit("mul r%s, r%s", lo_r[i], hi_r[h - 1 - i])
|
||||
emit("add r%s, r0", acc[0])
|
||||
emit("adc r%s, r1", acc[1])
|
||||
emit("adc r%s, %s", acc[2], zero)
|
||||
emit("st z+, r%s", acc[0])
|
||||
print ""
|
||||
print("")
|
||||
acc = acc[1:] + acc[:1]
|
||||
|
||||
lo_r = lo_r[1:] + lo_r[:1]
|
||||
emit("ld r%s, x+", lo_r[h-1])
|
||||
|
||||
# now we have loaded everything, and we just need to finish the last corner
|
||||
for r in xrange(init_size-h, init_size-1):
|
||||
for r in range(init_size-h, init_size-1):
|
||||
emit("ldi r%s, 0", acc[2])
|
||||
for i in xrange(0, (init_size+1 - r)//2):
|
||||
for i in range(0, (init_size+1 - r)//2):
|
||||
emit("mul r%s, r%s", lo_r[i], hi_r[h - 1 - i])
|
||||
emit("add r%s, r0", acc[0])
|
||||
emit("adc r%s, r1", acc[1])
|
||||
emit("adc r%s, %s", acc[2], zero)
|
||||
emit("st z+, r%s", acc[0])
|
||||
print ""
|
||||
print("")
|
||||
acc = acc[1:] + acc[:1]
|
||||
lo_r = lo_r[1:] + lo_r[:1] # make the indexing easy
|
||||
|
||||
@ -125,7 +125,7 @@ if init_size > 0:
|
||||
emit("adc r%s, r1", acc[1])
|
||||
emit("st z+, r%s", acc[0])
|
||||
emit("st z+, r%s", acc[1])
|
||||
print ""
|
||||
print("")
|
||||
emit("sbiw r26, %s", init_size) # reset x
|
||||
emit("sbiw r30, %s", size + init_size) # reset z
|
||||
|
||||
@ -133,17 +133,17 @@ if init_size > 0:
|
||||
|
||||
s = size - init_size
|
||||
|
||||
for i in xrange(s):
|
||||
for i in range(s):
|
||||
emit("ld r%s, x+", rg(i))
|
||||
|
||||
#### first few columns
|
||||
# NOTE: this is only valid if size >= 3
|
||||
print ""
|
||||
print("")
|
||||
emit("ldi r23, 0")
|
||||
emit("mul r%s, r%s", rg(0), rg(0))
|
||||
emit("st z+, r0")
|
||||
emit("mov r22, r1")
|
||||
print ""
|
||||
print("")
|
||||
emit("ldi r24, 0")
|
||||
emit("mul r%s, r%s", rg(0), rg(1))
|
||||
emit("add r22, r0")
|
||||
@ -153,7 +153,7 @@ emit("add r22, r0")
|
||||
emit("adc r23, r1")
|
||||
emit("adc r24, %s", zero)
|
||||
emit("st z+, r22")
|
||||
print ""
|
||||
print("")
|
||||
emit("ldi r22, 0")
|
||||
emit("mul r%s, r%s", rg(0), rg(2))
|
||||
emit("add r23, r0")
|
||||
@ -167,11 +167,11 @@ emit("add r23, r0")
|
||||
emit("adc r24, r1")
|
||||
emit("adc r22, %s", zero)
|
||||
emit("st z+, r23")
|
||||
print ""
|
||||
print("")
|
||||
|
||||
acc = [23, 24, 22]
|
||||
old_acc = [28, 29]
|
||||
for i in xrange(3, s):
|
||||
for i in range(3, s):
|
||||
emit("ldi r%s, 0", old_acc[1])
|
||||
tmp = [acc[1], acc[2]]
|
||||
acc = [acc[0], old_acc[0], old_acc[1]]
|
||||
@ -181,7 +181,7 @@ for i in xrange(3, s):
|
||||
emit("mul r%s, r%s", rg(0), rg(i))
|
||||
emit("mov r%s, r0", acc[0])
|
||||
emit("mov r%s, r1", acc[1])
|
||||
for j in xrange(1, (i+1)//2):
|
||||
for j in range(1, (i+1)//2):
|
||||
emit("mul r%s, r%s", rg(j), rg(i-j))
|
||||
emit("add r%s, r0", acc[0])
|
||||
emit("adc r%s, r1", acc[1])
|
||||
@ -205,10 +205,10 @@ for i in xrange(3, s):
|
||||
|
||||
# store
|
||||
emit("st z+, r%s", acc[0])
|
||||
print ""
|
||||
print("")
|
||||
|
||||
regs = range(2, 22)
|
||||
for i in xrange(init_size):
|
||||
for i in range(init_size):
|
||||
regs = regs[1:] + regs[:1]
|
||||
emit("ld r%s, x+", regs[19])
|
||||
|
||||
@ -222,7 +222,7 @@ for i in xrange(init_size):
|
||||
emit("mul r%s, r%s", regs[0], regs[limit])
|
||||
emit("mov r%s, r0", acc[0])
|
||||
emit("mov r%s, r1", acc[1])
|
||||
for j in xrange(1, (limit+1)//2):
|
||||
for j in range(1, (limit+1)//2):
|
||||
emit("mul r%s, r%s", regs[j], regs[limit-j])
|
||||
emit("add r%s, r0", acc[0])
|
||||
emit("adc r%s, r1", acc[1])
|
||||
@ -252,9 +252,9 @@ for i in xrange(init_size):
|
||||
|
||||
# store
|
||||
emit("st z+, r%s", acc[0])
|
||||
print ""
|
||||
print("")
|
||||
|
||||
for i in xrange(1, s-3):
|
||||
for i in range(1, s-3):
|
||||
emit("ldi r%s, 0", old_acc[1])
|
||||
tmp = [acc[1], acc[2]]
|
||||
acc = [acc[0], old_acc[0], old_acc[1]]
|
||||
@ -264,7 +264,7 @@ for i in xrange(1, s-3):
|
||||
emit("mul r%s, r%s", regs[i], regs[s - 1])
|
||||
emit("mov r%s, r0", acc[0])
|
||||
emit("mov r%s, r1", acc[1])
|
||||
for j in xrange(1, (s-i)//2):
|
||||
for j in range(1, (s-i)//2):
|
||||
emit("mul r%s, r%s", regs[i+j], regs[s - 1 - j])
|
||||
emit("add r%s, r0", acc[0])
|
||||
emit("adc r%s, r1", acc[1])
|
||||
@ -288,7 +288,7 @@ for i in xrange(1, s-3):
|
||||
|
||||
# store
|
||||
emit("st z+, r%s", acc[0])
|
||||
print ""
|
||||
print("")
|
||||
|
||||
acc = acc[1:] + acc[:1]
|
||||
emit("ldi r%s, 0", acc[2])
|
||||
@ -304,7 +304,7 @@ emit("add r%s, r0", acc[0])
|
||||
emit("adc r%s, r1", acc[1])
|
||||
emit("adc r%s, %s", acc[2], zero)
|
||||
emit("st z+, r%s", acc[0])
|
||||
print ""
|
||||
print("")
|
||||
|
||||
acc = acc[1:] + acc[:1]
|
||||
emit("ldi r%s, 0", acc[2])
|
||||
@ -316,7 +316,7 @@ emit("add r%s, r0", acc[0])
|
||||
emit("adc r%s, r1", acc[1])
|
||||
emit("adc r%s, %s", acc[2], zero)
|
||||
emit("st z+, r%s", acc[0])
|
||||
print ""
|
||||
print("")
|
||||
|
||||
emit("mul r%s, r%s", regs[19], regs[19])
|
||||
emit("add r%s, r0", acc[1])
|
||||
|
@ -1,3 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import socket
|
||||
import struct
|
||||
import btstack.command_builder
|
||||
|
@ -1,3 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
from threading import Thread
|
||||
from ctypes import *
|
||||
|
||||
|
2
platform/daemon/binding/python/btstack/btstack_types.py
Normal file → Executable file
2
platform/daemon/binding/python/btstack/btstack_types.py
Normal file → Executable file
@ -1,3 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import struct
|
||||
|
||||
BLUETOOTH_BASE_UUID = bytes ([ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB ]);
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
#
|
||||
# Create project files for all BTstack embedded examples in AmbiqSuite/boards/apollo2_evb_am_ble
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
import getopt
|
||||
import re
|
||||
import sys
|
||||
@ -256,11 +256,11 @@ def writeListings(aout, infile_name, ref_prefix):
|
||||
parts = re.match('.*(EXAMPLE_END).*',line)
|
||||
if parts:
|
||||
if state != State.SearchListingStart:
|
||||
print "Formating error detected"
|
||||
print("Formating error detected")
|
||||
writeItemizeBlock(aout, 0)
|
||||
writeTextBlock(aout, 0)
|
||||
state = State.ReachedExampleEnd
|
||||
print "Reached end of the example"
|
||||
print("Reached end of the example")
|
||||
|
||||
|
||||
# write list of examples
|
||||
@ -319,18 +319,18 @@ def main(argv):
|
||||
try:
|
||||
opts, args = getopt.getopt(argv,"hiso:",["ifolder=","ofile="])
|
||||
except getopt.GetoptError:
|
||||
print 'update_listings.py [-i <inputfolder>] [-o <outputfile>]'
|
||||
print('update_listings.py [-i <inputfolder>] [-o <outputfile>]')
|
||||
sys.exit(2)
|
||||
for opt, arg in opts:
|
||||
if opt == '-h':
|
||||
print 'update_listings.py [-i <inputfolder>] [-s] [-o <outputfile>]'
|
||||
print('update_listings.py [-i <inputfolder>] [-s] [-o <outputfile>]')
|
||||
sys.exit()
|
||||
elif opt in ("-i", "--ifolder"):
|
||||
inputfolder = arg
|
||||
elif opt in ("-o", "--ofile"):
|
||||
outputfile = arg
|
||||
print 'Input folder is ', inputfolder
|
||||
print 'Output file is ', outputfile
|
||||
print('Input folder is ', inputfolder)
|
||||
print('Output file is ', outputfile)
|
||||
processExamples(intro_file, inputfolder, outputfile)
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
#
|
||||
# Create project files for all BTstack embedded examples in local port/esp32 folder
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
#
|
||||
# Delete project files for all BTstack embedded examples in local port/esp32 folder
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
|
||||
#
|
||||
# Add btstack component to esp-idf
|
||||
|
@ -43,8 +43,8 @@ csr_set_bd_addr: ${CORE_OBJ} ${COMMON_OBJ} btstack_chipset_csr.o csr_set_bd_addr
|
||||
|
||||
|
||||
# use pkg-config for portaudio
|
||||
# CFLAGS += $(shell pkg-config portaudio-2.0 --cflags) -DHAVE_PORTAUDIO
|
||||
# LDFLAGS += $(shell pkg-config portaudio-2.0 --libs)
|
||||
CFLAGS += $(shell pkg-config portaudio-2.0 --cflags) -DHAVE_PORTAUDIO
|
||||
LDFLAGS += $(shell pkg-config portaudio-2.0 --libs)
|
||||
|
||||
# hard coded flags for portaudio in /usr/local/lib
|
||||
# CFLAGS += -I/usr/local/include -DHAVE_PORTAUDIO
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
#
|
||||
# Create project files for all BTstack embedded examples in WICED/apps/btstack
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
#
|
||||
# Delete project files for all BTstack embedded examples in local port/esp32 folder
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import matplotlib.pyplot as plt
|
||||
#from pylab import *
|
||||
import cPickle
|
||||
import pickle
|
||||
import pylab as P
|
||||
import numpy as np
|
||||
from matplotlib.backends.backend_pdf import PdfPages
|
||||
@ -125,29 +125,29 @@ def prepare_data(exp_name, sensor_name):
|
||||
prefix = '../data/processed/'
|
||||
|
||||
scanning_type = exp_name+'_continuous'
|
||||
mn = cPickle.load(open(prefix+scanning_type+'_mac_'+sensor_name+'.data', 'rb')) # mac nio,
|
||||
mm = cPickle.load(open(prefix+scanning_type+'_mac_mac.data', 'rb')) # mac mac,
|
||||
rn = cPickle.load(open(prefix+scanning_type+'_rug_'+sensor_name+'.data', 'rb')) # ruggear nio,
|
||||
rm = cPickle.load(open(prefix+scanning_type+'_rug_mac.data', 'rb')) # ruggear mac,
|
||||
mn = pickle.load(open(prefix+scanning_type+'_mac_'+sensor_name+'.data', 'rb')) # mac nio,
|
||||
mm = pickle.load(open(prefix+scanning_type+'_mac_mac.data', 'rb')) # mac mac,
|
||||
rn = pickle.load(open(prefix+scanning_type+'_rug_'+sensor_name+'.data', 'rb')) # ruggear nio,
|
||||
rm = pickle.load(open(prefix+scanning_type+'_rug_mac.data', 'rb')) # ruggear mac,
|
||||
|
||||
scanning_type = exp_name+'_normal'
|
||||
try:
|
||||
normal_rn = cPickle.load(open(prefix + scanning_type+'_rug_'+sensor_name+'.data', 'rb')) # ruggear mac, normal
|
||||
normal_rn = pickle.load(open(prefix + scanning_type+'_rug_'+sensor_name+'.data', 'rb')) # ruggear mac, normal
|
||||
except:
|
||||
normal_rn = list()
|
||||
|
||||
try:
|
||||
normal_mn = cPickle.load(open(prefix + scanning_type+'_mac_'+sensor_name+'.data', 'rb')) # ruggear mac, normal
|
||||
normal_mn = pickle.load(open(prefix + scanning_type+'_mac_'+sensor_name+'.data', 'rb')) # ruggear mac, normal
|
||||
except:
|
||||
normal_mn = list()
|
||||
|
||||
try:
|
||||
normal_rm = cPickle.load(open(prefix + scanning_type+'_rug_mac.data', 'rb')) # ruggear mac, normal
|
||||
normal_rm = pickle.load(open(prefix + scanning_type+'_rug_mac.data', 'rb')) # ruggear mac, normal
|
||||
except:
|
||||
normal_rm = list()
|
||||
|
||||
try:
|
||||
normal_mm = cPickle.load(open(prefix + scanning_type+'_mac_mac.data', 'rb')) # ruggear mac, normal
|
||||
normal_mm = pickle.load(open(prefix + scanning_type+'_mac_mac.data', 'rb')) # ruggear mac, normal
|
||||
except:
|
||||
normal_mm = list()
|
||||
|
||||
@ -156,7 +156,7 @@ def prepare_data(exp_name, sensor_name):
|
||||
L = mean_common_len([mm, mn, rm, rn, normal_rm, normal_rn, normal_mm, normal_mn])
|
||||
Z = 15
|
||||
|
||||
print "mct %d, mcl %d" % (T,L)
|
||||
print("mct %d, mcl %d" % (T,L))
|
||||
mac_mac = normalize(mm)
|
||||
mac_nio = normalize(mn)
|
||||
ruggeer_mac = normalize(rm)
|
||||
|
22
port/mtk/docs/scripts/plot_scan_two_groups.py
Normal file → Executable file
22
port/mtk/docs/scripts/plot_scan_two_groups.py
Normal file → Executable file
@ -1,8 +1,8 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import matplotlib.pyplot as plt
|
||||
#from pylab import *
|
||||
import cPickle
|
||||
import pickle
|
||||
import pylab as P
|
||||
import numpy as np
|
||||
from matplotlib.backends.backend_pdf import PdfPages
|
||||
@ -124,29 +124,29 @@ def prepare_data(exp_name, sensor_name):
|
||||
prefix = '../data/processed/'
|
||||
|
||||
scanning_type = exp_name+'_continuous'
|
||||
mn = cPickle.load(open(prefix+scanning_type+'_mac_'+sensor_name+'.data', 'rb')) # mac nio,
|
||||
mm = cPickle.load(open(prefix+scanning_type+'_mac_mac.data', 'rb')) # mac mac,
|
||||
rn = cPickle.load(open(prefix+scanning_type+'_rug_'+sensor_name+'.data', 'rb')) # ruggear nio,
|
||||
rm = cPickle.load(open(prefix+scanning_type+'_rug_mac.data', 'rb')) # ruggear mac,
|
||||
mn = pickle.load(open(prefix+scanning_type+'_mac_'+sensor_name+'.data', 'rb')) # mac nio,
|
||||
mm = pickle.load(open(prefix+scanning_type+'_mac_mac.data', 'rb')) # mac mac,
|
||||
rn = pickle.load(open(prefix+scanning_type+'_rug_'+sensor_name+'.data', 'rb')) # ruggear nio,
|
||||
rm = pickle.load(open(prefix+scanning_type+'_rug_mac.data', 'rb')) # ruggear mac,
|
||||
|
||||
scanning_type = exp_name+'_normal'
|
||||
try:
|
||||
normal_rn = cPickle.load(open(prefix + scanning_type+'_rug_'+sensor_name+'.data', 'rb')) # ruggear mac, normal
|
||||
normal_rn = pickle.load(open(prefix + scanning_type+'_rug_'+sensor_name+'.data', 'rb')) # ruggear mac, normal
|
||||
except:
|
||||
normal_rn = list()
|
||||
|
||||
try:
|
||||
normal_mn = cPickle.load(open(prefix + scanning_type+'_mac_'+sensor_name+'.data', 'rb')) # ruggear mac, normal
|
||||
normal_mn = pickle.load(open(prefix + scanning_type+'_mac_'+sensor_name+'.data', 'rb')) # ruggear mac, normal
|
||||
except:
|
||||
normal_mn = list()
|
||||
|
||||
try:
|
||||
normal_rm = cPickle.load(open(prefix + scanning_type+'_rug_mac.data', 'rb')) # ruggear mac, normal
|
||||
normal_rm = pickle.load(open(prefix + scanning_type+'_rug_mac.data', 'rb')) # ruggear mac, normal
|
||||
except:
|
||||
normal_rm = list()
|
||||
|
||||
try:
|
||||
normal_mm = cPickle.load(open(prefix + scanning_type+'_mac_mac.data', 'rb')) # ruggear mac, normal
|
||||
normal_mm = pickle.load(open(prefix + scanning_type+'_mac_mac.data', 'rb')) # ruggear mac, normal
|
||||
except:
|
||||
normal_mm = list()
|
||||
|
||||
@ -155,7 +155,7 @@ def prepare_data(exp_name, sensor_name):
|
||||
L = mean_common_len([mm, mn, rm, rn, normal_rm, normal_rn, normal_mm, normal_mn])
|
||||
Z = 15
|
||||
|
||||
print "mct %d, mcl %d" % (T,L)
|
||||
print("mct %d, mcl %d" % (T,L))
|
||||
mac_mac = normalize(mm)
|
||||
mac_nio = normalize(mn)
|
||||
ruggeer_mac = normalize(rm)
|
||||
|
@ -1,9 +1,9 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import struct
|
||||
import math
|
||||
import sys, os
|
||||
import cPickle
|
||||
import pickle
|
||||
|
||||
devices = dict()
|
||||
delays = dict()
|
||||
@ -36,17 +36,17 @@ def reset_timestamp(packet_type, packet, time_sec):
|
||||
if (int(packet[3])):
|
||||
scan_start_timestamp = time_sec
|
||||
scan_nr = scan_nr + 1
|
||||
print "Scanning started at %u"%scan_start_timestamp
|
||||
print("Scanning started at %u"%scan_start_timestamp)
|
||||
|
||||
else:
|
||||
print "Scanning stopped"
|
||||
print("Scanning stopped")
|
||||
|
||||
def read_scan(packet_type, packet, time_sec):
|
||||
if packet_type != 0x01 or packet[0] != 0x3E or packet[2] != 0x02:
|
||||
return
|
||||
|
||||
if packet[3] != 1:
|
||||
print "More then one report"
|
||||
print("More then one report")
|
||||
return
|
||||
|
||||
(event_type, addr_type, addr, data_len) = struct.unpack('<BB6sB', packet[4:13])
|
||||
@ -66,7 +66,7 @@ def read_scan(packet_type, packet, time_sec):
|
||||
|
||||
normalized_timestamp = time_sec - scan_start_timestamp
|
||||
if not bt_addr_str in devices.keys():
|
||||
print "new device at %u %u" % (time_sec, scan_start_timestamp)
|
||||
print("new device at %u %u" % (time_sec, scan_start_timestamp))
|
||||
devices[bt_addr_str] = list()
|
||||
delays[bt_addr_str] = list()
|
||||
|
||||
@ -78,7 +78,7 @@ def read_scan(packet_type, packet, time_sec):
|
||||
return
|
||||
|
||||
def process_pklg(exp_name, sensor_name, scanning_type, pklg_file_name):
|
||||
print "Opening %s" % pklg_file_name
|
||||
print("Opening %s" % pklg_file_name)
|
||||
with open(pklg_file_name, "rb") as f:
|
||||
while True:
|
||||
try:
|
||||
@ -108,13 +108,13 @@ def process_pklg(exp_name, sensor_name, scanning_type, pklg_file_name):
|
||||
if not data_file_name:
|
||||
continue
|
||||
|
||||
cPickle.dump(devices[k], open(data_file_name, 'wb'))
|
||||
pickle.dump(devices[k], open(data_file_name, 'wb'))
|
||||
mes_index = 0
|
||||
# take the last measurement
|
||||
for i in range(len(devices[k])-1):
|
||||
if devices[k][i] > devices[k][i+1]:
|
||||
mes_index = i+1
|
||||
cPickle.dump(devices[k][mes_index:len(devices[k])], open(data_file_name, 'wb'))
|
||||
pickle.dump(devices[k][mes_index:len(devices[k])], open(data_file_name, 'wb'))
|
||||
|
||||
def init():
|
||||
global devices, delays, scan_start_timestamp, scan_nr
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
#
|
||||
# Create project files for all BTstack embedded examples in zephyr/samples/btstack
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
#
|
||||
# Create project files for all BTstack embedded examples in nRF5_X/examples/btstack
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
#
|
||||
# Create project files for all BTstack embedded examples in harmony/apps/btstack
|
||||
|
||||
@ -21,7 +21,7 @@ script_path = os.path.abspath(os.path.dirname(sys.argv[0]))
|
||||
|
||||
# validate Harmony root by reading version.txt
|
||||
harmony_root = script_path + "/../../../../"
|
||||
print harmony_root
|
||||
print(harmony_root)
|
||||
harmony_version = ""
|
||||
try:
|
||||
with open(harmony_root + 'config/harmony.hconfig', 'r') as fin:
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
#
|
||||
# Create project files for all BTstack embedded examples in WICED/apps/btstack
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
#
|
||||
# Delete project files for all BTstack embedded examples in local port/esp32 folder
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
#
|
||||
# Create project files for all BTstack embedded examples in WICED/apps/btstack
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
#
|
||||
# Create project files for all BTstack embedded examples in WICED/apps/btstack
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
#
|
||||
# Filter coverage reported by lcov/genhtml
|
||||
#
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# BlueKitchen GmbH (c) 2014
|
||||
|
||||
# primitive dump for PacketLogger format
|
||||
@ -32,17 +32,17 @@ def as_hex(data):
|
||||
return ''.join(str_list)
|
||||
|
||||
if len(sys.argv) < 2:
|
||||
print 'Dump PacketLogger file'
|
||||
print 'Copyright 2014, BlueKitchen GmbH'
|
||||
print ''
|
||||
print 'Usage: ', sys.argv[0], 'hci_dump.pklg test_name'
|
||||
print ('Dump PacketLogger file')
|
||||
print ('Copyright 2014, BlueKitchen GmbH')
|
||||
print ('')
|
||||
print ('Usage: ', sys.argv[0], 'hci_dump.pklg test_name')
|
||||
exit(0)
|
||||
|
||||
infile = sys.argv[1]
|
||||
test_name = sys.argv[2]
|
||||
separator = ""
|
||||
spaces = " "
|
||||
print "const char * "+test_name+"[] = {"
|
||||
print ("const char * "+test_name+"[] = {")
|
||||
|
||||
|
||||
with open (infile, 'rb') as fin:
|
||||
@ -69,21 +69,21 @@ with open (infile, 'rb') as fin:
|
||||
hfp_cmds = parts.groups()[0].split('\\r\\n')
|
||||
for cmd in hfp_cmds:
|
||||
cmd = cmd.strip()
|
||||
if cmd <> "":
|
||||
if cmd != "":
|
||||
cmd = cmd.replace("\\r","")
|
||||
print separator+spaces+"\""+cmd+"\"",
|
||||
print (separator+spaces+"\""+cmd+"\"",)
|
||||
separator = ",\n"
|
||||
|
||||
else:
|
||||
parts = re.match('USER:\'(.*)\'.*',packet)
|
||||
if parts:
|
||||
cmd = 'USER:'+parts.groups()[0]
|
||||
print separator+spaces+"\""+cmd+"\"",
|
||||
print (separator+spaces+"\""+cmd+"\"",)
|
||||
separator = ",\n"
|
||||
|
||||
|
||||
except TypeError:
|
||||
print "\n};\n"
|
||||
print ("\n};\n")
|
||||
exit(0)
|
||||
|
||||
print "\n};\n"
|
||||
print ("\n};\n")
|
||||
|
@ -602,7 +602,7 @@ if len(sys.argv) == 1:
|
||||
print ('Dump Mesh PacketLogger file')
|
||||
print ('Copyright 2019, BlueKitchen GmbH')
|
||||
print ('')
|
||||
print ('Usage: ' + sys.argv[0] + 'hci_dump.pklg')
|
||||
print ('Usage: ' + sys.argv[0] + ' hci_dump.pklg')
|
||||
exit(0)
|
||||
|
||||
infile = sys.argv[1]
|
||||
|
@ -5,8 +5,17 @@
|
||||
|
||||
# implementation of the Bluetooth SIG Mesh crypto functions using pycryptodomex
|
||||
|
||||
from Cryptodome.Cipher import AES
|
||||
from Cryptodome.Hash import CMAC
|
||||
try:
|
||||
from Cryptodome.Cipher import AES
|
||||
from Cryptodome.Hash import CMAC
|
||||
except ImportError:
|
||||
# fallback: try to import PyCryptodome as (an almost drop-in) replacement for the PyCrypto library
|
||||
try:
|
||||
from Crypto.Cipher import AES
|
||||
from Crypto.Hash import CMAC
|
||||
except ImportError:
|
||||
print("\n[!] PyCryptodome required but not installed (using random value instead)")
|
||||
print("[!] Please install PyCryptodome, e.g. 'pip3 install pycryptodomex' or 'pip3 install pycryptodome'\n")
|
||||
|
||||
def aes128(key, n):
|
||||
cipher = AES.new(key, AES.MODE_ECB)
|
||||
|
@ -5,6 +5,18 @@
|
||||
|
||||
from mesh_crypto import *
|
||||
|
||||
try:
|
||||
from Cryptodome.Cipher import AES
|
||||
from Cryptodome.Hash import CMAC
|
||||
except ImportError:
|
||||
# fallback: try to import PyCryptodome as (an almost drop-in) replacement for the PyCrypto library
|
||||
try:
|
||||
from Crypto.Cipher import AES
|
||||
from Crypto.Hash import CMAC
|
||||
except ImportError:
|
||||
print("\n[!] PyCryptodome required but not installed (using random value instead)")
|
||||
print("[!] Please install PyCryptodome, e.g. 'pip3 install pycryptodomex' or 'pip3 install pycryptodome'\n")
|
||||
|
||||
# S1('test') = b73cefbd641ef2ea598c2b6efb62f79c
|
||||
s1_input = b'test'
|
||||
s1_actual = s1(s1_input)
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
#
|
||||
# Simulate network of Bluetooth Controllers
|
||||
#
|
||||
@ -17,8 +17,19 @@ import sys
|
||||
import bisect
|
||||
import time
|
||||
|
||||
from Crypto.Cipher import AES
|
||||
from Crypto import Random
|
||||
# fallback: try to import PyCryptodome as (an almost drop-in) replacement for the PyCrypto library
|
||||
try:
|
||||
from Cryptodome.Cipher import AES
|
||||
import Cryptodome.Random as Random
|
||||
except ImportError:
|
||||
# fallback: try to import PyCryptodome as (an almost drop-in) replacement for the PyCrypto library
|
||||
try:
|
||||
from Crypto.Cipher import AES
|
||||
import Crypto.Random as Random
|
||||
except ImportError:
|
||||
print("\n[!] PyCryptodome required but not installed (using random value instead)")
|
||||
print("[!] Please install PyCryptodome, e.g. 'pip3 install pycryptodomex' or 'pip3 install pycryptodome'\n")
|
||||
|
||||
|
||||
def little_endian_read_16(buffer, pos):
|
||||
return ord(buffer[pos]) + (ord(buffer[pos+1]) << 8)
|
||||
|
18
test/sbc/sbc.py
Normal file → Executable file
18
test/sbc/sbc.py
Normal file → Executable file
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
import numpy as np
|
||||
import wave
|
||||
import struct
|
||||
@ -244,10 +244,10 @@ class SBCFrame:
|
||||
self.EX = np.zeros(nr_subbands)
|
||||
|
||||
def dump_audio_samples(self, blk, ch):
|
||||
print self.audio_sample[blk][ch]
|
||||
print(self.audio_sample[blk][ch])
|
||||
|
||||
def dump_subband_samples(self, blk, ch):
|
||||
print self.sb_sample[blk][ch]
|
||||
print(self.sb_sample[blk][ch])
|
||||
|
||||
def dump_state(self):
|
||||
res = "SBCFrameHeader state:"
|
||||
@ -258,7 +258,7 @@ class SBCFrame:
|
||||
res += "\n - levels: %s" % self.levels
|
||||
res += "\n - join: %s" % self.join
|
||||
res += "\n - bits: %s" % self.bits
|
||||
print res
|
||||
print(res)
|
||||
|
||||
def __str__(self):
|
||||
res = "SBCFrameHeader:"
|
||||
@ -371,13 +371,13 @@ def sbc_bit_allocation_stereo_joint(frame):
|
||||
|
||||
|
||||
if bits.sum() != frame.bitpool:
|
||||
print "bit allocation failed, bitpool %d, allocated %d" % (bits.sum() , frame.bitpool)
|
||||
print("bit allocation failed, bitpool %d, allocated %d" % (bits.sum() , frame.bitpool))
|
||||
exit(1)
|
||||
return bits
|
||||
|
||||
|
||||
def sbc_bit_allocation_mono_dual(frame):
|
||||
#print "Bit allocation for mono/dual channel"
|
||||
#print("Bit allocation for mono/dual channel" )
|
||||
bitneed = np.zeros(shape=(frame.nr_channels, frame.nr_subbands), dtype = np.int32)
|
||||
bits = np.zeros(shape=(frame.nr_channels, frame.nr_subbands), dtype = np.int32)
|
||||
loudness = 0
|
||||
@ -461,7 +461,7 @@ def sbc_bit_allocation(frame):
|
||||
elif frame.channel_mode == STEREO or frame.channel_mode == JOINT_STEREO:
|
||||
return sbc_bit_allocation_stereo_joint(frame)
|
||||
else:
|
||||
print "Wrong channel mode ", frame.channel_mode
|
||||
print("Wrong channel mode ", frame.channel_mode)
|
||||
return -1
|
||||
|
||||
def sbc_sampling_frequency_index(sample_rate):
|
||||
@ -534,14 +534,14 @@ def get_bit(fin):
|
||||
|
||||
def drop_remaining_bits():
|
||||
global ibuffer_count
|
||||
#print "dropping %d bits" % ibuffer_count
|
||||
#print("dropping %d bits" % ibuffer_count)
|
||||
ibuffer_count = 0
|
||||
|
||||
def get_bits(fin, bit_count):
|
||||
bits = 0
|
||||
for i in range(bit_count):
|
||||
bits = (bits << 1) | get_bit(fin)
|
||||
# print "get bits: %d -> %02x" %(bit_count, bits)
|
||||
# print("get bits: %d -> %02x" %(bit_count, bits))
|
||||
return bits
|
||||
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
import numpy as np
|
||||
import wave
|
||||
import struct
|
||||
@ -34,7 +34,7 @@ def find_syncword(h2_first_byte, h2_second_byte):
|
||||
def sbc_unpack_frame(fin, available_bytes, frame):
|
||||
global H2_first_byte, H2_second_byte
|
||||
if available_bytes == 0:
|
||||
print "no available_bytes"
|
||||
print ("no available_bytes")
|
||||
raise TypeError
|
||||
|
||||
frame.syncword = get_bits(fin,8)
|
||||
@ -88,13 +88,13 @@ def sbc_unpack_frame(fin, available_bytes, frame):
|
||||
frame.scale_factor[ch][sb] = get_bits(fin, 4)
|
||||
|
||||
if mSBC_enabled:
|
||||
#print "syncword: ", find_syncword(H2_first_byte, H2_second_byte)
|
||||
#print ("syncword: ", find_syncword(H2_first_byte, H2_second_byte))
|
||||
crc = calculate_crc_mSBC(frame)
|
||||
else:
|
||||
crc = calculate_crc(frame)
|
||||
|
||||
if crc != frame.crc_check:
|
||||
print "CRC mismatch: calculated %d, expected %d" % (crc, frame.crc_check)
|
||||
print ("CRC mismatch: calculated %d, expected %d" % (crc, frame.crc_check))
|
||||
return -1
|
||||
|
||||
|
||||
@ -111,7 +111,7 @@ def sbc_unpack_frame(fin, available_bytes, frame):
|
||||
for ch in range(frame.nr_channels):
|
||||
for sb in range(frame.nr_subbands):
|
||||
frame.audio_sample[blk][ch][sb] = get_bits(fin, frame.bits[ch][sb])
|
||||
#print "block %2d - audio sample: %s" % (blk, frame.audio_sample[blk][0])
|
||||
#print ("block %2d - audio sample: %s" % (blk, frame.audio_sample[blk][0]))
|
||||
|
||||
drop_remaining_bits()
|
||||
return 0
|
||||
@ -290,8 +290,8 @@ def write_wav_file(fout, frame):
|
||||
packed_value = struct.pack('h', frame.pcm[ch][i])
|
||||
values.append(packed_value)
|
||||
except struct.error:
|
||||
print frame
|
||||
print i, frame.pcm[ch][i], frame.pcm[ch]
|
||||
print (frame)
|
||||
print (i, frame.pcm[ch][i], frame.pcm[ch])
|
||||
exit(1)
|
||||
|
||||
value_str = ''.join(values)
|
||||
@ -320,9 +320,9 @@ if __name__ == "__main__":
|
||||
else:
|
||||
wavfile = infile.replace('.sbc', '-decoded-py.wav')
|
||||
|
||||
print "input file: ", infile
|
||||
print "output file: ", wavfile
|
||||
print "mSBC enabled: ", mSBC_enabled
|
||||
print ("input file: ", infile)
|
||||
print ("output file: ", wavfile)
|
||||
print ("mSBC enabled: ", mSBC_enabled)
|
||||
|
||||
fout = False
|
||||
|
||||
@ -345,16 +345,16 @@ if __name__ == "__main__":
|
||||
while True:
|
||||
frame = SBCFrame()
|
||||
if frame_count % 200 == 0:
|
||||
print "== Frame %d == offset %d" % (frame_count, fin.tell())
|
||||
print ("== Frame %d == offset %d" % (frame_count, fin.tell()))
|
||||
|
||||
err = sbc_unpack_frame(fin, file_size - fin.tell(), frame)
|
||||
if err:
|
||||
#print "error, frame_count: ", frame_count
|
||||
#print ("error, frame_count: ", frame_count)
|
||||
continue
|
||||
|
||||
if frame_count == 0:
|
||||
sbc_init_sythesis(frame.nr_subbands, implementation)
|
||||
print frame
|
||||
print (frame )
|
||||
|
||||
sbc_decode(frame, implementation)
|
||||
|
||||
@ -366,7 +366,7 @@ if __name__ == "__main__":
|
||||
fout.setnframes(0)
|
||||
fout.setcomptype = 'NONE'
|
||||
|
||||
print frame.pcm
|
||||
print (frame.pcm)
|
||||
|
||||
|
||||
write_wav_file(fout, frame)
|
||||
@ -377,7 +377,7 @@ if __name__ == "__main__":
|
||||
|
||||
except TypeError as err:
|
||||
if not fout:
|
||||
print err
|
||||
print (err)
|
||||
else:
|
||||
fout.close()
|
||||
if frame_count > 0:
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
import numpy as np
|
||||
import wave
|
||||
import struct
|
||||
@ -18,38 +18,38 @@ def sbc_compare_pcm(frame_count, actual_frame, expected_frame):
|
||||
max_error = M
|
||||
|
||||
if max_error > error:
|
||||
print "pcm error (%d, %f ) " % (frame_count, max_error)
|
||||
print("pcm error (%d, %f ) " % (frame_count, max_error))
|
||||
return -1
|
||||
return 0
|
||||
|
||||
|
||||
def sbc_compare_headers(frame_count, actual_frame, expected_frame):
|
||||
if actual_frame.sampling_frequency != expected_frame.sampling_frequency:
|
||||
print "sampling_frequency wrong ", actual_frame.sampling_frequency
|
||||
print("sampling_frequency wrong ", actual_frame.sampling_frequency)
|
||||
return -1
|
||||
|
||||
if actual_frame.nr_blocks != expected_frame.nr_blocks:
|
||||
print "nr_blocks wrong ", actual_frame.nr_blocks
|
||||
print("nr_blocks wrong ", actual_frame.nr_blocks)
|
||||
return -1
|
||||
|
||||
if actual_frame.channel_mode != expected_frame.channel_mode:
|
||||
print "channel_mode wrong ", actual_frame.channel_mode
|
||||
print("channel_mode wrong ", actual_frame.channel_mode)
|
||||
return -1
|
||||
|
||||
if actual_frame.nr_channels != expected_frame.nr_channels:
|
||||
print "nr_channels wrong ", actual_frame.nr_channels
|
||||
print("nr_channels wrong ", actual_frame.nr_channels)
|
||||
return -1
|
||||
|
||||
if actual_frame.allocation_method != expected_frame.allocation_method:
|
||||
print "allocation_method wrong ", actual_frame.allocation_method
|
||||
print("allocation_method wrong ", actual_frame.allocation_method)
|
||||
return -1
|
||||
|
||||
if actual_frame.nr_subbands != expected_frame.nr_subbands:
|
||||
print "nr_subbands wrong ", actual_frame.nr_subbands
|
||||
print("nr_subbands wrong ", actual_frame.nr_subbands)
|
||||
return -1
|
||||
|
||||
if actual_frame.bitpool != expected_frame.bitpool:
|
||||
print "bitpool wrong (E: %d, D: %d)" % (actual_frame.bitpool, expected_frame.bitpool)
|
||||
print("bitpool wrong (E: %d, D: %d)" % (actual_frame.bitpool, expected_frame.bitpool))
|
||||
return -1
|
||||
|
||||
return 0
|
||||
@ -62,7 +62,7 @@ def get_actual_frame(fin, implementation, frame_count):
|
||||
sbc_reconstruct_subband_samples(actual_frame)
|
||||
if subband_frame_count == 0:
|
||||
sbc_init_sythesis(actual_frame.nr_subbands, implementation)
|
||||
print actual_frame
|
||||
print(actual_frame)
|
||||
sbc_synthesis(actual_frame, implementation)
|
||||
return actual_frame
|
||||
|
||||
@ -108,7 +108,7 @@ try:
|
||||
|
||||
while True:
|
||||
if subband_frame_count % 200 == 0:
|
||||
print ("== Frame %d ==" % subband_frame_count)
|
||||
print("== Frame %d ==" % subband_frame_count)
|
||||
|
||||
|
||||
actual_frame = get_actual_frame(fin, implementation, subband_frame_count)
|
||||
@ -121,12 +121,12 @@ try:
|
||||
err = sbc_compare_headers(subband_frame_count, actual_frame, expected_frame)
|
||||
|
||||
if err < 0:
|
||||
print ("Frame %d: Headers differ \n%s\n%s" % (subband_frame_count, actual_frame, expected_frame))
|
||||
print("Frame %d: Headers differ \n%s\n%s" % (subband_frame_count, actual_frame, expected_frame))
|
||||
sys.exit(1)
|
||||
|
||||
err = sbc_compare_pcm(subband_frame_count, actual_frame, expected_frame)
|
||||
if err < 0:
|
||||
print ("Frame %d: PCMs differ %f \n%s\n%s" % (subband_frame_count, max_error, actual_frame.pcm, expected_frame.pcm))
|
||||
print("Frame %d: PCMs differ %f \n%s\n%s" % (subband_frame_count, max_error, actual_frame.pcm, expected_frame.pcm))
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
@ -135,7 +135,7 @@ try:
|
||||
except TypeError:
|
||||
fin_expected.close()
|
||||
fin.close()
|
||||
print ("DONE, max MSE PCM error %f" % max_error)
|
||||
print("DONE, max MSE PCM error %f" % max_error)
|
||||
|
||||
except IOError as e:
|
||||
print(usage)
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
import numpy as np
|
||||
import wave
|
||||
import struct
|
||||
@ -190,7 +190,7 @@ if __name__ == "__main__":
|
||||
sbc_encoder_frame = SBCFrame(nr_blocks, nr_subbands, nr_channels, bitpool, sampling_frequency, allocation_method, force_channel_mode)
|
||||
|
||||
if subband_frame_count == 0:
|
||||
print sbc_encoder_frame
|
||||
print (sbc_encoder_frame)
|
||||
fetch_samples_for_next_sbc_frame(fin, sbc_encoder_frame)
|
||||
|
||||
sbc_encode(sbc_encoder_frame, force_channel_mode)
|
||||
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
import numpy as np
|
||||
import wave
|
||||
import struct
|
||||
@ -20,9 +20,9 @@ def sbc_compare_subband_samples(frame_count, actual_frame, expected_frame):
|
||||
max_error = M
|
||||
|
||||
if max_error > error:
|
||||
print "Frame %d: sb_sample error %f (ch %d, blk %d)" % (frame_count, max_error, ch, blk)
|
||||
print actual_frame.sb_sample[blk]
|
||||
print expected_frame.sb_sample[blk]
|
||||
print ("Frame %d: sb_sample error %f (ch %d, blk %d)" % (frame_count, max_error, ch, blk))
|
||||
print (actual_frame.sb_sample[blk])
|
||||
print (expected_frame.sb_sample[blk])
|
||||
return -1
|
||||
return 0
|
||||
|
||||
@ -36,65 +36,65 @@ def sbc_compare_audio_frames(frame_count, actual_frame, expected_frame):
|
||||
max_error = M
|
||||
|
||||
if max_error > error:
|
||||
print "audio_sample error (%d, %f ) " % (frame_count, max_error)
|
||||
print actual_frame.audio_sample[blk]
|
||||
print expected_frame.audio_sample[blk]
|
||||
print ("audio_sample error (%d, %f ) " % (frame_count, max_error))
|
||||
print (actual_frame.audio_sample[blk])
|
||||
print (expected_frame.audio_sample[blk])
|
||||
|
||||
return -1
|
||||
return 0
|
||||
|
||||
def sbc_compare_headers(frame_count, actual_frame, expected_frame):
|
||||
if actual_frame.syncword != expected_frame.syncword:
|
||||
print "syncword wrong ", actual_frame.syncword
|
||||
print ("syncword wrong ", actual_frame.syncword)
|
||||
return -1
|
||||
|
||||
if actual_frame.sampling_frequency != expected_frame.sampling_frequency:
|
||||
print "sampling_frequency wrong ", actual_frame.sampling_frequency
|
||||
print ("sampling_frequency wrong ", actual_frame.sampling_frequency)
|
||||
return -1
|
||||
|
||||
if actual_frame.nr_blocks != expected_frame.nr_blocks:
|
||||
print "nr_blocks wrong ", actual_frame.nr_blocks
|
||||
print ("nr_blocks wrong ", actual_frame.nr_blocks)
|
||||
return -1
|
||||
|
||||
if actual_frame.channel_mode != expected_frame.channel_mode:
|
||||
print "channel_mode wrong ", actual_frame.channel_mode
|
||||
print ("channel_mode wrong ", actual_frame.channel_mode)
|
||||
return -1
|
||||
|
||||
if actual_frame.nr_channels != expected_frame.nr_channels:
|
||||
print "nr_channels wrong ", actual_frame.nr_channels
|
||||
print ("nr_channels wrong ", actual_frame.nr_channels)
|
||||
return -1
|
||||
|
||||
if actual_frame.allocation_method != expected_frame.allocation_method:
|
||||
print "allocation_method wrong ", actual_frame.allocation_method
|
||||
print ("allocation_method wrong ", actual_frame.allocation_method)
|
||||
return -1
|
||||
|
||||
if actual_frame.nr_subbands != expected_frame.nr_subbands:
|
||||
print "nr_subbands wrong ", actual_frame.nr_subbands
|
||||
print ("nr_subbands wrong ", actual_frame.nr_subbands)
|
||||
return -1
|
||||
|
||||
if actual_frame.bitpool != expected_frame.bitpool:
|
||||
print "bitpool wrong (E: %d, D: %d)" % (actual_frame.bitpool, expected_frame.bitpool)
|
||||
print ("bitpool wrong (E: %d, D: %d)" % (actual_frame.bitpool, expected_frame.bitpool))
|
||||
return -1
|
||||
|
||||
if mse(actual_frame.join, expected_frame.join) > 0:
|
||||
print "join error \nE:\n %s \nD:\n %s" % (actual_frame.join, expected_frame.join)
|
||||
print ("join error \nE:\n %s \nD:\n %s" % (actual_frame.join, expected_frame.join))
|
||||
return -1
|
||||
|
||||
|
||||
if mse(actual_frame.scale_factor, expected_frame.scale_factor) > 0:
|
||||
print "scale_factor error %d \nE:\n %s \nD:\n %s" % (frame_count, actual_frame.scale_factor, expected_frame.scale_factor)
|
||||
print ("scale_factor error %d \nE:\n %s \nD:\n %s" % (frame_count, actual_frame.scale_factor, expected_frame.scale_factor))
|
||||
return -1
|
||||
|
||||
if mse(actual_frame.scalefactor, expected_frame.scalefactor) > 0:
|
||||
print "scalefactor error %d \nE:\n %s \nD:\n %s" % (frame_count, actual_frame.scalefactor, expected_frame.scalefactor)
|
||||
print ("scalefactor error %d \nE:\n %s \nD:\n %s" % (frame_count, actual_frame.scalefactor, expected_frame.scalefactor))
|
||||
return -1
|
||||
|
||||
if mse(actual_frame.bits, expected_frame.bits) > 0:
|
||||
print "bits error %d \nE:\n %s \nD:\n %s" % (frame_count, actual_frame.bits, expected_frame.bits)
|
||||
print ("bits error %d \nE:\n %s \nD:\n %s" % (frame_count, actual_frame.bits, expected_frame.bits))
|
||||
return -1
|
||||
|
||||
if actual_frame.crc_check != expected_frame.crc_check:
|
||||
print "crc_check wrong (E: %d, D: %d)" % (actual_frame.crc_check, expected_frame.crc_check)
|
||||
print ("crc_check wrong (E: %d, D: %d)" % (actual_frame.crc_check, expected_frame.crc_check))
|
||||
return -1
|
||||
|
||||
return 0
|
||||
|
6
test/sbc/sbc_synthesis_v1.py
Normal file → Executable file
6
test/sbc/sbc_synthesis_v1.py
Normal file → Executable file
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
import numpy as np
|
||||
import wave
|
||||
import struct
|
||||
@ -56,11 +56,11 @@ def remap_V(i):
|
||||
return V_remap[i]
|
||||
|
||||
def sbc_frame_synthesis_v1_4subbands(frame, ch, blk):
|
||||
print "sbc_frame_synthesis_v1_4subbands(frame, ch, blk) not implemented yet"
|
||||
print ("sbc_frame_synthesis_v1_4subbands(frame, ch, blk) not implemented yet")
|
||||
exit(1)
|
||||
|
||||
def sbc_frame_synthesis_v1_8subbands(frame, ch, blk):
|
||||
print "sbc_frame_synthesis_v1_8subbands(frame, ch, blk) not implemented yet"
|
||||
print ("sbc_frame_synthesis_v1_8subbands(frame, ch, blk) not implemented yet")
|
||||
exit(1)
|
||||
|
||||
def matrix_R():
|
||||
|
@ -33,9 +33,9 @@ except ImportError:
|
||||
from Crypto.Cipher import AES
|
||||
from Crypto.Hash import CMAC
|
||||
except ImportError:
|
||||
have_crypto = False
|
||||
print("\n[!] PyCryptodome required to calculate GATT Database Hash but not installed (using random value instead)")
|
||||
print("[!] Please install PyCryptodome, e.g. 'pip install pycryptodomex' or 'pip install pycryptodome'\n")
|
||||
have_crypto = False
|
||||
print("\n[!] PyCryptodome required to calculate GATT Database Hash but not installed (using random value instead)")
|
||||
print("[!] Please install PyCryptodome, e.g. 'pip3 install pycryptodomex' or 'pip3 install pycryptodome'\n")
|
||||
|
||||
header = '''
|
||||
// {0} generated from {1} for BTstack
|
||||
|
Loading…
x
Reference in New Issue
Block a user