Skip to content

Commit

Permalink
Update capture_ZWO.cpp: better error checks with flushBufferedImages()
Browse files Browse the repository at this point in the history
  • Loading branch information
EricClaeys authored Sep 25, 2023
1 parent 5d7f7d0 commit ee68917
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/capture_ZWO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ ASI_ERROR_CODE setControl(int camNum, ASI_CONTROL_TYPE control, long value, ASI_
ret = ASISetControlValue(camNum, control, value, makeAuto);
if (ret != ASI_SUCCESS)
{
Log(-1, "*** %s: WARNING: ASISetControlCaps() for control %d, value=%ld failed: %s\n",
Log(-1, "*** %s: WARNING: ASISetControlValue() for control %d, value=%ld failed: %s\n",
CG.ME, control, value, getRetCode(ret));
return(ret);
}
Expand Down Expand Up @@ -323,12 +323,17 @@ int computeHistogram(unsigned char *imageBuffer, config cg, bool useHistogramBox
// Camera has internal frame buffers we need to clear.
// The camera and/or driver will buffer frames and return the oldest one which
// could be very old. Read out all the buffered frames so the frame we get is current.
void flushBufferedImages(config *cg, void *buf, size_t size)
ASI_ERROR_CODE flushBufferedImages(config *cg, void *buf, size_t size)
{
enum { NUM_IMAGE_BUFFERS = 2 };
ASI_ERROR_CODE status;

setControl(cg->cameraNumber, ASI_EXPOSURE, cg->cameraMinExposure_us, ASI_FALSE);
status = setControl(cg->cameraNumber, ASI_EXPOSURE, cg->cameraMinExposure_us, ASI_FALSE);
if (status != ASI_SUCCESS)
{
Log(0, "*** %s: ERROR: flushBufferedImages() setControl() returned %s\n", cg->ME, getRetCode(status));
return(status);
}

for (int i = 0; i < NUM_IMAGE_BUFFERS; i++)
{
Expand All @@ -341,8 +346,14 @@ void flushBufferedImages(config *cg, void *buf, size_t size)
{
Log(0, "*** %s: ERROR: flushBufferedImages() got %s\n", cg->ME, getRetCode(status));
}
// TODO: in theory if status == ASI_ERROR_TIMEOUT we could stop.
else
{
// ASI_ERROR_TIMEOUT. No more left.
return(status);
}
}

return(ASI_SUCCESS);
}


Expand Down

0 comments on commit ee68917

Please sign in to comment.