def fsk_BEP(rx_data,m,flip):
    """
    fsk_BEP(rx_data,m,flip)
    
    Estimate the BEP of the data bits recovered
    by the RTL-SDR Based FSK Receiver.
     
    The reference m-sequence generated in Python
    was found to produce sequences running in the opposite
    direction relative to the m-sequences generated by the
    mbed. To allow error detection the reference m-sequence
    is flipped.
    
    Mark Wickert April 2014
    """
    Nbits = len(rx_data)
    c = dc.m_seq(m)
    if flip == 1:
        # Flip the sequence to compenstate for mbed code difference
        # First make it a 1xN array
        c.shape = (1,len(c))
        c = np.fliplr(c).flatten()
    L = int(np.ceil(Nbits/float(len(c))))
    tx_data = np.dot(c.reshape(len(c),1),np.ones((1,L)))
    tx_data = tx_data.T.reshape((1,len(c)*L)).flatten()
    tx_data = tx_data[:Nbits]
    # Convert to +1/-1 bits
    tx_data = 2*tx_data - 1
    Bit_count,Bit_errors = dc.BPSK_BEP(rx_data,tx_data)
    print('len rx_data = %d, len tx_data = %d' % (len(rx_data),len(tx_data)))
    Pe = Bit_errors/float(Bit_count)
    print('/////////////////////////////////////')
    print('Bit Errors: %d' % Bit_errors)
    print('Bits Total: %d' % Bit_count)
    print('       BEP: %2.2e' % Pe)
    print('/////////////////////////////////////')
def fsk_BEP(rx_data,m,flip):
    """
    fsk_BEP(rx_data,m,flip)
    
    Estimate the BEP of the data bits recovered
    by the RTL-SDR Based FSK Receiver.
     
    The reference m-sequence generated in Python
    was found to produce sequences running in the opposite
    direction relative to the m-sequences generated by the
    mbed. To allow error detection the reference m-sequence
    is flipped.
    
    Mark Wickert April 2014
    """
    Nbits = len(rx_data)
    c = dc.m_seq(m)
    if flip == 1:
        # Flip the sequence to compenstate for mbed code difference
        # First make it a 1xN array
        c.shape = (1,len(c))
        c = np.fliplr(c).flatten()
    L = int(np.ceil(Nbits/float(len(c))))
    tx_data = np.dot(c.reshape(len(c),1),np.ones((1,L)))
    tx_data = tx_data.T.reshape((1,len(c)*L)).flatten()
    tx_data = tx_data[:Nbits]
    # Convert to +1/-1 bits
    tx_data = 2*tx_data - 1
    Bit_count,Bit_errors = dc.BPSK_BEP(rx_data,tx_data)
    print('len rx_data = %d, len tx_data = %d' % (len(rx_data),len(tx_data)))
    Pe = Bit_errors/float(Bit_count)
    print('/////////////////////////////////////')
    print('Bit Errors: %d' % Bit_errors)
    print('Bits Total: %d' % Bit_count)
    print('       BEP: %2.2e' % Pe)
    print('/////////////////////////////////////')
def fsk_BEP ( rx_data , m , flip ) : Nbits = len ( rx_data ) c = dc . m_seq ( m ) if flip == 1 : # Flip the sequence to compenstate for mbed code difference
 # First make it a 1xN array
 c . shape = ( 1 , len ( c ) ) c = np . fliplr ( c ) . flatten ( ) L = int ( np . ceil ( Nbits / float ( len ( c ) ) ) ) tx_data = np . dot ( c . reshape ( len ( c ) , 1 ) , np . ones ( ( 1 , L ) ) ) tx_data = tx_data . T . reshape ( ( 1 , len ( c ) * L ) ) . flatten ( ) tx_data = tx_data [ : Nbits ] # Convert to +1/-1 bits
 tx_data = 2 * tx_data - 1 Bit_count , Bit_errors = dc . BPSK_BEP ( rx_data , tx_data ) print ( 'len rx_data = %d, len tx_data = %d' % ( len ( rx_data ) , len ( tx_data ) ) ) Pe = Bit_errors / float ( Bit_count ) print ( '/////////////////////////////////////' ) print ( 'Bit Errors: %d' % Bit_errors ) print ( 'Bits Total: %d' % Bit_count ) print ( '       BEP: %2.2e' % Pe ) print ( '/////////////////////////////////////' )
fsk_BEP(rx_data,m,flip)
    
    Estimate the BEP of the data bits recovered
    by the RTL-SDR Based FSK Receiver.
     
    The reference m-sequence generated in Python
    was found to produce sequences running in the opposite
    direction relative to the m-sequences generated by the
    mbed. To allow error detection the reference m-sequence
    is flipped.
    
    Mark Wickert April 2014
fsk_BEP ( rx_data m flip ) Estimate the BEP of the data bits recovered by the RTL - SDR Based FSK Receiver . The reference m - sequence generated in Python was found to produce sequences running in the opposite direction relative to the m - sequences generated by the mbed . To allow error detection the reference m - sequence is flipped . Mark Wickert April 2014