def copy_ecu_with_frames(ecu_or_glob, source_db, target_db):
    # type: (typing.Union[cm.Ecu, str], cm.CanMatrix, cm.CanMatrix) -> None
    """
    Copy ECU(s) identified by Name or as Object from source CAN matrix to target CAN matrix.
    This function additionally copy all relevant Frames and Defines.

    :param ecu_or_glob: Ecu instance or glob pattern for Ecu name
    :param source_db: Source CAN matrix
    :param target_db: Destination CAN matrix
    """
    # check whether ecu_or_glob is object or symbolic name
    if isinstance(ecu_or_glob, cm.Ecu):
        ecu_list = [ecu_or_glob]
    else:
        ecu_list = source_db.glob_ecus(ecu_or_glob)

    for ecu in ecu_list:
        logger.info("Copying ECU " + ecu.name)

        target_db.add_ecu(copy.deepcopy(ecu))

        # copy tx-frames
        for frame in source_db.frames:
            if ecu.name in frame.transmitters:
                copy_frame(frame.arbitration_id, source_db, target_db)

        # copy rx-frames
        for frame in source_db.frames:
            for signal in frame.signals:
                if ecu.name in signal.receivers:
                    copy_frame(frame.arbitration_id, source_db, target_db)
                    break

        # copy all ECU defines
        for attribute in ecu.attributes:
            if attribute not in target_db.ecu_defines:
                target_db.add_ecu_defines(
                    copy.deepcopy(attribute), copy.deepcopy(source_db.ecu_defines[attribute].definition))
                target_db.add_define_default(
                    copy.deepcopy(attribute), copy.deepcopy(source_db.ecu_defines[attribute].defaultValue))
            # update enum-data types if needed:
            if source_db.ecu_defines[attribute].type == 'ENUM':
                temp_attr = ecu.attribute(attribute, db=source_db)
                if temp_attr not in target_db.ecu_defines[attribute].values:
                    target_db.ecu_defines[attribute].values.append(copy.deepcopy(temp_attr))
                    target_db.ecu_defines[attribute].update()
Copy ECU(s) identified by Name or as Object from source CAN matrix to target CAN matrix.
    This function additionally copy all relevant Frames and Defines.

    :param ecu_or_glob: Ecu instance or glob pattern for Ecu name
    :param source_db: Source CAN matrix
    :param target_db: Destination CAN matrix