def unmake_packet(whitened_payload_with_crc, whitener_offset=0, dewhitening=1): """ Return (ok, payload) Args: whitened_payload_with_crc: string whitener_offset: offset into whitener string to use [0-16) dewhitening: Turn whitener on or off (bool) """ # Debug TFC # print "dewhitening: "+str(dewhitening) 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, dewhitening=True, check_crc=True): """ 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 check_crc: ok, payload = crc.check_crc32(payload_with_crc) else: payload = payload_with_crc ok = True 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) print "" return ok, payload
def unmake_packet(whitened_payload_with_crc, whitener_offset=0, dewhitening=True, check_crc=True): """ 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 check_crc: ok, payload = crc.check_crc32(payload_with_crc) else: payload = payload_with_crc ok = True 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) print "" return ok, payload
def unmake_packet(whitened_payload_with_crc, fec_n, fec_k, bps, expectedLen, whitener_offset=0, dewhitening=1): """ 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 0: printlst = list() for x in whitened_payload_with_crc: t = hex(ord(x)).replace('0x', '') if(len(t) == 1): t = '0' + t printlst.append(t) printable = ''.join(printlst) print "whitened: " sys.stdout.flush() print printable sys.stdout.flush() print "\n" sys.stdout.flush() if dewhitening: payload_with_crc = dewhiten(whitened_payload_with_crc, whitener_offset) else: payload_with_crc = whitened_payload_with_crc if 0: printlst = list() for x in payload_with_crc: t = hex(ord(x)).replace('0x', '') if(len(t) == 1): t = '0' + t printlst.append(t) printable = ''.join(printlst) print "dewhitened: " sys.stdout.flush() print printable sys.stdout.flush() print "\n" sys.stdout.flush() if (fec_n > 0 and fec_k > 0): pkt = crc.rx_wrapper(payload_with_crc, fec_n, fec_k, bps, expectedLen) else: pkt = payload_with_crc ok, payload = crc.check_crc32(pkt) 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, dewhitening=1): """ 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 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, fec_n, fec_k, bps, expectedLen, whitener_offset=0, dewhitening=1): """ 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 0: printlst = list() for x in whitened_payload_with_crc: t = hex(ord(x)).replace('0x', '') if (len(t) == 1): t = '0' + t printlst.append(t) printable = ''.join(printlst) print "whitened: " sys.stdout.flush() print printable sys.stdout.flush() print "\n" sys.stdout.flush() if dewhitening: payload_with_crc = dewhiten(whitened_payload_with_crc, whitener_offset) else: payload_with_crc = whitened_payload_with_crc if 0: printlst = list() for x in payload_with_crc: t = hex(ord(x)).replace('0x', '') if (len(t) == 1): t = '0' + t printlst.append(t) printable = ''.join(printlst) print "dewhitened: " sys.stdout.flush() print printable sys.stdout.flush() print "\n" sys.stdout.flush() if (fec_n > 0 and fec_k > 0): pkt = crc.rx_wrapper(payload_with_crc, fec_n, fec_k, bps, expectedLen) else: pkt = payload_with_crc ok, payload = crc.check_crc32(pkt) 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