Skip to content

Commit 51d6284

Browse files
committed
elbpcom: add a --size argument
Normally elbpcom looks up the preferred transfer size of the selected memory space in the memory space's info area. Specifying the transfer size on the command line makes elbpcom skip this step, and use the specified size directly.
1 parent 31a4645 commit 51d6284

2 files changed

Lines changed: 17 additions & 4 deletions

File tree

docs/man/man1/elbpcom.1

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Common options:
1010
.BI [\-\-port= PORT ]
1111
.BI [\-\-timeout= TIMEOUT ]
1212
.BI [\-\-space= MEMSPACE ]
13+
.BI [\-\-size= TRANSFER_SIZE ]
1314
.RE
1415

1516
Reading data:
@@ -54,8 +55,15 @@ If not specified, the default values are
5455
.BI \-\-port= 27181
5556
.BI \-\-timeout= .2
5657
.BI \-\-space= 0
58+
.BI \-\-size= 0
5759
.RE
5860

61+
If the
62+
.B --size
63+
argument
64+
.I TRANSFER_SIZE
65+
is 0, elbpcom will look up the preferred transfer size of the space in the space's info area.
66+
5967
This example demonstrates reading the HOSTMOT2 identifying string from the
6068
IDROM in space 0:
6169
.RS

src/hal/utils/elbpcom.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@
4646
parser.add_option("-n", "--no-increment", dest="increment",
4747
action="store_false",
4848
help="do not auto-increment address")
49+
parser.add_option("--size", dest="size",
50+
help="Transfer size in number of bytes (default: look up preferred transfer size in the space's info area)",
51+
type="int", default=0)
4952
parser.add_option("-r", "--read", type="int", dest="read", default=None,
5053
help="Number of bytes to read")
5154
parser.add_option("-w", "--write", type="string", dest="write", default=None,
@@ -109,16 +112,18 @@ def optimal_size(space:int, info:bool, address:int, nbytes:int):
109112

110113
if options.read:
111114
if options.address is None: raise SystemExit("--read must specify --address")
112-
size = optimal_size(options.space, options.info, options.address, options.read if options.increment else 0)
113-
command = make_read_request(options.space, options.info, size, options.increment, options.address, options.read)
115+
if options.size == 0:
116+
options.size = optimal_size(options.space, options.info, options.address, options.read if options.increment else 0)
117+
command = make_read_request(options.space, options.info, options.size, options.increment, options.address, options.read)
114118
print(">", command.hex())
115119
transact(command)
116120

117121
elif options.write:
118122
if options.address is None: raise SystemExit("--write must specify --address")
119123
write = bytes.fromhex(options.write)
120-
size = optimal_size(options.space, options.info, options.address, len(write) if options.increment else 0)
121-
command = make_write_request(options.space, options.info, size, options.increment, options.address, write)
124+
if options.size == 0:
125+
options.size = optimal_size(options.space, options.info, options.address, len(write) if options.increment else 0)
126+
command = make_write_request(options.space, options.info, options.size, options.increment, options.address, write)
122127
print(">", command.hex())
123128
transact(command, response=False)
124129

0 commit comments

Comments
 (0)