Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add error handling for camera initialization. #2

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

drLite35
Copy link
Contributor

Added error handling and display for connection failure related to bug index of bound.

@44yu5h
Copy link
Owner

44yu5h commented Jul 20, 2024

Thanks for the PR!
It only "kinda kinda" works. I can see the dialogue box pop up every time there's an error - 1. when no camera is attached, 2. when camera initialization fails (happens when the resource is busy)

It works fine in the second case the pop up is displayed, however, the cross or the "OK" button lets the user go into the UI. It'd be great if it can redirect to home screen or just close the activity

In the first case, when no camera is attached. It just gets unresponsive and freezes and needs to be force closed.
Terminal logs:

[0:01:20.028681067] [1404]  INFO Camera camera_manager.cpp:313 libcamera v0.3.0+65-6ddd79b5
[0:01:20.036560344] [1426]  INFO RPI pisp.cpp:695 libpisp version v1.0.6 b567f0455680 17-06-2024 (10:20:00)
[0:01:20.047493256] [1426]  INFO RPI pisp.cpp:1154 Registered camera /base/axi/pcie@120000/rp1/i2c@80000/ov5647@36 to CFE device /dev/media3 and ISP device /dev/media0 using PiSP variant BCM2712_C0
[0:01:20.048752058] [1404]  INFO Camera camera_manager.cpp:313 libcamera v0.3.0+65-6ddd79b5
[0:01:20.058253543] [1429]  INFO RPI pisp.cpp:695 libpisp version v1.0.6 b567f0455680 17-06-2024 (10:20:00)
[0:01:20.071108079] [1429]  INFO RPI pisp.cpp:1154 Registered camera /base/axi/pcie@120000/rp1/i2c@80000/ov5647@36 to CFE device /dev/media3 and ISP device /dev/media0 using PiSP variant BCM2712_C0
[0:01:20.073318893] [1404]  WARN V4L2 v4l2_pixelformat.cpp:344 Unsupported V4L2 pixel format RPBP
[0:01:20.073984364] [1404]  INFO Camera camera.cpp:1183 configuring streams: (0) 640x480-RGB888 (1) 640x480-GBRG_PISP_COMP1
[0:01:20.074093871] [1429]  INFO RPI pisp.cpp:1450 Sensor: /base/axi/pcie@120000/rp1/i2c@80000/ov5647@36 - Selected sensor format: 640x480-SGBRG10_1X10 - Selected CFE format: 640x480-PC1g
[0:01:20.114945972] [1429] ERROR V4L2 v4l2_videodevice.cpp:1906 /dev/video6[29:cap]: Failed to start streaming: Remote I/O error
Error starting camera preview: Failed to start camera: Remote I/O error
^Z
[1]+  Stopped                 sugar-activity3

Comment on lines +159 to +169
def show_error_message(self, message):
# Create an error dialog
dialog = Gtk.MessageDialog(
parent=self,
flags=Gtk.DialogFlags.MODAL,
type=Gtk.MessageType.ERROR,
buttons=Gtk.ButtonsType.OK,
message_format=message
)
dialog.run()
dialog.destroy()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should use the sugar3.graphics.alert instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok thanks!

@drLite35
Copy link
Contributor Author

Thanks for the PR! It only "kinda kinda" works. I can see the dialogue box pop up every time there's an error - 1. when no camera is attached, 2. when camera initialization fails (happens when the resource is busy)

It works fine in the second case the pop up is displayed, however, the cross or the "OK" button lets the user go into the UI. It'd be great if it can redirect to home screen or just close the activity

In the first case, when no camera is attached. It just gets unresponsive and freezes and needs to be force closed. Terminal logs:

[0:01:20.028681067] [1404]  INFO Camera camera_manager.cpp:313 libcamera v0.3.0+65-6ddd79b5
[0:01:20.036560344] [1426]  INFO RPI pisp.cpp:695 libpisp version v1.0.6 b567f0455680 17-06-2024 (10:20:00)
[0:01:20.047493256] [1426]  INFO RPI pisp.cpp:1154 Registered camera /base/axi/pcie@120000/rp1/i2c@80000/ov5647@36 to CFE device /dev/media3 and ISP device /dev/media0 using PiSP variant BCM2712_C0
[0:01:20.048752058] [1404]  INFO Camera camera_manager.cpp:313 libcamera v0.3.0+65-6ddd79b5
[0:01:20.058253543] [1429]  INFO RPI pisp.cpp:695 libpisp version v1.0.6 b567f0455680 17-06-2024 (10:20:00)
[0:01:20.071108079] [1429]  INFO RPI pisp.cpp:1154 Registered camera /base/axi/pcie@120000/rp1/i2c@80000/ov5647@36 to CFE device /dev/media3 and ISP device /dev/media0 using PiSP variant BCM2712_C0
[0:01:20.073318893] [1404]  WARN V4L2 v4l2_pixelformat.cpp:344 Unsupported V4L2 pixel format RPBP
[0:01:20.073984364] [1404]  INFO Camera camera.cpp:1183 configuring streams: (0) 640x480-RGB888 (1) 640x480-GBRG_PISP_COMP1
[0:01:20.074093871] [1429]  INFO RPI pisp.cpp:1450 Sensor: /base/axi/pcie@120000/rp1/i2c@80000/ov5647@36 - Selected sensor format: 640x480-SGBRG10_1X10 - Selected CFE format: 640x480-PC1g
[0:01:20.114945972] [1429] ERROR V4L2 v4l2_videodevice.cpp:1906 /dev/video6[29:cap]: Failed to start streaming: Remote I/O error
Error starting camera preview: Failed to start camera: Remote I/O error
^Z
[1]+  Stopped                 sugar-activity3

Well let me see the other way around it but it gets me in terminal directly in both the cases but that might due to I am running these activity from terminal only

@chimosky
Copy link

Well let me see the other way around it but it gets me in terminal directly in both the cases but that might due to I am running these activity from terminal only

People who use sugar would rarely ever run activities from the terminal, test activities through the activity ring and see how they behave as that's how you'll expect people to run them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants