Add check that camera is present and initialized
b/124529767
Change-Id: I727b7ee0045d75753f0a9a88d8b68de6424c12f4
diff --git a/snapshot b/snapshot
index 548f139..247f0cc 100755
--- a/snapshot
+++ b/snapshot
@@ -23,6 +23,7 @@
FILENAME_PREFIX = 'img'
FILENAME_SUFFIX = '.png'
AF_SYSFS_NODE = '/sys/module/ov5645_camera_mipi_v2/parameters/ov5645_af'
+CAMERA_INIT_QUERY_SYSFS_NODE = '/sys/module/ov5645_camera_mipi_v2/parameters/ov5645_initialized'
HDMI_SYSFS_NODE = '/sys/class/drm/card0/card0-HDMI-A-1/status'
# No of initial frames to throw away before camera has stabilized
@@ -266,6 +267,12 @@
args = parser.parse_args()
try:
+ with open(CAMERA_INIT_QUERY_SYSFS_NODE) as init_file:
+ init_file.seek(0)
+ init = init_file.read()
+ if int(init) != 1:
+ raise Exception('Cannot find ov5645 CSI camera, ' +
+ 'check that your camera is connected')
with open(AF_SYSFS_NODE, 'w+') as sysfs:
snap = SnapHelper(sysfs, args.prefix, args.oneshot, args.suffix)
run_pipeline(snap)