Example #1
0
  def updateParity(self, dataBits, resolve=False):
    '''
    Updates data bits and computes parity.

    When 32 bits are provided, they are used for parity computation and for
    bit inversion.

    Parameters
    ----------
    dataBits : numpy.ndarray(dtype=numpy.uint8)
      30 or 32 element array
    resolve: bool, optional
      When specified, bits d23 and d24 of the GPS word are updated to ensure
      that parity bits d29 and d30 are zeros.
    '''
    packed = numpy.packbits(dataBits)
    acc = (packed[0] << 24) | (packed[1] << 16) | \
          (packed[2] << 8) | packed[3]
    if len(dataBits) == 30:
      acc >>= 2
    elif acc & 0x40000000:
      acc ^= 0x3FFFFFC0
      dataBits[-30:-6] ^= 1

    # D29 = D30*^d1^d3^d5^d6^d7^d9^d10^d14^d15^d16^d17^d18^d21^d22^d24
    d29 = parity(acc & 0b01101011101100011111001101000000)
    # D30 = D29*^d3^d5^d6^d8^d9^d10^d11^d13^d15^d19^d22^d23^d24
    d30 = parity(acc & 0b10001011011110101000100111000000)

    if resolve:
      if d29:
        acc ^= 0x80
        d29 = False
        d30 = not d30
        dataBits[-8] ^= 1
      if d30:
        acc ^= 0x40
        d30 = False
        dataBits[-7] ^= 1

    # D25 = D29*^d1^d2^d3^d5^d6^d10^d11^d12^d13^d14^d17^d18^d20^d23
    dataBits[-6] = parity(acc & 0b10111011000111110011010010000000)
    # D26 = D30*^d2^d3^d4^d6^d7^d11^d12^d13^d14^d15^d18^d19^d21^d24
    dataBits[-5] = parity(acc & 0b01011101100011111001101001000000)
    # D27 = D29*^d1^d3^d4^d5^d7^d8^d12^d13^d14^d15^d16^d19^d20^d22
    dataBits[-4] = parity(acc & 0b10101110110001111100111000000000)
    # D28 = D30*^d2^d4^d5^d6^d8^d9^d13^d14^d15^d16^d17^d20^d21^d23
    dataBits[-3] = parity(acc & 0b01010111011000111110011010000000)
    # D29 = D30*^d1^d3^d5^d6^d7^d9^d10^d14^d15^d16^d17^d18^d21^d22^d24
    dataBits[-2] = d29
    # D30 = D29*^d3^d5^d6^d8^d9^d10^d11^d13^d15^d19^d22^d23^d24
    dataBits[-1] = d30

    return
Example #2
0
    def updateParity(self, dataBits):
        '''
    Updates data bits and computes parity.

    When 85 bits are provided, they are used for parity computation and for
    bit inversion.

    Parameters
    ----------
    dataBits : numpy.ndarray(dtype=numpy.uint8)
      85 element array
    '''
        packed = numpy.packbits(dataBits)
        assert len(packed) == 11

        hc = _HAMMING_COEFFS
        for bIdx in range(8):
            p = 0
            for i in range(11):
                p ^= parity(packed[i] & hc[bIdx][i])
            dataBits[-(bIdx + 1)] = p
            packed[10] |= p << bIdx
Example #3
0
  def updateParity(self, dataBits):
    '''
    Updates data bits and computes parity.

    When 85 bits are provided, they are used for parity computation and for
    bit inversion.

    Parameters
    ----------
    dataBits : numpy.ndarray(dtype=numpy.uint8)
      85 element array
    '''
    packed = numpy.packbits(dataBits)
    assert len(packed) == 11

    hc = _HAMMING_COEFFS
    for bIdx in range(8):
      p = 0
      for i in range(11):
        p ^= parity(packed[i] & hc[bIdx][i])
      dataBits[-(bIdx + 1)] = p
      packed[10] |= p << bIdx