Skip to content

Commit ab55bff

Browse files
authored
Merge pull request #27 from MrClock8163/docs/command-help-improvements
Command help improvements
2 parents 934ac85 + a248c9d commit ab55bff

File tree

19 files changed

+340
-141
lines changed

19 files changed

+340
-141
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ The project uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
2828
- Added progress indicator to more commands
2929
- `points` option in set measurement and station calculation is now a multi
3030
option, instead of a comma separated string list
31+
- `chunk` option of file download now expects size in bytes, instead of
32+
encoded hex characters
3133

3234
### Fixed
3335

docs/about.rst

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,10 @@ These have to be set before specifying the command groups.
4040
4141
iman --info --file iman.log measure ...
4242
43-
Usage
44-
-----
43+
.. tip::
4544

46-
.. click:: instrumentman:cli
47-
:prog: iman
45+
See the command help for all logging options.
46+
47+
.. code-block:: shell
48+
49+
iman -h

docs/commands/files/download.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Downloading
22
===========
33

4-
A useful file management feature is the ability to download a file from the
5-
instrument. The download command can be used to download a file identified
4+
A useful file management feature that gives the ability to download a file from
5+
the instrument. The download command can be used to download a file identified
66
by either a file name and type, or a full file path.
77

88
.. caution::

docs/commands/protocoltest/geocom.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ see what part of the protocol might be usable on the instrument.
66

77
.. note::
88

9-
The commands only does surface level testing by executing one command
9+
The command only does surface level testing by executing one command
1010
from each subsystem. The results are only informative, they might not be
1111
completely accurate. It might happen, that an instrument responds to the
1212
command used for testing, but does not actually respond to the other

docs/commands/targets/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Targets
55

66
To run a point measurement program, the targets first must be defined. This is
77
done in JSON format, providing the point IDs, prism types and their 3D
8-
coordinates in an arbitrary coordinate system. This application provdes ways
8+
coordinates in an arbitrary coordinate system. This application provides ways
99
to create such a definition.
1010

1111
.. note::

docs/commands/targets/measure.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@ aimed at.
1212
.. caution::
1313
:class: warning
1414

15-
The appropriate prism type needs to be set on the instrument before
16-
recording each target point. The program will automatically request
17-
the type from the instrument after the point is measured.
15+
The appropriate prism type and target height needs to be set on the
16+
instrument before recording each target point.
1817

1918
This is needed, because the automated measurement programs support target
2019
series with mixed reflector types. The prism types are set according to

