diff --git a/demos/python/sdk_wireless_camera_control/open_gopro/demos/gui/webcam.py b/demos/python/sdk_wireless_camera_control/open_gopro/demos/gui/webcam.py index 24233237..5e090628 100644 --- a/demos/python/sdk_wireless_camera_control/open_gopro/demos/gui/webcam.py +++ b/demos/python/sdk_wireless_camera_control/open_gopro/demos/gui/webcam.py @@ -5,6 +5,7 @@ import argparse import asyncio +import sys from typing import Final from rich.console import Console @@ -39,6 +40,7 @@ async def poll_for_status() -> bool: response = (await gopro.http_command.webcam_status()).data if response.error != WebcamError.SUCCESS: # Something bad happened + console.print(f"[yellow]Received webcam error: {response.error}") return False if response.status in statuses: # We found the desired status @@ -51,7 +53,7 @@ async def poll_for_status() -> bool: return False -async def main(args: argparse.Namespace) -> None: +async def main(args: argparse.Namespace) -> int: logger = setup_logging(__name__, args.log) gopro: GoProBase | None = None @@ -79,7 +81,9 @@ async def main(args: argparse.Namespace) -> None: await wait_for_webcam_status(gopro, {WebcamStatus.OFF}) console.print("[blue]Starting webcam...") - await gopro.http_command.webcam_start() + if (status := (await gopro.http_command.webcam_start()).data.error) != WebcamError.SUCCESS: + console.print(f"[red]Couldn't start webcam: {status}") + return -1 await wait_for_webcam_status(gopro, {WebcamStatus.HIGH_POWER_PREVIEW}) # Start player @@ -97,6 +101,8 @@ async def main(args: argparse.Namespace) -> None: if gopro: await gopro.close() + return 0 + def parse_arguments() -> argparse.Namespace: parser = argparse.ArgumentParser(description="Setup and view a GoPro webcam using TS protocol.") @@ -117,7 +123,7 @@ def parse_arguments() -> argparse.Namespace: # Needed for poetry scripts defined in pyproject.toml def entrypoint() -> None: - asyncio.run(main(parse_arguments())) + sys.exit(asyncio.run(main(parse_arguments()))) if __name__ == "__main__": diff --git a/demos/python/tutorial/tutorial_modules/tutorial_6_connect_wifi/connect_as_sta.py b/demos/python/tutorial/tutorial_modules/tutorial_6_connect_wifi/connect_as_sta.py index be97f628..c7effa85 100644 --- a/demos/python/tutorial/tutorial_modules/tutorial_6_connect_wifi/connect_as_sta.py +++ b/demos/python/tutorial/tutorial_modules/tutorial_6_connect_wifi/connect_as_sta.py @@ -29,9 +29,7 @@ def yield_fragmented_packets(payload: bytes) -> Generator[bytes, None, None]: is_first_packet = True # Build initial length header - if length < (2**5 - 1): - header = bytearray([length]) - elif length < (2**13 - 1): + if length < (2**13 - 1): header = bytearray((length | 0x2000).to_bytes(2, "big", signed=False)) elif length < (2**16 - 1): header = bytearray((length | 0x6400).to_bytes(2, "big", signed=False))