<filename>scaaml/capture/communication.py
# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Communication protocols between the capturing host and the chip."""

from abc import ABC, abstractmethod
from typing import Optional

from chipwhisperer.capture.api.cwcommon import ChipWhispererCommonInterface


class AbstractSCommunication(ABC):
    """Base class for communication. Communication is a context manager."""

    def __init__(self):
        """Initialization of the communication object."""

    @abstractmethod
    def __enter__(self):
        """Initialize target."""
        return self

    @abstractmethod
    def __exit__(self, exc_type, exc_value, exc_tb):
        """Safely close all resources.

        Args:
          exc_type: None if no exception, otherwise the exception type.
          exc_value: None if no exception, otherwise the exception value.
          exc_tb: None if no exception, otherwise the traceback.
        """

    @property
    def target(self) -> Optional[ChipWhispererCommonInterface]:
        """The target object. Returns None if no target is available."""
        return None

<filename>scaaml/capture/communication.py
# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Communication protocols between the capturing host and the chip."""

from abc import ABC, abstractmethod
from typing import Optional

from chipwhisperer.capture.api.cwcommon import ChipWhispererCommonInterface


class AbstractSCommunication(ABC):
    """Base class for communication. Communication is a context manager."""

    def __init__(self):
        """Initialization of the communication object."""

    @abstractmethod
    def __enter__(self):
        """Initialize target."""
        return self

    @abstractmethod
    def __exit__(self, exc_type, exc_value, exc_tb):
        """Safely close all resources.

        Args:
          exc_type: None if no exception, otherwise the exception type.
          exc_value: None if no exception, otherwise the exception value.
          exc_tb: None if no exception, otherwise the traceback.
        """

    @property
    def target(self) -> Optional[ChipWhispererCommonInterface]:
        """The target object. Returns None if no target is available."""
        return None

# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # #     https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. Communication protocols between the capturing host and the chip. Base class for communication. Communication is a context manager. Initialization of the communication object. Initialize target. Safely close all resources.          Args:           exc_type: None if no exception, otherwise the exception type.           exc_value: None if no exception, otherwise the exception value.           exc_tb: None if no exception, otherwise the traceback. The target object. Returns None if no target is available.