I feel like I'm somewhat different in how I am using Astroberry. I want to share some things about my setup and how I use it. This first topic will be about how I control the shutter on my camera.
I have a Fujifilm X-T20. It is not possible to control the shutter and download images at the same time. More expensive Fujifilm cameras support tethered shooting, but not the X-T20. It is possible to use external intervalometers, but this makes it nearly impossible to dither. Controlling the shutter from an INDI client (I use CCD Ciel) while also dithering in PHD2 was my ultimate goal.
I also have a Sky-Watcher EQ6-R Pro. Many Sky-Watcher mounts have "snap" ports that can be used to control cameras in the same way intervalometers can control cameras. The snap port on my Sky-Watcher mount controls my X-T20 using a simple 2.5mm to 3.5mm stereo audio cable. If I use the mount's hand controller, I can access a menu that works just like an intervalometer would.
I don't use a hand controller though. Instead I connect the Raspberry PI directly to the mount using a USB cable. I then use the EQMod Mount INDI driver. Recent versions of this driver include INDI parameters for controlling the snap ports on Sky-Watcher mounts. The parameters to look for are "EQMod Mount.SNAPPORT1.SNAPPORT1_ON" and "EQMod Mount.SNAPPORT1.SNAPPORT1_OFF".
Note: The driver looks at a mount identifier to determine if the parameters should be enabled. If you have a mount with a snap port, but the parameters do not exist, the EQMod driver developer might only need to add a mount identifier to the code to enable support.
This means we can control the shutter from a shell prompt with the following command.
indi_setprop "EQMod Mount.SNAPPORT1.SNAPPORT1_ON=On"
And similarly, this command will close the shutter.
indi_setprop "EQMod Mount.SNAPPORT1.SNAPPORT1_OFF=On"
So now we have a way to control the shutter from the command line, but in order to use an INDI client, we need something that looks like an INDI camera. The secret to making all of this work, is to enable the "CCD Simulator" driver. This is a fake camera in INDI. We setup our INDI client to use the CCD Simulator camera as the main camera. When the client tells the camera to take a picture, it sets the "CCD Simulator.CCD_EXPOSURE.CCD_EXPOSURE_VALUE" to the length of the exposure needed.
The next trick is to watch that CCD_EXPOSURE_VALUE parameter from a shell script, catch the new exposure length when it increases in value, and then open the shutter for the specified number of seconds. Ok, I admit that sounds a little complicated, so I've included my script that does just that. The snap_port_listener script (attached with a txt extension) uses an indi_eval command to wait for the exposure value to change. To use this script, just open a shell window and start the script before using the camera in your favorite client. The script will keep track of the cumulative exposure time as well as the total number of exposures. When you're done capturing, just issue a Ctrl-C in the window running the listener, and the script will stop. If you kill it while an exposure is taking place, it will close the shutter.
This script can be easily edited if you have a different way to control your shutter from the command line. I actually use a similar script that controls my shutter using an optoisolator circuit and the GPIO pins on the Raspberry PI. The only thing that needs to change in the script to use a different shutter control method is the exposeSensor and closeShutter functions.
It is also worth noting that if the INDI client cancels an exposure, the script will not see it. In that case, you would want to kill the script, or wait for the exposure to finish, before starting a new set of exposures using the client.
You may need to check the values of the parameters on the CCD Simulator driver to ensure the exposure is set to zero before starting the script. Also, the CCD Simulator creates simulated image files. You will want to note where these get saved so you can purge them later, or block them from being written all together. I actually tell CCD Ciel to write the files to a directory that I have set with 000 permissions. It happily fails to write them and continues with exposures anyway... which is handy in my case. I also configure the CCD Simulator to use a smaller resolution (600x400) and scale the pixel size so the field of view actually matches my camera. This is not necessary, but results in less IO for the simulator driver, and any client that uses the sensor for field of view estimates will draw the correct sized box.
I hope someone finds this script helpful. I'm sure there are many other ways to do this, and many different ways to write this, but this is working well for me. Feel free to use it as a starting point for your own script.