worlickwerx / sbig-util

Linux utility for Santa Barbara Instrument Group cameras for astronomy
GNU General Public License v3.0
5 stars 2 forks source link

need concurrent access to camera by multiple tools #24

Open garlick opened 7 years ago

garlick commented 7 years ago

Problem 1: establishing a connection with the sbigudrv has a long latency, more than one second. Unfortunately, this means running each standalone command in sbig-util incurs that latency, and attempting to drive the commands back to back to do different things from a shell script incurs this latency repeatedly.

Problem 2: concurrent access to the camera is a problem from multiple utilities since access to the hardware is not coordinated. So for example, errors occur if you run a script that logs the CCD temperature, e.g.

#!/bin/sh
while true; do
    sbig info cooler|grep "imaging ccd:" >>/var/log/ccd-temperature.log
    sleep 5
done

and concurrently run sbig snap to take images, e.g.

$ sbig snap --force --no-cooler
sbig-snap: Device open
sbig-snap: sbig_establish_link: Camera not Found

A potential solution to this problem is to use FUSE to mount the camera as a file system. The act of mounting the camera starts a fuse-enabled process that incurs the connect latency once at mount time, then persists until it is unmounted. All accesses through the file system are coordinated by this process. In the example above, the logging script might be

#!/bin/sh
while true; do
    cat /mnt/camera/cooler/imaging-ccd >>/var/log/ccd-temperature.log
    sleep 5
done

and the equivalent of sbig-snap might be

#!/bin/sh
echo start-exposure 60 >/mnt/camera/ccd/imaging/ctl
cat /mnt/camera/ccd/imaging/image >/tmp/foo.fits

As long as the fuse-enabled program is built for concurrency, these two activities can run without interfering with each other. The sbigudrv API supports separate commands for starting and finalizing an exposure specifically for this purpose.

https://github.com/libfuse/libfuse