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

Update capture.cpp to log camera serial number and configurable ID field #499

Merged
merged 2 commits into from
Sep 28, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 66 additions & 17 deletions capture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ int asiNightMaxExposure = DEFAULT_ASINIGHTMAXEXPOSURE;
int gainTransitionTime = DEFAULT_GAIN_TRANSITION_TIME;
ASI_BOOL currentAutoExposure = ASI_FALSE; // is Auto Exposure currently on or off?

#ifdef USE_HISTOGRAM
long cameraMaxAutoExposureUS = NOT_SET; // camera's max auto exposure in us
#ifdef USE_HISTOGRAM
#define DEFAULT_BOX_SIZEX 500
#define DEFAULT_BOX_SIZEY 500
int histogramBoxSizeX = DEFAULT_BOX_SIZEX; // 500 px x 500 px box. Must be a multiple of 2.
Expand Down Expand Up @@ -633,14 +633,12 @@ void writeTemperatureToFile(float val)
}

// Simple function to make flags easier to read for humans.
char const *yes = "1 (yes)";
char const *no = "0 (no)";
char const *yesNo(int flag)
{
if (flag)
return(yes);
if (flag != 0)
EricClaeys marked this conversation as resolved.
Show resolved Hide resolved
return("Yes");
else
return(no);
return("No");
}

bool adjustGain = false; // Should we adjust the gain? Set by user on command line.
Expand Down Expand Up @@ -938,11 +936,11 @@ const char *locale = DEFAULT_LOCALE;
setlinebuf(stdout); // Line buffer output so entries appear in the log immediately.
printf("\n");
printf("%s ******************************************\n", KGRN);
printf("%s *** Allsky Camera Software v0.8 | 2021 ***\n", KGRN);
printf("%s *** Allsky Camera Software v0.8.1 | 2021 ***\n", KGRN);
printf("%s ******************************************\n\n", KGRN);
printf("\%sCapture images of the sky with a Raspberry Pi and an ASI Camera\n", KGRN);
printf("\n");
printf("%sAdd -h or -help for available options\n", KYEL);
printf("%sAdd -h or --help for available options\n", KYEL);
printf("\n");
printf("\%sAuthor: ", KNRM);
printf("Thomas Jacquin - <[email protected]>\n\n");
Expand All @@ -963,7 +961,7 @@ const char *locale = DEFAULT_LOCALE;
// -h[elp] doesn't take an argument, but the "for" loop assumes every option does,
// so check separately, assuming the option is the first one.
// If it's not the first option, we'll find it in the "for" loop.
if (strcmp(argv[0], "-h") == 0 || strcmp(argv[0], "-help") == 0)
if (strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "-help") == 0 || strcmp(argv[1], "--help") == 0))
EricClaeys marked this conversation as resolved.
Show resolved Hide resolved
{
help = 1;
i = 1;
Expand All @@ -979,7 +977,7 @@ const char *locale = DEFAULT_LOCALE;
for ( ; i < argc - 1 ; i++)
{
// Check again in case "-h" isn't the first option.
if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "-help") == 0)
if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "-help") == 0 || strcmp(argv[i], "-help") == 0))
EricClaeys marked this conversation as resolved.
Show resolved Hide resolved
{
help = 1;
}
Expand Down Expand Up @@ -1395,6 +1393,7 @@ const char *locale = DEFAULT_LOCALE;
printf(" -debuglevel - Default = 0. Set to 1,2 or 3 for more debugging information.\n");
printf("%sUsage:\n", KRED);
printf(" ./capture -width 640 -height 480 -nightexposure 5000000 -gamma 50 -type 1 -nightbin 1 -filename Lake-Laberge.PNG\n\n");
exit(0);
}
printf("%s\n", KNRM);
setlocale(LC_NUMERIC, locale);
Expand Down Expand Up @@ -1506,15 +1505,43 @@ const char *locale = DEFAULT_LOCALE;
printf(" - Camera with cooling capabilities\n");
}

const char *ver = ASIGetSDKVersion();
printf(" - SDK version %s\n", ver);

asiRetCode = ASIInitCamera(CamNum);
if (asiRetCode == ASI_SUCCESS)
printf("\n");
ASI_ID cameraID; // USB 3 cameras only
if (ASICameraInfo.IsUSB3Camera == ASI_TRUE && ASIGetID(CamNum, &cameraID) == ASI_SUCCESS)
{
printf(" - Camera ID: ");
if (cameraID.id[0] == '\0')
{
printf("[none]");
} else {
for (unsigned int i=0; i<sizeof(cameraID.id); i++) printf("%c", cameraID.id[i]);
}
printf("\n");
}
// To clear the camera ID:
// cameraID.id[0] = '\0';
// ASISetID(CamNum, cameraID);
ASI_SN serialNumber;
asiRetCode = ASIGetSerialNumber(CamNum, &serialNumber);
if (asiRetCode != ASI_SUCCESS)
{
printf(" - Initialise Camera OK\n");
printf("*** WARNING: unable to get serialNumber (%s)\n", getRetCode(asiRetCode));
}
else
{
printf(" - Camera Serial Number: ");
if (serialNumber.id[0] == '\0')
{
printf("[none]");
} else {
printf("0x");
EricClaeys marked this conversation as resolved.
Show resolved Hide resolved
for (unsigned int i=0; i<sizeof(serialNumber.id); i++) printf("%02x", serialNumber.id[i]);
}
printf("\n");
}

asiRetCode = ASIInitCamera(CamNum);
if (asiRetCode != ASI_SUCCESS)
{
printf("*** ERROR: Unable to initialise camera: %s\n", getRetCode(asiRetCode));
closeUp(1); // Can't do anything so might as well exit.
Expand All @@ -1537,6 +1564,25 @@ const char *locale = DEFAULT_LOCALE;
}
}

if (debugLevel >= 3)
{
printf("Supported video formats:\n");
for (i = 0; i < 8; i++)
{
ASI_IMG_TYPE it = ASICameraInfo.SupportedVideoFormat[i];
if (it == ASI_IMG_END)
{
break;
}
printf(" - %s\n",
it == ASI_IMG_RAW8 ? "ASI_IMG_RAW8" :
it == ASI_IMG_RGB24 ? "ASI_IMG_RGB24" :
it == ASI_IMG_RAW16 ? "ASI_IMG_RAW16" :
it == ASI_IMG_Y8 ? "ASI_IMG_Y8" :
"unknown video format");
}
}

if (width == 0 || height == 0)
{
width = iMaxWidth;
Expand Down Expand Up @@ -1657,7 +1703,10 @@ const char *locale = DEFAULT_LOCALE;
printf(" Darkframe: %s\n", yesNo(darkframe));
printf(" Debug Level: %d\n", debugLevel);
printf(" TTY: %s\n", yesNo(tty));
printf("%s\n", KNRM);
printf(" Version 0.8 Exposure Method: %s\n", yesNo(use_new_exposure_algorithm));
EricClaeys marked this conversation as resolved.
Show resolved Hide resolved

// This should always be last since it turns color off.
EricClaeys marked this conversation as resolved.
Show resolved Hide resolved
printf(" ZWO SDK version %s%s\n", ASIGetSDKVersion(), KNRM);

//-------------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------------
Expand Down