aboutsummaryrefslogtreecommitdiff
path: root/pyecsca/sca/scope/base.py
diff options
context:
space:
mode:
Diffstat (limited to 'pyecsca/sca/scope/base.py')
-rw-r--r--pyecsca/sca/scope/base.py86
1 files changed, 85 insertions, 1 deletions
diff --git a/pyecsca/sca/scope/base.py b/pyecsca/sca/scope/base.py
index 3bade40..2979a7d 100644
--- a/pyecsca/sca/scope/base.py
+++ b/pyecsca/sca/scope/base.py
@@ -1,5 +1,89 @@
+from typing import Tuple, Sequence, Optional
+import numpy as np
+from public import public
+
+@public
class Scope(object):
"""An oscilloscope."""
- pass
+
+ def open(self) -> None:
+ """Open the connection to the scope."""
+ raise NotImplementedError
+
+ @property
+ def channels(self) -> Sequence[str]:
+ """A list of channels available on this scope."""
+ raise NotImplementedError
+
+ def setup_frequency(self, frequency: int, samples: int) -> Tuple[int, int]:
+ """
+ Setup the frequency and sample count for the measurement. The scope might not support
+ the requested values and will adjust them to get the next best frequency and the largest
+ supported number of samples (or the number of samples requested).
+
+ :param frequency: The requested frequency in Hz.
+ :param samples: The requested number of samples to measure.
+ :return: A tuple of the actual set frequency and the actual number of samples.
+ """
+ raise NotImplementedError
+
+ def setup_channel(self, channel: str, coupling: str, range: float, enable: bool) -> None:
+ """
+ Setup a channel to use the coupling method and measure the given voltage range.
+
+ :param channel: The channel to measure.
+ :param coupling: The coupling method ("AC" or "DC).
+ :param range: The voltage range to measure.
+ :param enable: Whether to enable or disable the channel.
+ """
+ raise NotImplementedError
+
+ def setup_trigger(self, channel: str, threshold: float, direction: str, delay: int,
+ timeout: int, enable: bool) -> None:
+ """
+ Setup a trigger on a particular `channel`, the channel has to be set up and enabled.
+ The trigger will fire based on the `threshold` and `direction`, if enabled, the trigger
+ will capture after `delay` ticks pass. If trigger conditions do not hold it will fire
+ automatically after `timeout` milliseconds.
+
+ :param channel: The channel to trigger on.
+ :param threshold: The value to trigger on.
+ :param direction: The direction to trigger on ("above", "below", "rising", "falling").
+ :param delay: The delay for capture after trigger (clock ticks).
+ :param timeout: The timeout in milliseconds.
+ :param enable: Whether to enable or disable this trigger.
+ """
+ raise NotImplementedError
+
+ def setup_capture(self, channel: str, enable: bool) -> None:
+ """
+ Setup the capture for a channel.
+
+ :param channel: The channel to capture.
+ :param enable: Whether to enable or disable capture.
+ """
+ raise NotImplementedError
+
+ def arm(self) -> None:
+ """Arm the scope, it will listen for the trigger after this point."""
+ raise NotImplementedError
+
+ def capture(self, channel: str, timeout: Optional[int] = None) -> Optional[np.ndarray]:
+ """
+ Wait for the trace to capture, this will block until the scope has a trace.
+
+ :param channel: The channel to retrieve the trace from.
+ :param timeout: A time in milliseconds to wait for the trace, returns `None` if it runs out.
+ :return: The trace, or if timed out, None.
+ """
+ raise NotImplementedError
+
+ def stop(self) -> None:
+ """Stop the capture, if any."""
+ raise NotImplementedError
+
+ def close(self) -> None:
+ """Close the connection to the scope."""
+ raise NotImplementedError