|
46 | 46 | parser.add_option("-n", "--no-increment", dest="increment", |
47 | 47 | action="store_false", |
48 | 48 | 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) |
49 | 52 | parser.add_option("-r", "--read", type="int", dest="read", default=None, |
50 | 53 | help="Number of bytes to read") |
51 | 54 | 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): |
109 | 112 |
|
110 | 113 | if options.read: |
111 | 114 | 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) |
114 | 118 | print(">", command.hex()) |
115 | 119 | transact(command) |
116 | 120 |
|
117 | 121 | elif options.write: |
118 | 122 | if options.address is None: raise SystemExit("--write must specify --address") |
119 | 123 | 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) |
122 | 127 | print(">", command.hex()) |
123 | 128 | transact(command, response=False) |
124 | 129 |
|
|
0 commit comments