Skip to content

Commit 448d8e6

Browse files
committed
✨ Collect logs for the new OctoPi camera stack
1 parent cbe1ef1 commit 448d8e6

File tree

4 files changed

+153
-5
lines changed

4 files changed

+153
-5
lines changed

octoprint_pi_support/__init__.py

Lines changed: 70 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,50 @@
1717
_PROC_DT_MODEL_PATH = "/proc/device-tree/model"
1818
_OCTOPI_VERSION_PATH = "/etc/octopi_version"
1919
_OCTOPIUPTODATE_BUILD_PATH = "/etc/octopiuptodate_build"
20+
_NEW_CAMERA_STACK_PATH = "/etc/systemd/system/[email protected]"
2021
_VCGENCMD_THROTTLE = "/usr/bin/vcgencmd get_throttled"
2122
_SSHWARN_PATH = "/run/sshwarn"
2223

2324
_CHECK_INTERVAL_OK = 300
2425
_CHECK_INTERVAL_THROTTLED = 30
2526

27+
28+
def _gather_new_camerastack_files():
29+
import logging
30+
31+
files = {}
32+
33+
try:
34+
os.system(
35+
"journalctl --boot -u 'camera-streamer*' > /tmp/camerastack-journal.log"
36+
)
37+
files["camerastack-journal.log"] = "/tmp/camerastack-journal.log"
38+
except Exception:
39+
logging.getLogger(__name__).exception(
40+
"Failed to create camerastack-journal.log file"
41+
)
42+
43+
try:
44+
os.system(
45+
"/usr/bin/libcamera-hello --list-cameras > /tmp/camerastack-libcamera.log"
46+
)
47+
files["camerastack-libcamera.log"] = "/tmp/camerastack-libcamera.log"
48+
except Exception:
49+
logging.getLogger(__name__).exception(
50+
"Failed to create camerastack-libcamera.log file"
51+
)
52+
53+
try:
54+
os.system("/usr/bin/list-usb-cameras > /tmp/camerastack-usb.log")
55+
files["camerastack-usb.log"] = "/tmp/camerastack-usb.log"
56+
except Exception:
57+
logging.getLogger(__name__).exception(
58+
"Failed to create camerastack-usb.log file"
59+
)
60+
61+
return files
62+
63+
2664
__LOCAL_DEBUG = os.path.exists(
2765
os.path.realpath(os.path.join(os.path.dirname(__file__), "..", ".local_debug"))
2866
)
@@ -43,12 +81,22 @@
4381
_PROC_DT_MODEL_PATH = os.path.join(base, "fake_model.txt")
4482
_OCTOPI_VERSION_PATH = os.path.join(base, "fake_octopi.txt")
4583
_OCTOPIUPTODATE_BUILD_PATH = os.path.join(base, "fake_octopiuptodate.txt")
84+
_NEW_CAMERA_STACK_PATH = os.path.join(debug, "new-camera-stack")
4685
_SSHWARN_PATH = os.path.join(debug, "sshwarn")
4786

87+
_gather_new_camerastack_files = lambda: { # noqa: F811
88+
"camerastack-journal.log": os.path.join(base, "fake_camerastack_journal.txt"),
89+
"camerastack-libcamera.log": os.path.join(
90+
base, "fake_camerastack_libcamera.txt"
91+
),
92+
"camerastack-usb.log": os.path.join(base, "fake_camerastack_usb.txt"),
93+
}
94+
4895
import itertools
4996

5097
_VCGENCMD_OUTPUT = itertools.chain(
51-
iter(("0x0", "0x0", "0x50005", "0x50000", "0x70007")), itertools.repeat("0x70005")
98+
iter(("0x0", "0x0", "0x50005", "0x50000", "0x70007")),
99+
itertools.repeat("0x70005"),
52100
)
53101
_VCGENCMD_BROKEN = os.path.exists(os.path.join(debug, "vcgencmd_broken"))
54102

