Skip to content

Commit 9f72b37

Browse files
committed
[datatransfer] added inclue EOF option to download
1 parent 1e431f4 commit 9f72b37

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/instrumentman/datatransfer/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@
4040
help="close transfer automatically upon timeout or when EOF is received",
4141
default=True
4242
)
43+
@option(
44+
"--inclide-eof/--no-include-eof",
45+
help=(
46+
"wether the EOF marker is part of the output format "
47+
"(or just sent by the instrument regardless of the format in question)"
48+
),
49+
default=False
50+
)
4351
def cli_download(**kwargs: Any) -> None:
4452
"""Receive data sent from the instrument."""
4553
from .app import main_download

src/instrumentman/datatransfer/app.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ def main_download(
1313
timeout: int = 2,
1414
output: BufferedWriter | None = None,
1515
eof: str = "",
16-
autoclose: bool = True
16+
autoclose: bool = True,
17+
include_eof: bool = False
1718
) -> None:
1819
eof_bytes = eof.encode("ascii")
1920
with open_serial(
@@ -27,6 +28,11 @@ def main_download(
2728
try:
2829
data = com.receive_binary()
2930
started = True
31+
32+
if data == eof_bytes and autoclose and not include_eof:
33+
echo_green("Download finished (end-of-file)")
34+
return
35+
3036
echo(data.decode("ascii", "replace"))
3137
if output is not None:
3238
output.write(data + eol_bytes)

0 commit comments

Comments
 (0)