def unmake_packet(whitened_payload_with_crc, whitener_offset=0, dewhitening=1, coder=None): """ Return (ok, payload) @param whitened_payload_with_crc: string @param whitener_offset offset into whitener string to use [0-16) @param dewhitening: Turn whitener on or off @type dewhitening: bool """ if dewhitening: payload_with_crc = dewhiten(whitened_payload_with_crc, whitener_offset) else: payload_with_crc = whitened_payload_with_crc if coder is not None: try: payload_with_crc = decode_rs(coder, payload_with_crc) except: payload_with_crc = "XXXXXXXXXX" ok, payload = crc.check_crc32(payload_with_crc) if 0: print "payload_with_crc =", string_to_hex_list(payload_with_crc) print "ok = %r, len(payload) = %d" % (ok, len(payload)) print "payload =", string_to_hex_list(payload) return ok, payload
def unmake_packet(whitened_payload_with_crc, whitener_offset=0, dewhitening=True): """ Return (ok, payload) @param whitened_payload_with_crc: string """ # Xu: Never dewhitening ''' if dewhitening: payload_with_crc = dewhiten(whitened_payload_with_crc, whitener_offset) else: payload_with_crc = (whitened_payload_with_crc) ''' payload_with_crc = (whitened_payload_with_crc) ############################### # Decoding here #rx_pkt = payload_with_crc #cccl = len(rx_pkt) #ccnb = ccDecoder.cc3_nbytes(cccl, CCLEN) #ccDecoder.cc3_decode(rx_pkt,cccl, CCLEN) #rsbitstr = rx_pkt[0:ccnb] rsbitstr = payload_with_crc cl = len(rsbitstr) nb = Decoder.cat_nbytes( cl ) Decoder.cat_decode(rsbitstr, cl) ok, payload = crc.check_crc32(rsbitstr[0:nb]) ########################################################## # uncoded #ok, payload = crc.check_crc32(payload_with_crc) if 0: print "payload_with_crc =", string_to_hex_list(payload_with_crc) print "ok = %r, len(payload) = %d" % (ok, len(payload)) print "payload =", string_to_hex_list(payload) return ok, payload
def unmake_packet(whitened_payload_with_crc, whitener_offset=0, dewhitening=True): """ Return (ok, payload) @param whitened_payload_with_crc: string """ if dewhitening: payload_with_crc = dewhiten(whitened_payload_with_crc, whitener_offset) else: payload_with_crc = (whitened_payload_with_crc) ok, payload = crc.check_crc32(payload_with_crc) if 0: print "payload_with_crc =", string_to_hex_list(payload_with_crc) print "ok = %r, len(payload) = %d" % (ok, len(payload)) print "payload =", string_to_hex_list(payload) return ok, payload
def unmake_packet(whitened_payload_with_crc, whitener_offset=0, debug=False, dewhitening=True, check_crc=True, repeat=1, interleave=None): """ Return (ok, payload) Args: whitened_payload_with_crc: string whitener_offset: integer offset into whitener table dewhitening: True if we should run this through the dewhitener check_crc: True if we should check the CRC of the packet """ if dewhitening: payload_with_crc = dewhiten(whitened_payload_with_crc, whitener_offset) else: payload_with_crc = (whitened_payload_with_crc) if repeat > 1: if interleave == 1: payload_with_crc = fec.deinterleave(payload_with_crc, repeat) elif interleave == 2: payload_with_crc = fec.shuffle_decode(payload_with_crc) payload_with_crc = fec.repeat_decode(payload_with_crc, repeat) if check_crc: ok, payload = crc.check_crc32(payload_with_crc) else: payload = payload_with_crc ok = True if debug: print "" print "payload_with_crc =", string_to_hex_list(payload_with_crc) print "ok = %r, len(payload) = %d" % (ok, len(payload)) print "payload =", string_to_hex_list(payload) print "" return ok, payload
def unmake_packet(whitened_payload_with_crc, whitener_offset=0, dewhitening=True, coder=None): """ Return (ok, payload) @param whitened_payload_with_crc: string """ if dewhitening: payload_with_crc = dewhiten(whitened_payload_with_crc, whitener_offset) else: payload_with_crc = (whitened_payload_with_crc) if coder is not None: try: payload_with_crc = decode_rs(coder, payload_with_crc) except: payload_with_crc = "XXXXXXXXXX" ok, payload = crc.check_crc32(payload_with_crc) if 0: print "payload_with_crc =", string_to_hex_list(payload_with_crc) print "ok = %r, len(payload) = %d" % (ok, len(payload)) print "payload =", string_to_hex_list(payload) return ok, payload
def unmake_packet(whitened_payload_with_crc, options, use_coding=False, #added on 09/20/12 logging= -1, # deprecated whitener_offset=0, dewhitening=True): """ Return (ok, payload) @param whitened_payload_with_crc: string """ #changed payload_with_crc to payload_with_crc_and_rs_interleaved if dewhitening: payload_with_crc_and_rs_interleaved, success = dewhiten(whitened_payload_with_crc, whitener_offset) else: payload_with_crc_and_rs_interleaved = (whitened_payload_with_crc) success=True # check if dewhitening failed if success: #use_coding section copied from Thomas' ofdm_packet_util.py #added by Tri on 09/20/2012 if use_coding: #print "use_coding is activated on rx" # Reed Solomon Variables N = 8 K = 4 #if K is changed, copy it to benchmark_tx.py as well #De-interleave payload_with_crc_and_rs = '' for n in range(0, len(payload_with_crc_and_rs_interleaved)/N, 1): payload_with_crc_and_rs = payload_with_crc_and_rs + payload_with_crc_and_rs_interleaved[n:len(payload_with_crc_and_rs_interleaved):len(payload_with_crc_and_rs_interleaved)/N] #Reed-Solomon Decode rs_encoder = Codec(N,K) payload_with_crc = '' rs_ok = 1 for n in range(0, len(payload_with_crc_and_rs), N): try: decoded = rs_encoder.decode(payload_with_crc_and_rs[n:n+N]); except: decoded = ('0'*K,) rs_ok = 0 payload_with_crc = payload_with_crc + decoded[0] else: payload_with_crc = payload_with_crc_and_rs_interleaved rs_ok = True crc_ok, payload = crc.check_crc32(payload_with_crc) ok = crc_ok & rs_ok if 0: print "payload_with_crc =", string_to_hex_list(payload_with_crc) print "ok = %r, len(payload) = %d" % (ok, len(payload)) print "payload =", string_to_hex_list(payload) # whitening failed. Don't trust the payload at all and assume CRC failed else: payload='' ok=False return ok, payload
def unmake_packet( whitened_payload_with_crc, options, use_coding=False, #added on 09/20/12 logging=-1, # deprecated whitener_offset=0, dewhitening=True): """ Return (ok, payload) @param whitened_payload_with_crc: string """ #changed payload_with_crc to payload_with_crc_and_rs_interleaved if dewhitening: payload_with_crc_and_rs_interleaved, success = dewhiten( whitened_payload_with_crc, whitener_offset) else: payload_with_crc_and_rs_interleaved = (whitened_payload_with_crc) success = True # check if dewhitening failed if success: #use_coding section copied from Thomas' ofdm_packet_util.py #added by Tri on 09/20/2012 if use_coding: #print "use_coding is activated on rx" # Reed Solomon Variables N = 8 K = 4 #if K is changed, copy it to benchmark_tx.py as well #De-interleave payload_with_crc_and_rs = '' for n in range(0, len(payload_with_crc_and_rs_interleaved) / N, 1): payload_with_crc_and_rs = payload_with_crc_and_rs + payload_with_crc_and_rs_interleaved[ n:len(payload_with_crc_and_rs_interleaved ):len(payload_with_crc_and_rs_interleaved) / N] #Reed-Solomon Decode rs_encoder = Codec(N, K) payload_with_crc = '' rs_ok = 1 for n in range(0, len(payload_with_crc_and_rs), N): try: decoded = rs_encoder.decode(payload_with_crc_and_rs[n:n + N]) except: decoded = ('0' * K, ) rs_ok = 0 payload_with_crc = payload_with_crc + decoded[0] else: payload_with_crc = payload_with_crc_and_rs_interleaved rs_ok = True crc_ok, payload = crc.check_crc32(payload_with_crc) ok = crc_ok & rs_ok if 0: print "payload_with_crc =", string_to_hex_list(payload_with_crc) print "ok = %r, len(payload) = %d" % (ok, len(payload)) print "payload =", string_to_hex_list(payload) # whitening failed. Don't trust the payload at all and assume CRC failed else: payload = '' ok = False return ok, payload