@@ -79,7 +127,8 @@ def from_value(cls, value=0):
79127
"throttled": _FLAG_THROTTLED & value == _FLAG_THROTTLED,
80128
"past_undervoltage": _FLAG_PAST_UNDERVOLTAGE & value
81129
== _FLAG_PAST_UNDERVOLTAGE,
82-
"past_freq_capped": _FLAG_PAST_FREQ_CAPPED & value == _FLAG_PAST_FREQ_CAPPED,
130+
"past_freq_capped": _FLAG_PAST_FREQ_CAPPED & value
131+
== _FLAG_PAST_FREQ_CAPPED,
83132
"past_throttled": _FLAG_PAST_THROTTLED & value == _FLAG_PAST_THROTTLED,
84133
"raw_value": value,
85134
}
@@ -196,7 +245,9 @@ def get_vcgencmd_throttled_state(command):
196245
output, error = sarge.get_both(command, close_fds=CLOSE_FDS)
197246

198247
if "throttled=0x" not in output:
199-
raise ValueError(f"Cannot parse {command!r} output: {error if error else output}")
248+
raise ValueError(
249+
f"Cannot parse {command!r} output: {error if error else output}"
250+
)
200251

201252
value = output[len("throttled=") :].strip(" \t\r\n\0")
202253
value = int(value, 0)
@@ -211,6 +262,10 @@ def is_octopiuptodate():
211262
return os.path.exists(_OCTOPIUPTODATE_BUILD_PATH)
212263

213264

265+
def is_new_camerastack():
266+
return os.path.exists(_NEW_CAMERA_STACK_PATH)
267+
268+
214269
def is_model_any_of(model, *args):
215270
model = model.lower()
216271
for arg in map(lambda x: x.lower(), args):
@@ -301,10 +356,20 @@ def get_additional_permissions(self):
301356

