Skip to content

Commit

Permalink
🔖 Release 3.4.0 (#225)
Browse files Browse the repository at this point in the history
* 🐛 emit correct compiler for C files when generating CDB (#188)

* Update Azure Pipelines with new self hosted M1 Mac (#189)

* Update azure-pipelines.yml for Azure Pipelines

* Update azure-pipelines.yml

* Update azure-pipelines.yml for Azure Pipelines

* Update azure-pipelines.yml for Azure Pipelines

* Fixes 'make.exe.exe' typo. Adds disable sentry prompt option for VSCode. (#190)

* Fixes 'make.exe.exe' typo. Adds disable sentry prompt option for VSCode.

* Fix sentry-off flag

* change sentry-off to no-sentry

* Update Version (#186) (#191)

* ✨Add Analytics (#193)

* Fix and move no-sentry to default options. Setup framework for analytics

* Fix some things. --toggle-analytics works

* Analytics should be working. Need to figure out which commands matter

* Make use-analytics a choice not a toggle

* Show no-analytics flag feedback so user knows it works

* Analytics appear to be working!

* Reset uid to None

* Compress code a bit

* Remove interactive command analytics. Fix info-project typo

* Move GA config to cli.pros. Fixes --use-analytics

* ✨More Upload Options (#194)

* Start of more upload options

* Adds project icon, name, and description. Use name/description="string"

* pros v5 rm-program command

* rm program literals

* Remove extra print messages. Kernel version = None when no project

* Update Version (#186) (#195)

* Add __init__ file so ga is considered a module (#206)

* Fix issue with programs uploading segfaulting/NACKing/doing nothing (#207)

* ✨Set team number and robot name (#210)

* Adds kv_read and kv_write functions (UNTESTED) to V5Device class

* Add commands to read and set kernel variables

* Add descriptions to set_variable and read_variable commands

* Finish reading kernel variables. Use None for unknown rx length

* Trim kernel variable value and ensure null terminated.

* Move rv and sv to v5 commands

* Working set command. Maximum lengths based on brain's screen space

* get and set aliases

* Add m as an alias for pros make. (#204)

* Cleaned Up CI (#213)

* Update azure-pipelines.yml for Azure Pipelines

* Update azure-pipelines.yml for Azure Pipelines

* Update azure-pipelines.yml for Azure Pipelines

* Update azure-pipelines.yml for Azure Pipelines

* Update azure-pipelines.yml for Azure Pipelines

* Update azure-pipelines.yml for Azure Pipelines

* Update azure-pipelines.yml for Azure Pipelines

* Update azure-pipelines.yml for Azure Pipelines

* Update azure-pipelines.yml for Azure Pipelines

* Update azure-pipelines.yml for Azure Pipelines

* Update azure-pipelines.yml for Azure Pipelines

* Update azure-pipelines.yml for Azure Pipelines

* Revert "✨Set team number and robot name (#210)" (#214)

This reverts commit 62ee4b8.

* ✨Set team number and robot name (#219)

* old code (not working)

* use correct txrx function

* return set value

* ✨Terminal file output (#220)

* Added file redirect click.option to terminal.py

* Got rid of indentation error

* Added code for output

* Redirects standard output stream to file

* Outputs to both terminal and file

* Modified imported modules

* Added line at end

* changes on windows

* Update pros/cli/terminal.py for terminal file output

Co-authored-by: Will Xu <[email protected]>

* Removed ident error

Co-authored-by: BennyBot <[email protected]>

Co-authored-by: Will Xu <[email protected]>
Co-authored-by: Benjamin Davis <[email protected]>
Co-authored-by: Will Xu <[email protected]>
Co-authored-by: BennyBot <[email protected]>

Co-authored-by: Alex Brooke <[email protected]>
Co-authored-by: BennyBot <[email protected]>
Co-authored-by: Benjamin Davis <[email protected]>
Co-authored-by: sharmaneha03 <[email protected]>
Co-authored-by: Will Xu <[email protected]>
Co-authored-by: Will Xu <[email protected]>
  • Loading branch information
7 people authored Aug 25, 2022
1 parent 62758e9 commit bdbc6e2
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 1 deletion.
30 changes: 29 additions & 1 deletion pros/cli/terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import time

import click
import sys

import pros.conductor as c
import pros.serial.devices as devices
Expand All @@ -29,6 +30,8 @@ def terminal_cli():
help='Specify 2 ports for the "share" backend. The default option deterministically selects ports '
'based on the serial port name')
@click.option('--banner/--no-banner', 'request_banner', default=True)
@click.option('--output', nargs = 1, type=str, is_eager = True, help='Redirect terminal output to a file', default=None)

def terminal(port: str, backend: str, **kwargs):
"""
Open a terminal to a serial port
Expand All @@ -39,7 +42,7 @@ def terminal(port: str, backend: str, **kwargs):
may be preferred when "share" doesn't perform adequately.
Note: share backend is not yet implemented.
"""
"""
analytics.send("terminal")
from pros.serial.devices.vex.v5_user_device import V5UserDevice
from pros.serial.terminal import Terminal
Expand Down Expand Up @@ -82,9 +85,34 @@ def terminal(port: str, backend: str, **kwargs):
device = devices.vex.V5UserDevice(ser)
term = Terminal(device, request_banner=kwargs.pop('request_banner', True))

class TerminalOutput(object):
def __init__(self, file):
self.terminal = sys.stdout
self.log = open(file, 'a')
def write(self, data):
self.terminal.write(data)
self.log.write(data)
def flush(self):
pass
def end(self):
self.log.close()

output = None
if kwargs.get('output', None):
output_file = kwargs['output']
output = TerminalOutput(f'{output_file}')
term.console.output = output
sys.stdout = output
logger(__name__).info(f'Redirecting Terminal Output to File: {output_file}')
else:
sys.stdout = sys.__stdout__

signal.signal(signal.SIGINT, term.stop)
term.start()
while not term.alive.is_set():
time.sleep(0.005)
sys.stdout = sys.__stdout__
if output:
output.end()
term.join()
logger(__name__).info('CLI Main Thread Dying')
31 changes: 31 additions & 0 deletions pros/cli/v5_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,3 +290,34 @@ def capture(file_name: str, port: str, force: bool = False):
w.write(file_, i_data)

print(f'Saved screen capture to {file_name}')

@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)
@default_options
def set_variable(variable, value):
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]
if port == None:
return
device = vex.V5Device(DirectPort(port))
actual_value = device.kv_write(variable, value).decode()
print(f'Value of \'{variable}\' set to : {actual_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)
@default_options
def read_variable(variable):
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]
if port == None:
return
device = vex.V5Device(DirectPort(port))
value = device.kv_read(variable).decode()
print(f'Value of \'{variable}\' is : {value}')
30 changes: 30 additions & 0 deletions pros/serial/devices/vex/v5_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -892,6 +892,36 @@ def sc_init(self) -> None:
self._txrx_ext_struct(0x28, [], '')
logger(__name__).debug('Completed ext 0x28 command')

@retries
def kv_read(self, kv: str) -> bytearray:
logger(__name__).debug('Sending ext 0x2e command')
encoded_kv = f'{kv}\0'.encode(encoding='ascii')
tx_payload = struct.pack(f'<{len(encoded_kv)}s', encoded_kv)
# Because the length of the kernel variables is not known, use None to indicate we are recieving an unknown length.
ret = self._txrx_ext_packet(0x2e, tx_payload, 1, check_length=False, check_ack=True)
logger(__name__).debug('Completed ext 0x2e command')
return ret

@retries
def kv_write(self, kv: str, payload: Union[Iterable, bytes, bytearray, str]):
logger(__name__).debug('Sending ext 0x2f command')
encoded_kv = f'{kv}\0'.encode(encoding='ascii')
kv_to_max_bytes = {
'teamnumber': 7,
'robotname': 16
}
if len(payload) > kv_to_max_bytes.get(kv, 254):
print(f'Truncating input to meet maximum value length ({kv_to_max_bytes[kv]} characters).')
# Trim down size of payload to fit within the 255 byte limit and add null terminator.
payload = payload[:kv_to_max_bytes.get(kv, 254)] + "\0"
if isinstance(payload, str):
payload = payload.encode(encoding='ascii')
tx_fmt =f'<{len(encoded_kv)}s{len(payload)}s'
tx_payload = struct.pack(tx_fmt, encoded_kv, payload)
ret = self._txrx_ext_packet(0x2f, tx_payload, 1, check_length=False, check_ack=True)
logger(__name__).debug('Completed ext 0x2f command')
return payload

def _txrx_ext_struct(self, command: int, tx_data: Union[Iterable, bytes, bytearray],
unpack_fmt: str, check_length: bool = True, check_ack: bool = True,
timeout: Optional[float] = None) -> Tuple:
Expand Down

0 comments on commit bdbc6e2

Please sign in to comment.