Skip to content

Commit

Permalink
CG-526: support new --poll option for polling a single configuration …
Browse files Browse the repository at this point in the history
…item multiple times
  • Loading branch information
Liam Wickins committed Nov 30, 2023
1 parent 4e5353c commit 9d67a32
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
5 changes: 5 additions & 0 deletions pylinkit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,8 @@ def scalw(self, sensor, step, value=0):

def argostx(self, mod, power, freq, size, tcxo):
self._dte.argostx(mod, power, freq, size, tcxo)

def poll(self, key, repetitions=1):
for i in range(repetitions):
result = self._dte.parmr([key])
print(result)
12 changes: 9 additions & 3 deletions pylinkit/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
parser.add_argument('--erase', type=str, choices=erase_options, required=False, help='Erase log file')
parser.add_argument('--device', type=str, required=False, help='xx:xx:xx:xx:xx:xx BLE device address')
parser.add_argument('--parmr', type=argparse.FileType('w'), required=False, help='Filename to write [PARAM] configuration to')
parser.add_argument('--poll', type=str, required=False, help='Poll a parameter value by key and use --value to denote repetitions')
parser.add_argument('--rstvw', type=str, choices=resetv_options.keys(), required=False, help='Reset variable: tx_counter or rx_counter')
parser.add_argument('--rstbw', action='store_true', required=False, help='Reset beacon')
parser.add_argument('--factw', action='store_true', required=False, help='Factory reset (WARNING: erases all stored logs and configuration!)')
Expand Down Expand Up @@ -87,6 +88,9 @@ def main():
cfg.write(args.parmr)
args.parmr.close()

if args.poll and args.value is not None:
dev.poll(args.poll, int(args.value))

if args.parmw:
cfg = OrderedRawConfigParser()
cfg.optionxform = lambda option: option
Expand Down Expand Up @@ -152,16 +156,18 @@ def main():
rtd::
--scalw rtd --command 0 ; reset RTD calibration
--scalw rtd --command 0 ; reset RTD calibration, wakeup device
--scalw rtd --command 1 ; perform 0C calibration
--scalw rtd --command 2 ; perform 100C calibration
--scalw rtd --command 3 ; put device back into sleep mode
mcp47x6::
--scalw mcp47x6 --command 0 ; reset mcp47x6 calibration
--scalw mcp47x6 --command 350 --value 2345 ; calibration point for DAC for 350 mW power
--scalw mcp47x6 --command 500 --value 2645 ; calibration point for DAC for 500 mW power
--scalw mcp47x6 --command 1 ; save mcp47x6 calibration to file
Note: use in conjunction with --argostx to send a packet at calibrated mW
""")
Expand Down

0 comments on commit 9d67a32

Please sign in to comment.