302357
def get_additional_bundle_files(self, *args, **kwargs):
303358
if is_octopi():
304-
return {
305-
"webcamd.log": "/var/log/webcamd.log",
359+
result = {
306360
"haproxy.log": "/var/log/haproxy.log",
307361
}
362+
363+
if is_new_camerastack():
364+
# new camera-streamer based camera stack
365+
files = _gather_new_camerastack_files()
366+
result.update(**files)
367+
368+
else:
369+
# old mjpg-streamer based camera stack
370+
result["webcamd.log"] = "/var/log/webcamd.log"
371+
372+
return result
308373
else:
309374
return {}
310375

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
-- Journal begins at Thu 2022-09-22 01:23:40 BST, ends at Wed 2023-05-24 16:28:00 BST. --
2+
May 24 01:48:08 octopic systemd[1]: Starting camera-streamer...
3+
May 24 01:48:08 octopic camera-streamer-control[533]: Running start for camera-streamer-libcamera.service...
4+
May 24 01:48:08 octopic camera-streamer-control[533]: ... done.
5+
May 24 01:48:08 octopic camera-streamer-control[533]: Adding path unit for autolaunch of camera-streamer-usb@default
6+
May 24 01:48:08 octopic systemd[1]: Starting camera-streamer libcamera...
7+
May 24 01:48:09 octopic camera-streamer-control[533]: Running start for camera-streamer-usb-default.path...
8+
May 24 01:48:09 octopic camera-streamer-control[533]: ... done.
9+
May 24 01:48:09 octopic systemd[1]: Started camera-streamer default autolaunch.
10+
May 24 01:48:09 octopic systemd[1]: Finished camera-streamer.
11+
May 24 01:48:11 octopic sh[549]: /base/soc/i2c0mux/i2c@1/ov5647@36
12+
May 24 01:48:11 octopic systemd[1]: Started camera-streamer libcamera.
13+
May 24 01:48:15 octopic sh[589]: /usr/bin/camera-streamer Version: v0.1-21-g54f538e (54f538e)
14+
May 24 01:48:15 octopic sh[589]: [0:00:20.341406502] [589] INFO Camera camera_manager.cpp:299 libcamera v0.0.4+22-923f5d70
15+
May 24 01:48:15 octopic sh[589]: [0:00:20.411405304] [705] INFO RPI raspberrypi.cpp:1476 Registered camera /base/soc/i2c0mux/i2c@1/ov5647@36 to Unicam device /dev/media2 and ISP device /dev/media0
16+
May 24 01:48:15 octopic sh[589]: device/libcamera/device.cc: CAMERA: Device path=/base/soc/i2c0mux/i2c@1/ov5647@36 opened
17+
May 24 01:48:15 octopic sh[589]: [0:00:20.413811397] [589] INFO Camera camera.cpp:1028 configuring streams: (0) 1920x1080-YUYV
18+
May 24 01:48:15 octopic sh[589]: [0:00:20.414694522] [705] INFO RPI raspberrypi.cpp:851 Sensor: /base/soc/i2c0mux/i2c@1/ov5647@36 - Selected sensor format: 1920x1080-SGBRG10_1X10 - Selected unicam format: 1920x1080-pGAA
19+
May 24 01:48:15 octopic sh[589]: [0:00:20.418496866] [589] INFO Camera camera.cpp:1028 configuring streams: (0) 1920x1080-YUYV (1) 1920x1080-SGBRG10_CSI2P
20+
May 24 01:48:15 octopic sh[589]: [0:00:20.419256345] [705] INFO RPI raspberrypi.cpp:851 Sensor: /base/soc/i2c0mux/i2c@1/ov5647@36 - Selected sensor format: 1920x1080-SGBRG10_1X10 - Selected unicam format: 1920x1080-pGAA
21+
May 24 01:48:15 octopic sh[589]: device/buffer_list.c: CAMERA:capture: Using: 1920x1080/YUYV, buffers=2, bytesperline=3840, sizeimage=0.0MiB
22+
May 24 01:48:15 octopic sh[589]: device/buffer_list.c: CAMERA:capture: Opened 2 buffers. Memory used: 7.9 MiB
23+
May 24 01:48:15 octopic sh[589]: device/buffer_list.c: CAMERA:capture:1: Using: 1920x1080/GB10, buffers=2, bytesperline=2400, sizeimage=0.0MiB
24+
May 24 01:48:15 octopic sh[589]: device/buffer_list.c: CAMERA:capture:1: Opened 2 buffers. Memory used: 4.9 MiB
25+
May 24 01:48:15 octopic sh[589]: device/v4l2/device.c: SNAPSHOT: Device path=/dev/video31 fd=37 opened
26+
May 24 01:48:15 octopic sh[589]: device/v4l2/buffer_list.c: SNAPSHOT:output:mplane: Requested resolution=1920x1080 is unavailable. Got 1920x1088.
27+
May 24 01:48:15 octopic sh[589]: device/buffer_list.c: SNAPSHOT:output:mplane: Using: 1920x1056/YUYV, buffers=2, bytesperline=3840, sizeimage=3.9MiB
28+
May 24 01:48:15 octopic sh[589]: device/buffer_list.c: SNAPSHOT:output:mplane: Opened 2 buffers. Memory used: 0.0 MiB
29+
May 24 01:48:15 octopic sh[589]: device/buffer_list.c: SNAPSHOT:capture:mplane: Using: 1920x1056/JPEG, buffers=2, bytesperline=0, sizeimage=4.0MiB
30+
May 24 01:48:15 octopic sh[589]: device/buffer_list.c: SNAPSHOT:capture:mplane: Opened 2 buffers. Memory used: 8.0 MiB
31+
May 24 01:48:15 octopic sh[589]: device/v4l2/device.c: RESCALLER:STREAM: Device path=/dev/video12 fd=40 opened
32+
May 24 01:48:15 octopic sh[589]: device/buffer_list.c: RESCALLER:STREAM:output:mplane: Using: 1920x1080/YUYV, buffers=2, bytesperline=3840, sizeimage=4.0MiB
33+
May 24 01:48:15 octopic sh[589]: device/buffer_list.c: RESCALLER:STREAM:output:mplane: Opened 2 buffers. Memory used: 0.0 MiB
34+
May 24 01:48:15 octopic sh[589]: device/buffer_list.c: RESCALLER:STREAM:capture:mplane: Using: 1312x736/YUYV, buffers=2, bytesperline=2624, sizeimage=1.8MiB
35+
May 24 01:48:15 octopic sh[589]: device/buffer_list.c: RESCALLER:STREAM:capture:mplane: Opened 2 buffers. Memory used: 3.7 MiB
36+
May 24 01:48:15 octopic sh[589]: device/v4l2/device.c: STREAM: Device path=/dev/video31 fd=43 opened
37+
May 24 01:48:15 octopic sh[589]: device/buffer_list.c: STREAM:output:mplane: Using: 1312x736/YUYV, buffers=2, bytesperline=2624, sizeimage=1.8MiB
38+
May 24 01:48:15 octopic sh[589]: device/buffer_list.c: STREAM:output:mplane: Opened 2 buffers. Memory used: 0.0 MiB
39+
May 24 01:48:15 octopic sh[589]: device/buffer_list.c: STREAM:capture:mplane: Using: 1312x736/JPEG, buffers=2, bytesperline=0, sizeimage=4.0MiB
40+
May 24 01:48:15 octopic sh[589]: device/buffer_list.c: STREAM:capture:mplane: Opened 2 buffers. Memory used: 8.0 MiB
41+
May 24 01:48:15 octopic sh[589]: device/v4l2/device.c: VIDEO: Device path=/dev/video11 fd=46 opened
42+
May 24 01:48:15 octopic sh[589]: device/buffer_list.c: VIDEO:output:mplane: Using: 1312x736/YUYV, buffers=2, bytesperline=2624, sizeimage=1.8MiB
43+
May 24 01:48:15 octopic sh[589]: device/buffer_list.c: VIDEO:output:mplane: Opened 2 buffers. Memory used: 0.0 MiB
44+
May 24 01:48:15 octopic sh[589]: device/buffer_list.c: VIDEO:capture:mplane: Using: 1312x736/H264, buffers=2, bytesperline=0, sizeimage=0.8MiB
45+
May 24 01:48:15 octopic sh[589]: device/buffer_list.c: VIDEO:capture:mplane: Opened 2 buffers. Memory used: 1.5 MiB
46+
May 24 01:48:15 octopic sh[589]: device/device.c: CAMERA: Setting frame interval_us=0 for FPS=15
47+
May 24 01:48:15 octopic sh[589]: device/v4l2/device_options.c: SNAPSHOT: Configuring option compressionquality (009d0903) = 80
48+
May 24 01:48:15 octopic sh[589]: device/v4l2/device_options.c: STREAM: Configuring option compressionquality (009d0903) = 80
49+
May 24 01:48:15 octopic sh[589]: device/v4l2/device_options.c: VIDEO: Configuring option repeatsequenceheader (009909e2) = 1
50+
May 24 01:48:15 octopic sh[589]: device/v4l2/device_options.c: VIDEO: Configuring option videobitratemode (009909ce) = 0
51+
May 24 01:48:15 octopic sh[589]: device/v4l2/device_options.c: VIDEO: Configuring option videobitrate (009909cf) = 2000000
52+
May 24 01:48:15 octopic sh[589]: device/v4l2/device_options.c: VIDEO: Configuring option repeatsequenceheader (009909e2) = 5000000
53+
May 24 01:48:15 octopic sh[589]: device/v4l2/device_options.c: VIDEO: Configuring option h264iframeperiod (00990a66) = 30
54+
May 24 01:48:15 octopic sh[589]: device/v4l2/device_options.c: VIDEO: Configuring option h264level (00990a67) = 11
55+
May 24 01:48:15 octopic sh[589]: device/v4l2/device_options.c: VIDEO: Configuring option h264profile (00990a6b) = 4
56+
May 24 01:48:15 octopic sh[589]: device/v4l2/device_options.c: VIDEO: Configuring option h264minimumqpvalue (00990a61) = 16
57+
May 24 01:48:15 octopic sh[589]: device/v4l2/device_options.c: VIDEO: Configuring option h264maximumqpvalue (00990a62) = 32
58+
May 24 01:48:15 octopic sh[589]: device/links.c: ?: Link 0: CAMERA:capture[1920x1080/YUYV/2] => [SNAPSHOT:output:mplane[1920x1056/YUYV/2], RESCALLER:STREAM:output:mplane[1920x1080/YUYV/2]]
59+
May 24 01:48:15 octopic sh[589]: device/links.c: ?: Link 1: SNAPSHOT:capture:mplane[1920x1056/JPEG/2] => [SNAPSHOT-CAPTURE]
60+
May 24 01:48:15 octopic sh[589]: device/links.c: ?: Link 2: RESCALLER:STREAM:capture:mplane[1312x736/YUYV/2] => [STREAM:output:mplane[1312x736/YUYV/2], VIDEO:output:mplane[1312x736/YUYV/2]]
61+
May 24 01:48:15 octopic sh[589]: device/links.c: ?: Link 3: STREAM:capture:mplane[1312x736/JPEG/2] => [STREAM-CAPTURE]
62+
May 24 01:48:15 octopic sh[589]: device/links.c: ?: Link 4: VIDEO:capture:mplane[1312x736/H264/2] => [VIDEO-CAPTURE]
63+
May 24 01:48:16 octopic sh[589]: device/buffer_list.c: CAMERA:capture: Streaming started... Was 0 of 2 enqueud
64+
May 24 01:48:16 octopic sh[589]: device/buffer_list.c: SNAPSHOT:output:mplane: Streaming started... Was 0 of 2 enqueud
65+
May 24 01:48:16 octopic sh[589]: device/buffer_list.c: RESCALLER:STREAM:output:mplane: Streaming started... Was 0 of 2 enqueud
66+
May 24 01:48:16 octopic sh[589]: device/buffer_list.c: SNAPSHOT:capture:mplane: Streaming started... Was 0 of 2 enqueud
67+
May 24 01:48:16 octopic sh[589]: device/buffer_list.c: RESCALLER:STREAM:capture:mplane: Streaming started... Was 0 of 2 enqueud
68+
May 24 01:48:16 octopic sh[589]: device/buffer_list.c: STREAM:output:mplane: Streaming started... Was 0 of 2 enqueud
69+
May 24 01:48:16 octopic sh[589]: device/buffer_list.c: VIDEO:output:mplane: Streaming started... Was 0 of 2 enqueud
70+
May 24 01:48:16 octopic sh[589]: device/buffer_list.c: STREAM:capture:mplane: Streaming started... Was 0 of 2 enqueud
71+
May 24 01:48:16 octopic sh[589]: device/buffer_list.c: VIDEO:capture:mplane: Streaming started... Was 0 of 2 enqueud
72+
May 24 12:16:11 octopic sh[589]: util/http/http.c: HTTP8080/2: Client connected 127.0.0.1 (fd=5).
73+
May 24 12:16:11 octopic sh[589]: util/http/http.c: HTTP8080/2: Request 'GET' '/' ''
74+
May 24 12:16:11 octopic sh[589]: util/http/http.c: HTTP8080/2: Client disconnected 127.0.0.1.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Available cameras
2+
-----------------
3+
0 : ov5647 [2592x1944] (/base/soc/i2c0mux/i2c@1/ov5647@36)
4+
Modes: 'SGBRG10_CSI2P' : 640x480 [30.00 fps - (0, 0)/0x0 crop]
5+
1296x972 [30.00 fps - (0, 0)/0x0 crop]
6+
1920x1080 [30.00 fps - (0, 0)/0x0 crop]
7+
2592x1944 [30.00 fps - (0, 0)/0x0 crop]

tests/fakes/fake_camerastack_usb.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Available USB camera devices:
2+
/dev/v4l/by-id/usb-*-video-index0

0 commit comments

Comments
 (0)