mirror of
https://github.com/odriverobotics/ODrive.git
synced 2026-09-23 17:13:47 +08:00
allow setting interactive shell variables, fix some warnings
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
|
||||
from fibre.discovery import find_any, find_all
|
||||
from fibre.utils import Event, Logger
|
||||
from fibre.protocol import ChannelBrokenException, ChannelDamagedException
|
||||
from fibre.shell import launch_shell
|
||||
from .discovery import find_any, find_all
|
||||
from .utils import Event, Logger
|
||||
from .protocol import ChannelBrokenException, ChannelDamagedException
|
||||
from .shell import launch_shell
|
||||
|
||||
@@ -4,10 +4,10 @@ import platform
|
||||
import threading
|
||||
import fibre
|
||||
|
||||
interactive_variables = {}
|
||||
discovered_devices = []
|
||||
|
||||
def did_discover_device(device, branding_short, branding_long, logger, app_shutdown_token):
|
||||
def did_discover_device(device,
|
||||
interactive_variables, discovered_devices,
|
||||
branding_short, branding_long,
|
||||
logger, app_shutdown_token):
|
||||
"""
|
||||
Handles the discovery of new devices by displaying a
|
||||
message and making the device available to the interactive
|
||||
@@ -40,6 +40,7 @@ def did_lose_device(interactive_name, logger, app_shutdown_token):
|
||||
logger.warn("Oh no {} disappeared".format(interactive_name))
|
||||
|
||||
def launch_shell(args,
|
||||
interactive_variables,
|
||||
print_banner, print_help,
|
||||
logger, app_shutdown_token,
|
||||
branding_short="dev", branding_long="device"):
|
||||
@@ -51,10 +52,13 @@ def launch_shell(args,
|
||||
The names of the variables can be customized by setting branding_short.
|
||||
"""
|
||||
|
||||
discovered_devices = []
|
||||
globals().update(interactive_variables)
|
||||
|
||||
# Connect to device
|
||||
logger.debug("Waiting for {}...".format(branding_long))
|
||||
fibre.find_all(args.path, args.serial_number,
|
||||
lambda dev: did_discover_device(dev, branding_short, branding_long, logger, app_shutdown_token),
|
||||
lambda dev: did_discover_device(dev, interactive_variables, discovered_devices, branding_short, branding_long, logger, app_shutdown_token),
|
||||
app_shutdown_token,
|
||||
app_shutdown_token,
|
||||
logger=logger)
|
||||
|
||||
@@ -25,7 +25,7 @@ class UDPTransport(fibre.protocol.PacketSource, fibre.protocol.PacketSink):
|
||||
|
||||
def get_packet(self, deadline):
|
||||
# TODO: implement deadline
|
||||
data, addr = self.sock.recvfrom(1024)
|
||||
data, _ = self.sock.recvfrom(1024)
|
||||
return data
|
||||
|
||||
def discover_channels(path, serial_number, callback, cancellation_token, channel_termination_token, logger):
|
||||
|
||||
Reference in New Issue
Block a user