mirror of
https://github.com/odriverobotics/ODrive.git
synced 2026-09-22 16:14:37 +08:00
update libfibre
This commit is contained in:
+18
-7
@@ -31,13 +31,24 @@ all:
|
||||
@tup --quiet --no-environ-check
|
||||
@$(PY_CMD) interface_generator_stub.py --definitions odrive-interface.yaml --template ../tools/enums_template.j2 --output ../tools/odrive/enums.py
|
||||
|
||||
fibre:
|
||||
(cd fibre-cpp && tup --no-environ-check)
|
||||
! ls fibre-cpp/*.so 2>&1 > /dev/null || cp fibre-cpp/build-local/*.so ../tools/odrive/pyfibre/fibre/
|
||||
! ls fibre-cpp/*.dylib 2>&1 > /dev/null || cp fibre-cpp/build-local/*.dylib ../tools/odrive/pyfibre/fibre/
|
||||
! ls fibre-cpp/*.dll 2>&1 > /dev/null || cp fibre-cpp/build-local/*.dll ../tools/odrive/pyfibre/fibre/
|
||||
#(cd fibre-cpp && tup --no-environ-check build-linux-armhf)
|
||||
#cp fibre-cpp/build-linux-armhf/libfibre-linux-armhf.so ../tools/odrive/pyfibre/fibre/
|
||||
# Copy libfibre files to odrivetool if they were built
|
||||
@ ! compgen -G "fibre-cpp/build/libfibre-*.so" > /dev/null || cp fibre-cpp/build/libfibre-*.so ../tools/odrive/pyfibre/fibre/
|
||||
@ ! compgen -G "fibre-cpp/build/libfibre-*.dylib" > /dev/null || cp fibre-cpp/build/libfibre-*.dylib ../tools/odrive/pyfibre/fibre/
|
||||
@ ! compgen -G "fibre-cpp/build/libfibre-*.dll" > /dev/null || cp fibre-cpp/build/libfibre-*.dll ../tools/odrive/pyfibre/fibre/
|
||||
|
||||
libfibre-linux-armhf:
|
||||
docker run -it -v "`pwd`/fibre-cpp":/build -v /tmp/fibre-linux-armhf-build:/build/build -w /build fibre-compiler configs/linux-armhf.config
|
||||
cp /tmp/fibre-linux-armhf-build/libfibre-*.so ../tools/odrive/pyfibre/fibre/
|
||||
|
||||
libfibre-all:
|
||||
docker run -it -v "`pwd`/fibre-cpp":/build -v /tmp/libfibre-build:/build/build -w /build fibre-compiler configs/linux-amd64.config
|
||||
cp /tmp/libfibre-build/libfibre-linux-amd64.so ../tools/odrive/pyfibre/fibre/
|
||||
docker run -it -v "`pwd`/fibre-cpp":/build -v /tmp/libfibre-build:/build/build -w /build fibre-compiler configs/linux-armhf.config
|
||||
cp /tmp/libfibre-build/libfibre-linux-armhf.so ../tools/odrive/pyfibre/fibre/
|
||||
docker run -it -v "`pwd`/fibre-cpp":/build -v /tmp/libfibre-build:/build/build -w /build fibre-compiler configs/macos-x86.config
|
||||
cp /tmp/libfibre-build/libfibre-macos-x86.dylib ../tools/odrive/pyfibre/fibre/
|
||||
docker run -it -v "`pwd`/fibre-cpp":/build -v /tmp/libfibre-build:/build/build -w /build fibre-compiler configs/windows-amd64.config
|
||||
cp /tmp/libfibre-build/libfibre-windows-amd64.dll ../tools/odrive/pyfibre/fibre/
|
||||
|
||||
clean:
|
||||
-rm -fR .dep $(BUILD_DIR)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
|
||||
-- Prevent tup from running `Firmware/fibre-cpp/Tupfile.lua` when we run it in
|
||||
-- the `Firmware` folder.
|
||||
no_libfibre = true
|
||||
no_libfibre = tup.getconfig("BUILD_LIBFIBRE") != "true"
|
||||
|
||||
@@ -284,11 +284,14 @@ On Ubuntu 18.04, prerequisites are: `ruby ruby-dev zlib1g-dev`.
|
||||
|
||||
## Modifying libfibre
|
||||
|
||||
If you need to modify libfibre run `make fibre` in the `Firmware` directory. If
|
||||
you now run odrivetool from the repository it should use the new libfibre binary.
|
||||
If you need to modify libfibre add `CONFIG_BUILD_LIBFIBRE=true` to your tup.config and rerun `make`. After this you can start `odrivetool` (on your local PC) and it will use the updated libfibre.
|
||||
|
||||
To cross-compile libfibre for the Raspberry Pi, run `make libfibre-linux-armhf` or `make libfibre-all`. This will require a docker container. See [fibre-cpp readme](../Firmware/fibre-cpp/README.md) for details.
|
||||
|
||||
docker run -it -v "$(pwd)":/build -v /tmp/build:/build/build -w /build fibre-compiler configs/linux-armhf.config
|
||||
|
||||
If you're satisfied with the changes don't forget to generate binaries for all
|
||||
supported systems. See [Releases](#releases) for more info.
|
||||
supported systems using `make libfibre-all`.
|
||||
|
||||
## Releases
|
||||
|
||||
@@ -297,7 +300,7 @@ We use GitHub Releases to provide firmware releases.
|
||||
1. Cut off the changelog to reflect the new release
|
||||
2. Merge the release candidate into master.
|
||||
3. Push a (lightweight) tag to the master branch. Follow the existing naming convention.
|
||||
4. If you changed something in libfibre, regenerate the binaries using `Firmware/fibre-cpp/compile_for_all_platforms.sh` and then copy all resulting `*.so`, `*.dll` and `*.dylib` files to `tools/odrive/pyfibre/fibre/`.
|
||||
4. If you changed something in libfibre, regenerate the binaries using `make libfibre-all`. See [Modifying libfibre](#modifying-libfibre) for details.
|
||||
5. Push the python tools to PyPI (see setup.py for details).
|
||||
6. Edit the release on GitHub to add a title and description (copy&paste from changelog).
|
||||
|
||||
|
||||
@@ -45,7 +45,6 @@ parser.set_defaults(path="usb,tcp:localhost:9910")
|
||||
args = parser.parse_args()
|
||||
|
||||
logger = Logger(verbose=args.verbose)
|
||||
app_shutdown_token = Event()
|
||||
|
||||
def print_banner():
|
||||
pass
|
||||
@@ -54,4 +53,4 @@ def print_help(args, have_devices):
|
||||
pass
|
||||
|
||||
import fibre
|
||||
fibre.launch_shell(args, {}, print_banner, print_help, logger, app_shutdown_token)
|
||||
fibre.launch_shell(args, {}, print_banner, print_help, logger)
|
||||
|
||||
+23
-22
@@ -14,41 +14,42 @@ __version__ = get_version_str()
|
||||
del get_version_str
|
||||
|
||||
from .utils import get_serial_number_str
|
||||
import threading
|
||||
|
||||
default_search_path = 'usb:idVendor=0x1209,idProduct=0x0D32,bInterfaceClass=0,bInterfaceSubClass=1,bInterfaceProtocol=0'
|
||||
|
||||
def find_any(path=default_search_path, serial_number=None,
|
||||
search_cancellation_token=None, channel_termination_token=None,
|
||||
timeout=None, logger=fibre.Logger(verbose=False), find_multiple=False):
|
||||
timeout=None, logger=fibre.Logger(verbose=False)):
|
||||
"""
|
||||
Blocks until the first matching ODrive object is connected and then returns that object
|
||||
"""
|
||||
|
||||
result = []
|
||||
|
||||
done_signal = fibre.Event(search_cancellation_token)
|
||||
def did_discover_object(obj):
|
||||
channel_termination_token = fibre.Event(channel_termination_token)
|
||||
|
||||
async def discovered_object(obj):
|
||||
if not (serial_number is None) and ((await get_serial_number_str(obj)) != serial_number):
|
||||
return # ignore this device
|
||||
|
||||
obj._on_lost.add_done_callback(lambda x: channel_termination_token.set())
|
||||
result.append(obj)
|
||||
if find_multiple:
|
||||
if len(result) >= int(find_multiple):
|
||||
done_signal.set()
|
||||
else:
|
||||
done_signal.set()
|
||||
done_signal.set()
|
||||
|
||||
async def obj_filter(obj):
|
||||
return (serial_number is None or
|
||||
(await get_serial_number_str(obj)) == serial_number)
|
||||
|
||||
fibre.start_discovery(path, obj_filter, did_discover_object,
|
||||
done_signal, channel_termination_token, logger)
|
||||
def domain_thread():
|
||||
with fibre.Domain(path) as domain:
|
||||
discovery = domain.run_discovery(discovered_object)
|
||||
channel_termination_token.wait()
|
||||
discovery.stop()
|
||||
|
||||
threading.Thread(target=domain_thread).start()
|
||||
|
||||
try:
|
||||
done_signal.wait(timeout=timeout)
|
||||
except TimeoutError:
|
||||
if not find_multiple:
|
||||
return None
|
||||
finally:
|
||||
done_signal.set() # terminate find_all
|
||||
except:
|
||||
channel_termination_token.set()
|
||||
raise
|
||||
|
||||
if find_multiple:
|
||||
return result
|
||||
else:
|
||||
return result[0] if len(result) > 0 else None
|
||||
return result[0]
|
||||
|
||||
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -53,7 +53,7 @@ def benchmark(odrv):
|
||||
|
||||
fibre.libfibre.libfibre.loop.call_soon_threadsafe(lambda: asyncio.ensure_future(measure_async()))
|
||||
|
||||
def launch_shell(args, logger, app_shutdown_token):
|
||||
def launch_shell(args, logger):
|
||||
"""
|
||||
Launches an interactive python or IPython command line
|
||||
interface.
|
||||
@@ -79,12 +79,13 @@ def launch_shell(args, logger, app_shutdown_token):
|
||||
# Expose all enums from odrive.enums
|
||||
interactive_variables.update({k: v for (k, v) in odrive.enums.__dict__.items() if not k.startswith("_")})
|
||||
|
||||
async def obj_filter(obj):
|
||||
return (args.serial_number is None or
|
||||
(await odrive.utils.get_serial_number_str(obj)) == args.serial_number)
|
||||
async def mount(obj):
|
||||
serial_number_str = await odrive.utils.get_serial_number_str(obj)
|
||||
if ((not args.serial_number is None) and (serial_number_str != args.serial_number)):
|
||||
return None # reject this object
|
||||
return ("ODrive " + serial_number_str, "odrv")
|
||||
|
||||
fibre.launch_shell(args, obj_filter,
|
||||
fibre.launch_shell(args, mount,
|
||||
interactive_variables,
|
||||
print_banner, print_help,
|
||||
logger, app_shutdown_token,
|
||||
branding_short="odrv", branding_long="ODrive")
|
||||
logger)
|
||||
|
||||
+1
-1
@@ -140,7 +140,7 @@ try:
|
||||
print(" or better yet, submit a pull request to fix it.")
|
||||
print("")
|
||||
import odrive.shell
|
||||
odrive.shell.launch_shell(args, logger, app_shutdown_token)
|
||||
odrive.shell.launch_shell(args, logger)
|
||||
|
||||
elif args.command == 'dfu':
|
||||
print_version()
|
||||
|
||||
Reference in New Issue
Block a user