def make_full(hexinput): pdf1 = decodefunctions.hextobin(hexinput) b = pdf1[:204] + '0' * 48 print(b, len(b)) ecc = calcBCH(b, 0, 202, 250) newhex = decodefunctions.bin2hex(pdf1[:204] + ecc) print(newhex) print(ecc, decodefunctions.bin2hex(ecc)) BCH_POLYNOMIAL = 285 # 285 BCH_BITS = 6 bitflips = 0 bch = bchlib.BCH(BCH_POLYNOMIAL, BCH_BITS) max_data_len = bch.n // 8 - (bch.ecc_bits + 7) // 8 data = bytearray(bch1correct.bitstring_to_bytes(pdf1[:204])) necc = bch.encode(data) bchstring = '' for e in necc: binchar = decodefunctions.dec2bin(e).zfill(8) bchstring = bchstring + binchar print(bchstring, decodefunctions.bin2hex(bchstring)) newhex = decodefunctions.bin2hex(pdf1[:204] + bchstring) return newhex
def encodelong(form, h): secbin=dec2bin(int(form.timesecond.data),17) if int(form.altitude.data) >15952: alt='1'*10 else: alt= dec2bin(round((int(form.altitude.data)+400)/float(16)),10) completebin = form.longSGB(h) + '0001' + secbin+alt + form.act.data + form.gnss.data+form.battery.data + '0'*9 bch = calcBCH(completebin, 0, 202, 250) return bin2hex('00' + completebin + bch)
def encodelong(form, h): rlm_short_sig = str(form.rlm_short_signal.data.zfill(20)) completebin = form.longSGB(h) + '0010' + '00' +\ form.rls_capability_auto.data+\ form.rls_capability_manual.data+ '0000'+\ form.rls_provider.data+\ form.beacon_feedback_t1.data+\ form.beacon_feedback_t2.data+\ rlm_short_sig+'0'*11 bch = calcBCH(completebin, 0, 202, 250) return bin2hex('00' + completebin + bch)
def encodelong(form, h): hoursbin = dec2bin(int(form.hours.data), 6) if form.minutes.data == None: minbin = dec2bin(2047, 11) else: minbin = dec2bin(int(form.minutes.data), 11) if form.altitude.data == None: altbin = '1' * 10 else: a = round((float(form.altitude.data + 400) / 16), 0) altbin = dec2bin(a, 10) completebin = form.longSGB( h ) + '0000' + hoursbin + minbin + altbin + form.hdop.data + form.vdop.data + form.act.data + form.bat.data + form.fix.data + '00' bch = calcBCH(completebin, 0, 202, 250) print(completebin) return bin2hex('00' + completebin + bch)
def encodelong(form, h): completebin = form.longSGB(h)[:-14] + '0' *14 + '1111' + '1'*42 + form.cancel_message.data bch = calcBCH(completebin, 0, 202, 250) return bin2hex('00' + completebin + bch)
def encodelong(form, h): nat= str(dec2bin(int(form.national_use.data))).zfill(44) completebin = form.longSGB(h) + '0011' + nat bch = calcBCH(completebin, 0, 202, 250) return bin2hex('00' + completebin + bch)