blob: a9dbdac1a6d60a764dd4c038812748ea70142c48 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
"""Provides an abstract serial target, that communicates by writing and reading a stream of bytes."""
from abc import abstractmethod
from public import public
from pyecsca.sca.target.base import Target
@public
class SerialTarget(Target):
"""Serial target."""
@abstractmethod
def write(self, data: bytes) -> None:
"""
Write the :paramref:`~.write.data` bytes to the target's serial input.
:param data: The data to write.
"""
raise NotImplementedError
@abstractmethod
def read(self, num: int = 0, timeout: int = 0) -> bytes:
"""
Read upto :paramref:`~.read.num` bytes or until :paramref:`~.read.timeout` milliseconds from the target's serial output.
:param num: The number of bytes to read, ``0`` for all available.
:param timeout: The timeout in milliseconds.
:return: The bytes read.
"""
raise NotImplementedError
|