Skip to content

Commit

Permalink
Add port selection to set_variable and read_variable (#259)
Browse files Browse the repository at this point in the history
  • Loading branch information
ayushuk authored Jan 24, 2023
1 parent 4d0bb49 commit 0caacd1
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions pros/cli/v5_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,13 +294,14 @@ def capture(file_name: str, port: str, force: bool = False):
@v5.command(aliases=['sv', 'set'], short_help='Set a kernel variable on a connected V5 device')
@click.argument('variable', type=click.Choice(['teamnumber', 'robotname']), required=True)
@click.argument('value', required=True, type=click.STRING, nargs=1)
@click.argument('port', type=str, default=None, required=False)
@default_options
def set_variable(variable, value):
def set_variable(variable, value, port):
import pros.serial.devices.vex as vex
from pros.serial.ports import DirectPort

# Get the connected v5 device
port = resolve_v5_port(None, 'system')[0]
port = resolve_v5_port(port, 'system')[0]
if port == None:
return
device = vex.V5Device(DirectPort(port))
Expand All @@ -309,13 +310,14 @@ def set_variable(variable, value):

@v5.command(aliases=['rv', 'get'], short_help='Read a kernel variable from a connected V5 device')
@click.argument('variable', type=click.Choice(['teamnumber', 'robotname']), required=True)
@click.argument('port', type=str, default=None, required=False)
@default_options
def read_variable(variable):
def read_variable(variable, port):
import pros.serial.devices.vex as vex
from pros.serial.ports import DirectPort

# Get the connected v5 device
port = resolve_v5_port(None, 'system')[0]
port = resolve_v5_port(port, 'system')[0]
if port == None:
return
device = vex.V5Device(DirectPort(port))
Expand Down

0 comments on commit 0caacd1

Please sign in to comment.