src/instrumentman/__init__.py

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,43 @@ def cli(
5353
dateformat: str = "%Y-%m-%d %H:%M:%S",
5454
rotate: tuple[int, int] | None = None
5555
) -> None:
56-
"""Automated measurement programs and related utilities for surveying
57-
instruments."""
56+
"""
57+
\b
58+
+--------------------------------------------------------------------+
59+
| |
60+
| .---------. |
61+
| / +-------+ \\ |
62+
| .__| +---+ |__. |
63+
| | | | | | | ___ |
64+
| | |=| @ |=| | |_ _| _ __ ___ __ _ _ __ |
65+
| | | | | | | | | _____ | '_ ` _ \\ / _` | | '_ \\ |
66+
| | | +---+ | | | | |_____| | | | | | | | (_| | | | | | |
67+
| .+--+-------+--+. |___| |_| |_| |_| \\__,_| |_| |_| |
68+
| | .----. 123 | |
69+
| | |____| 456 | |
70+
| '_______________' |
71+
| |
72+
+--------------------------------------------------------------------+
73+
74+
Instrumentman (or I-man for short) is a collection of command line programs
75+
related to the automation of surveying instruments (primarily robotic total
76+
stations) through serial line command protocols (mainly Leica GeoCom).
77+
78+
The individual commands are available through their respective action
79+
based command groups. The help page for each command can be accessed
80+
through the -h/--help option. Logging can be set up with options of this
81+
root command.
82+
83+
Examples:
84+
85+
iman download file -h
86+
87+
iman --debug --file log.log measure inclination -o incline.csv -p 3 COM1
88+
89+
iman calc sets merged.json results.csv
90+
91+
iman terminal
92+
"""
5893
configure_logging(
5994
protocol,
6095
debug,

src/instrumentman/datatransfer/__init__.py

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,30 +26,45 @@
2626
@option(
2727
"-o",
2828
"--output",
29-
help="file to save received data",
29+
help="File to save received data",
3030
type=File("wb", encoding="utf8", lazy=True)
3131
)
3232
@option(
3333
"--eof",
34-
help="end-of-file marker (i.e. the last line to receive)",
34+
help="End-of-file marker (i.e. the last line to receive)",
3535
type=str,
3636
default=""
3737
)
3838
@option(
3939
"--autoclose/--no-autoclose",
40-
help="close transfer automatically upon timeout or when EOF is received",
40+
help="Close transfer automatically upon timeout or when EOF is received",
4141
default=True
4242
)
4343
@option(
4444
"--include-eof/--no-include-eof",
4545
help=(
46-
"wether the EOF marker is part of the output format "
46+
"Wether the EOF marker is part of the output format "
4747
"(or just sent by the instrument regardless of the format in question)"
4848
),
4949
default=False
5050
)
5151
def cli_download(**kwargs: Any) -> None:
52-
"""Receive data sent from the instrument."""
52+
"""
53+
Receive data sent from the instrument.
54+
55+
This command is intended to receive and save ASCII or extended ASCII
56+
documents line by line, such as typical data exports from instruments.
57+
58+
To sucessfully receive the data, the program has to be started before the
59+
instrument starts sending the lines.
60+
61+
Since not all ASCII export formats have an EOF marker, the download can be
62+
closed by two mechanisms if no marker is set. The process can be closed
63+
manually by keyboard interrupt once all data expected was received.
64+
Alternatively the process can close automatically at the first connection
65+
timeout (only if a first line was ever received, otherwise the program
66+
waits indefinitely and has to be interrupted manually).
67+
"""
5368
from .app import main_download
5469

5570
main_download(**kwargs)
@@ -63,20 +78,34 @@ def cli_download(**kwargs: Any) -> None:
6378
@com_port_argument()
6479
@argument(
6580
"file",
66-
help="data file to upload",
81+
help="Data file to upload",
6782
type=File("rt", encoding="ascii")
6883
)
6984
@com_baud_option(1200)
7085
@com_timeout_option()
7186
@option(
7287
"-s",
7388
"--skip",
74-
help="number of header rows to skip",
89+
help="Number of header rows to skip",
7590
type=IntRange(min=0),
7691
default=0
7792
)
7893
def cli_upload(**kwargs: Any) -> None:
79-
"""Upload ASCII data to the instrument."""
94+
"""
95+
Upload ASCII data to the instrument.
96+
97+
This command can be used to send ASCII data line by line to an instrument,
98+
that supports serial data transfer. Such data can be a CSV formatted
99+
coordinate list, or an instrument specific format type (e.g. Leica GSI,
100+
Sokkia SDR).
101+
102+
To ensure the successful reception of the data, it is recommended to use
103+
1200 baud. At higher speeds the instrument might not be able to process the
104+
data quickly enough, leading to the receiving buffer filling up, which will
105+
result in loss of data.
106+
107+
The instrument should be set to receiving mode before starting the upload.
108+
"""
80109
from .app import main_upload
81110

82111
main_upload(**kwargs)

src/instrumentman/filetransfer/__init__.py

Lines changed: 37 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@
2323
@com_port_argument()
2424
@argument(
2525
"directory",
26-
help="directory to list files in (path should end with '/')",
26+
help="Directory to list files in",
2727
type=str,
28-
default="/"
28+
default=""
2929
)
3030
@com_option_group()
3131
@option(
3232
"-d",
3333
"--device",
34-
help="memory device",
34+
help="Memory device",
3535
type=Choice(
3636
(
3737
"internal",
@@ -47,7 +47,7 @@
4747
@option(
4848
"-f",
4949
"--filetype",
50-
help="file type (ignored in recursive mode)",
50+
help="File type (all files are shown when not set)",
5151
type=Choice(
5252
(
5353
"image",
@@ -65,14 +65,26 @@
6565
@option(
6666
"--depth",
6767
help=(
68-
"recursive depth "
68+
"Recursive depth "
6969
"(0: unlimited; 1<=x: depth of directory search)"
7070
),
7171
type=IntRange(0),
7272
default=1
7373
)
7474
def cli_list(**kwargs: Any) -> None:
75-
"""List files on an instrument."""
75+
"""
76+
List files on an instrument.
77+
78+
For each file in the specified directory (and discovered subdirectories
79+
when recursive search is enabled) the file name, file size and the time of
80+
last modification is displayed. Not empty directories and items, that are
81+
likely directories are show in blue and light blue colors. Known text
82+
formats are shown green. Image and drawing formats are shown in magenta.
83+
Database files are red. Other files are shown without special color.
84+
85+
This command requires a GeoCom capable instrument, that supports file
86+
operations (TPS1200 and later).
87+
"""
7688
from .app import main_list
7789

7890
main_list(**kwargs)
@@ -87,21 +99,21 @@ def cli_list(**kwargs: Any) -> None:
8799
@argument(
88100
"filename",
89101
help=(
90-
"file to download (including path with '/' separators if filetype "
102+
"File to download (including path with '/' separators if filetype "
91103
"option is not specified)"
92104
),
93105
type=str
94106
)
95107
@argument(
96108
"output",
97-
help="file to save downloaded data to",
109+
help="File to save downloaded data to",
98110
type=File("wb", lazy=False)
99111
)
100112
@com_option_group()
101113
@option(
102114
"-d",
103115
"--device",
104-
help="memory device",
116+
help="Memory device",
105117
type=Choice(
106118
(
107119
"internal",
@@ -117,7 +129,7 @@ def cli_list(**kwargs: Any) -> None:
117129
@option(
118130
"-f",
119131
"--filetype",
120-
help="file type",
132+
help="File type (full file path is required if this option is not set)",
121133
type=Choice(
122134
(
123135
"image",
@@ -137,17 +149,27 @@ def cli_list(**kwargs: Any) -> None:
137149
@option(
138150
"-c",
139151
"--chunk",
140-
help="chunk size (max 450 for normal and 1800 for VivaTPS large download)",
141-
type=IntRange(1, 1800),
142-
default=450
152+
help="Chunk size (max. 225 for normal and 900 for large download mode)",
153+
type=IntRange(1, 900),
154+
default=225
143155
)
144156
@option(
145157
"--large",
146-
help="use large download commands (only available from VivaTPS)",
158+
help="Use large download commands (only available from VivaTPS)",
147159
is_flag=True
148160
)
149161
def cli_download(**kwargs: Any) -> None:
150-
"""Download a file from the instrument."""
162+
"""
163+
Download a file from the instrument.
164+
165+
Any format can be transferred. The file is downloaded in chunks of hex
166+
encoded binary data. The speed is strongly dependent on the connection
167+
baud and chunk size. Use the highest baud supported by the instrument, and
168+
the largest chunk size for the fastest download.
169+
170+
This command requires a GeoCom capable instrument, that supports file
171+
operations (TPS1200 and later).
172+
"""
151173
from .app import main_download
152174

153175
main_download(**kwargs)

src/instrumentman/filetransfer/app.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ def run_download(
250250
file: BufferedWriter,
251251
device: str = "internal",
252252
filetype: str = "unknown",
253-
chunk: int = 450,
253+
chunk: int = 225,
254254
large: bool = False
255255
) -> None:
256256
setup = tps.ftr.setup_download
@@ -266,7 +266,7 @@ def run_download(
266266
logger.debug(f"Download setup: large={str(large)}, chunk={chunk:d}")
267267
resp_setup = setup(
268268
filename,
269-
chunk,
269+
chunk * 2, # chunk size is in bytes, but command expects in hex chars
270270
_DEVICE[device],
271271
_FILE[filetype]
272272
)
@@ -307,7 +307,7 @@ def main_download(
307307
sync_after_timeout: bool = False,
308308
device: str = "internal",
309309
filetype: str = "unknown",
310-
chunk: int = 450,
310+
chunk: int = 225,
311311
large: bool = False
312312
) -> None:
313313
logger = getLogger("iman.files.download")

0 commit comments

Comments
 (0)