# HG changeset patch # User paul # Date 2014-02-20 16:02:24 # Node ID 30ac019d302a905ed1da989c6fb85ff9dcab24ff # Parent e4348633316b6dcc2fac6920c3628d6cf4f6edde Added a few files to the repository diff --git a/FSW-qt/bin/floatconversion.py b/FSW-qt/bin/floatconversion.py new file mode 100644 --- /dev/null +++ b/FSW-qt/bin/floatconversion.py @@ -0,0 +1,83 @@ +def ieee(f, word=32): + """Generate the binary string representing a floating-point value in IEEE754 code.""" + f = float(f) + if word not in (16, 32, 64, 128): + raise ValueError("IEEE754 is defined for 16, 32, 64 and 128 bit words.") + exp_bin = range({16:5, 32:8, 64:11, 128:15}[word]) + frac_bin = range(word - len(exp_bin) - 1) + + # Sign. + sign_bin = [int(f < 0)] + f = abs(f) + + # Find exponent (adding the bias). + bias = 2**(len(exp_bin)-1) -1 + exponent = bias + while f >= 2: + exponent += 1 + f /= 2 + while f < 1 and exponent > 0: + exponent -= 1 + f *= 2 + if not 0 <= exponent < 2*(bias+1): + raise ValueError("Exponent overflow: Absolute exponent must be smaller than %d." % (bias + 1)) + + # Encode exponent in binary. + for i in exp_bin[::-1]: + exp_bin[i] = int(exponent % 2) + exponent /= 2 + + # Remove the leading 1 bit. + f -= 1 + for i in frac_bin: + f *= 2 + frac_bin[i] = int(f >= 1) + f -= frac_bin[i] + + # Join the binary string components together. + return "".join(map(str, sign_bin + exp_bin + frac_bin)) + +def ieee_decode(binary): + """Decode a binary string representing a floating-point value in IEEE754 code.""" + + # Determine the word size of the binary. + word = len(binary) + if word not in (16, 32, 64, 128): + raise ValueError("IEEE754 is defined for 16, 32, 64 and 128 bit words.") + + # Determine the length of the exponent. + e = {16:5, 32:8, 64:11, 128:15}[word] + + # Turn the binary string into a bit-list. + binary = [int(c) for c in binary] + + # Split the components. + sign = -2 * binary[0] + 1 + exp_bin = binary[1:1+e] + frac_bin = binary[1+e:] + + # Decode the exponent. + bias = 2**(e-1) - 1 + exponent = -bias + c = 1 + for i in exp_bin[::-1]: + exponent += i * c + c *= 2 + + # Decode the fraction. + f = float(2**exponent) + power = f + for i in frac_bin: + power *= 0.5 + f += i * power + + return sign * f + +if __name__ == "__main__": + val = ieee(24.) + val + print val[:16] + print val[0], val[1], val[2] + val_in_int = int(val[:16], 2) + print val_in_int + print hex( val_in_int ) \ No newline at end of file diff --git a/FSW-qt/bin/gdb.ini b/FSW-qt/bin/gdb.ini new file mode 100644 --- /dev/null +++ b/FSW-qt/bin/gdb.ini @@ -0,0 +1,12 @@ +target extended-remote :3333 + +# Reset to known state +monitor reset halt +load +monitor reset init + +# Set a breakpoint at main(). +break set_apbuart_scaler_reload_register + +# Run to the breakpoint. +continue diff --git a/FSW-qt/bin/loadPlugin.py b/FSW-qt/bin/loadPlugin.py new file mode 100644 --- /dev/null +++ b/FSW-qt/bin/loadPlugin.py @@ -0,0 +1,14 @@ +# -*- coding: utf-8 *-* + +# setting up LPPMON plugins +from __main__ import proxy +if not(proxy.instanceExists("RMAPPlugin0")): + proxy.loadSysDriver("RMAPPlugin", "RMAPPlugin0") + proxy.loadSysDriverToParent("dsu3plugin", "RMAPPlugin0") + + dsu3plugin0.openFile("/opt/DEV_PLE/FSW-qt/bin/fsw") + dsu3plugin0.loadFile() + dsu3plugin0.run() + +from __main__ import RMAPPlugin0 + diff --git a/FSW-qt/bin/load_spectral_matrix.py b/FSW-qt/bin/load_spectral_matrix.py new file mode 100644 --- /dev/null +++ b/FSW-qt/bin/load_spectral_matrix.py @@ -0,0 +1,16 @@ +#!/usr/bin/lppmon -e + +address_to_read = 0x80000f08 +val = RMAPPlugin0.Read( address_to_read, 1) +matrixF0_Address0 = val[0] +print hex(matrixF0_Address0) + +# BUILD THE DATA +dataToWrite = [] +for frequencyBin in range(128): + for component in range (25): + dataToWrite.append( component ) + +# WRITE THE DATA +print len(dataToWrite) +RMAPPlugin0.Write( matrixF0_Address0, dataToWrite )