S15qkd/error_correction.py
def _ecnotepipe_digest(ec_note_pipe: str = PipesQKD.ECNOTE):
    '''
    Digests error correction activities indicated by the 'ecnotepipe' pipe.
    This is getting input from the ec_note_pipe which is updated after an error correction run.
    '''
    global proc_error_correction, total_ec_key_bits, servoed_QBER
    global ec_epoch, ec_raw_bits, ec_final_bits, ec_err_fraction
    global ec_err_fraction_history, ec_err_key_length_history, ec_key_gen_rate
    fd = os.open(ec_note_pipe, os.O_RDONLY | os.O_NONBLOCK)
    f = os.fdopen(fd, 'rb', 0)  # non-blocking

    while proc_error_correction is not None and proc_error_correction.poll() is None:
        time.sleep(0.1)
        try:
            message = (f.readline().decode().rstrip('\n')).lstrip('\x00')
            if len(message) != 0:
                message = message.split()
                ec_epoch = message[0]
                ec_raw_bits = int(message[1])
                ec_final_bits = int(message[2])
                ec_err_fraction = float(message[3])
                ec_nr_of_epochs = int(message[4])
                ec_key_gen_rate = ec_final_bits / \
                    (int(message[4]) * EPOCH_DURATION)
                total_ec_key_bits += ec_final_bits
                ec_err_fraction_history.append(ec_err_fraction)
                ec_err_key_length_history.append(ec_final_bits)
                # servoing QBER
                servoed_QBER += (ec_err_fraction - servoed_QBER) / servo_blocks
                if servoed_QBER < 0.005:
                    servoed_QBER = 0.005
                if servoed_QBER > 1 or servoed_QBER < 0:
                    servoed_QBER = default_QBER
                elif servoed_QBER > QBER_limit:
                    logger.error(f'QBER: {servoed_QBER} above {QBER_limit}. Restarting polarization compensation.')
                    controller.start_service_mode()
                    servoed_QBER = QBER_limit

                logger.info(
                    f'Epoch: {ec_epoch}, Raw bits: {ec_raw_bits}, Error corr. bits: {ec_final_bits}, QBER: {ec_err_fraction}, Nr. of consumed epochs: {ec_nr_of_epochs}')
        except OSError:
            pass
        except Exception as a:
            logger.error(a)
    logger.info(f'Thread finished')

    Digests error correction activities indicated by the 'ecnotepipe' pipe.
    This is getting input from the ec_note_pipe which is updated after an error correction run.
    
Digests error correction activities indicated by the 'ecnotepipe' pipe.
This is getting input from the ec_note_pipe which is updated after an error correction run.
Digests error correction activities indicated by the ' ecnotepipe ' pipe . This is getting input from the ec_note_pipe which is updated after an error correction run .
def _ecnotepipe_digest(ec_note_pipe: str = PipesQKD.ECNOTE):
    global proc_error_correction, total_ec_key_bits, servoed_QBER
    global ec_epoch, ec_raw_bits, ec_final_bits, ec_err_fraction
    global ec_err_fraction_history, ec_err_key_length_history, ec_key_gen_rate
    fd = os.open(ec_note_pipe, os.O_RDONLY | os.O_NONBLOCK)
    f = os.fdopen(fd, 'rb', 0)  
    while proc_error_correction is not None and proc_error_correction.poll() is None:
        time.sleep(0.1)
        try:
            message = (f.readline().decode().rstrip('\n')).lstrip('\x00')
            if len(message) != 0:
                message = message.split()
                ec_epoch = message[0]
                ec_raw_bits = int(message[1])
                ec_final_bits = int(message[2])
                ec_err_fraction = float(message[3])
                ec_nr_of_epochs = int(message[4])
                ec_key_gen_rate = ec_final_bits / \
                    (int(message[4]) * EPOCH_DURATION)
                total_ec_key_bits += ec_final_bits
                ec_err_fraction_history.append(ec_err_fraction)
                ec_err_key_length_history.append(ec_final_bits)
                servoed_QBER += (ec_err_fraction - servoed_QBER) / servo_blocks
                if servoed_QBER < 0.005:
                    servoed_QBER = 0.005
                if servoed_QBER > 1 or servoed_QBER < 0:
                    servoed_QBER = default_QBER
                elif servoed_QBER > QBER_limit:
                    logger.error(f'QBER: {servoed_QBER} above {QBER_limit}. Restarting polarization compensation.')
                    controller.start_service_mode()
                    servoed_QBER = QBER_limit
                logger.info(
                    f'Epoch: {ec_epoch}, Raw bits: {ec_raw_bits}, Error corr. bits: {ec_final_bits}, QBER: {ec_err_fraction}, Nr. of consumed epochs: {ec_nr_of_epochs}')
        except OSError:
            pass
        except Exception as a:
            logger.error(a)
    logger.info(f'Thread finished')
def _ecnotepipe_digest ( ec_note_pipe : str = PipesQKD . ECNOTE ) : global proc_error_correction , total_ec_key_bits , servoed_QBER global ec_epoch , ec_raw_bits , ec_final_bits , ec_err_fraction global ec_err_fraction_history , ec_err_key_length_history , ec_key_gen_rate fd = os . open ( ec_note_pipe , os . O_RDONLY | os . O_NONBLOCK ) f = os . fdopen ( fd , 'rb' , 0 ) while proc_error_correction is not None and proc_error_correction . poll ( ) is None : time . sleep ( 0.1 ) try : message = ( f . readline ( ) . decode ( ) . rstrip ( '\n' ) ) . lstrip ( '\x00' ) if len ( message ) != 0 : message = message . split ( ) ec_epoch = message [ 0 ] ec_raw_bits = int ( message [ 1 ] ) ec_final_bits = int ( message [ 2 ] ) ec_err_fraction = float ( message [ 3 ] ) ec_nr_of_epochs = int ( message [ 4 ] ) ec_key_gen_rate = ec_final_bits / ( int ( message [ 4 ] ) * EPOCH_DURATION ) total_ec_key_bits += ec_final_bits ec_err_fraction_history . append ( ec_err_fraction ) ec_err_key_length_history . append ( ec_final_bits ) servoed_QBER += ( ec_err_fraction - servoed_QBER ) / servo_blocks if servoed_QBER < 0.005 : servoed_QBER = 0.005 if servoed_QBER > 1 or servoed_QBER < 0 : servoed_QBER = default_QBER elif servoed_QBER > QBER_limit : logger . error ( f'QBER: {servoed_QBER} above {QBER_limit}. Restarting polarization compensation.' ) controller . start_service_mode ( ) servoed_QBER = QBER_limit logger . info ( f'Epoch: {ec_epoch}, Raw bits: {ec_raw_bits}, Error corr. bits: {ec_final_bits}, QBER: {ec_err_fraction}, Nr. of consumed epochs: {ec_nr_of_epochs}' ) except OSError : pass except Exception as a : logger . error ( a ) logger . info ( f'Thread finished' )
Digests error correction activities indicated by the 'ecnotepipe' pipe.
Digests error correction activities indicated by the ' ecnotepipe ' pipe .
'''
    Digests error correction activities indicated by the 'ecnotepipe' pipe.
    This is getting input from the ec_note_pipe which is updated after an error correction run.
    ''' # non-blocking # servoing QBER
ec_note_pipe
str