Skip to content

Guard log stream setup against missing TOC variables #800

@ataffanel

Description

@ataffanel

Problem

Several async log streaming methods (_stream_motors in FlightTab, _stream_battery in MainUI, _stream_loop in PoseLogger) add log variables unconditionally via block.add_variable(). If a variable is missing from the firmware's log TOC (e.g. due to firmware version differences or custom builds), this will raise an exception inside a create_task() coroutine, which can crash the tab or silently kill the streaming task.

Currently only supervisor.info has a TOC guard:

if self.LOG_NAME_SUPERVISOR_INFO in log.names():
    await block.add_variable(self.LOG_NAME_SUPERVISOR_INFO)

But other variables like sys.canfly, stabilizer.thrust, motor.m1-m4, pm.vbat, pm.state, and the stateEstimate.* pose variables are added without checking.

Suggestion

Add log.names() checks before adding variables, or wrap the setup in a try/except that gracefully disables the corresponding UI elements when variables are unavailable. This would make the client more robust against firmware variations.

Affected locations

  • src/cfclient/ui/tabs/FlightTab.py_stream_motors()
  • src/cfclient/ui/main.py_stream_battery()
  • src/cfclient/ui/pose_logger.py_stream_loop()

Context

Raised during Copilot review of PR #792.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions