diff --git a/picamera_coverage.zip b/picamera_coverage.zip index a29f518f..16fdc312 100644 Binary files a/picamera_coverage.zip and b/picamera_coverage.zip differ diff --git a/src/openflexure_microscope_server/things/camera/__init__.py b/src/openflexure_microscope_server/things/camera/__init__.py index fe24bdc2..b43b8dd9 100644 --- a/src/openflexure_microscope_server/things/camera/__init__.py +++ b/src/openflexure_microscope_server/things/camera/__init__.py @@ -8,7 +8,6 @@ See repository root for licensing information. from __future__ import annotations -import asyncio import io import json import os @@ -338,11 +337,9 @@ class BaseCamera(OFMThing): # This runs as an async task, which we wait to complete try: - total_time, frames, samples = ( - self._thing_server_interface.call_async_task( - self._monitor_framerate, - duration, - ) + total_time, frames, samples = self._thing_server_interface.call_async_task( + self._monitor_framerate, + duration, ) finally: @@ -359,6 +356,13 @@ class BaseCamera(OFMThing): "samples": samples, } + self.logger.info( + ("Framerate monitor results: duration=%.2fs, frames=%d, avg_fps=%.2f"), + total_time, + frames, + avg_fps, + ) + with open(log_path, "w") as f: json.dump(data, f, indent=2) diff --git a/tests/hardware_specific_tests/picamera2/test_acquisition.py b/tests/hardware_specific_tests/picamera2/test_acquisition.py index 3609bdd7..7ac49e3a 100644 --- a/tests/hardware_specific_tests/picamera2/test_acquisition.py +++ b/tests/hardware_specific_tests/picamera2/test_acquisition.py @@ -1,7 +1,6 @@ """Test data collection from the Raspberry Picamera.""" import json -import time from pathlib import Path import numpy as np @@ -35,19 +34,12 @@ def test_jpeg_and_array(picamera_client): assert array_main.shape[1::-1] == jpeg_capture.size -def test_record_framerate_async(picamera_client): - """Check that asynchronous framerate monitoring creates a valid JSON log.""" - returned_dir = Path(picamera_client.record_framerate_async(duration=1.0)) +def test_record_framerate(picamera_client): + """Check that framerate monitoring creates a valid JSON log with good data.""" + log_file = Path(picamera_client.record_framerate(duration=1.0)) - # Wait slightly longer than recording duration for async task completion - time.sleep(1.5) - - log_files = list(returned_dir.glob("framerate_*.json")) - - # Ensure exactly one log file was created - assert len(log_files) == 1 - - log_file = log_files[0] + assert log_file.exists() + assert log_file.is_file() # Ensure file is not empty assert log_file.stat().st_size > 0 @@ -74,7 +66,6 @@ def test_record_framerate_async(picamera_client): sample = samples[0] - # Each sample row equivalent assert "timestamp" in sample assert "frame_count" in sample assert "frame_size_bytes" in sample