Skip to content

Commit

Permalink
Working on QSI camera driver
Browse files Browse the repository at this point in the history
  • Loading branch information
msproul committed Jun 20, 2024
1 parent 8cf0573 commit 90d1a41
Show file tree
Hide file tree
Showing 8 changed files with 120 additions and 76 deletions.
9 changes: 6 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
#++ Mar 5, 2023 <MLS> Re-organizing object lists
#++ Dec 2, 2023 <MLS> Added piswitch3
#++ Apr 22, 2024 <MLS> Added _INCLUDE_MULTI_LANGUAGE_SUPPORT_
#++ Jun 16, 2024 <MLS> Updated QSI Makefile entry
######################################################################################
# Cr_Core is for the Sony camera
######################################################################################
Expand Down Expand Up @@ -2440,14 +2441,16 @@ qsi : DEFINEFLAGS += -D_ENABLE_QSI_
qsi : DEFINEFLAGS += -D_USE_OPENCV_
qsi : INCLUDES += -I$(QSI_INCLUDE_DIR)
qsi : \
$(CPP_OBJECTS) \
$(DRIVER_OBJECTS) \
$(CAMERA_DRIVER_OBJECTS) \
$(SOCKET_OBJECTS) \
$(HELPER_OBJECTS) \

$(LINK) \
$(SOCKET_OBJECTS) \
$(CPP_OBJECTS) \
$(DRIVER_OBJECTS) \
$(CAMERA_DRIVER_OBJECTS) \
$(SOCKET_OBJECTS) \
$(HELPER_OBJECTS) \
$(OPENCV_LINK) \
-lcfitsio \
-lqsiapi \
Expand Down
27 changes: 15 additions & 12 deletions alpacapi_EditHistory.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
History Comments found =3502 in 522 files
History Comments found =3505 in 522 files
PDS_ReadNASAfiles.c:28 //* Jan 26, 1992 Reading of PDS files into Mac program from CD working
PDS_ReadNASAfiles.c:29 //* Mar 14, 1992 Starting on more detailed interpretation of label (header)
PDS_ReadNASAfiles.c:30 //* Mar 16, 1992 Changed number of displayed bytes from 836 to 800
Expand Down Expand Up @@ -2674,7 +2674,7 @@ rotatordriver_sim.cpp:26 //* Mar 2, 2023 <MLS> CONFORMU-rotatordriver_sim -> P
switchdriver_sim.cpp:25 //* Mar 2, 2023 <MLS> Created switchdriver_sim.cpp
switchdriver_sim.h:11 //* Mar 2, 2023 <MLS> Created switchdriver_sim.h
alpacadriver.cpp:157 //* Mar 3, 2023 <MLS> Added ProcessAlpacaCommand()
alpacadriver.cpp:4088 //* Mar 3, 2023 <MLS> Make CONFORMU happy, check for valid device number
alpacadriver.cpp:4089 //* Mar 3, 2023 <MLS> Make CONFORMU happy, check for valid device number
alpacadriver_helper.c:13 //* Mar 3, 2023 <MLS> Added FindDeviceTypeByStringLowerCase()
calibration_sim.cpp:20 //* Mar 3, 2023 <MLS> Created calibration_sim.cpp
cameradriver_SONY.cpp:1295 //* Mar 3, 2023 <MLS> this line caused a compile err
Expand Down Expand Up @@ -3482,13 +3482,16 @@ SkyTravelTimeRoutines.c:7 //* Jun 11, 2024 <MLS> Added SetCurrentTime()
windowtab_skytravel.cpp:129 //* Jun 11, 2024 <MLS> Changed cAutoAdvanceTime to global, gAutoAdvanceTime
windowtab_solarsystem.cpp:24 //* Jun 11, 2024 <MLS> Added time adjustment key commands identical to SkyTravel window
KeplerEquations.cpp:6 //* Jun 12, 2024 <MLS> Added ReadAsteroidElementsData()
windowtab_solarsystem.cpp:25 //* Jun 12, 2024 <MLS> DrawAsteriods() & DrawAstronomicalScale()
windowtab_solarsystem.cpp:25 //* Jun 12, 2024 <MLS> Added DrawAsteriods() & DrawAstronomicalScale()
windowtab_solarsystem.cpp:26 //* Jun 12, 2024 <MLS> Added DrawCrossHairs()
windowtab_solarsystem.cpp:27 //* Jun 13, 2024 <MLS> Added DrawKuiperBelt()
KeplerEquations.cpp:7 //* Jun 14, 2024 <MLS> Added ReadTransNeptunianData()
windowtab_solarsystem.cpp:28 //* Jun 14, 2024 <MLS> Added DrawOrbits()
cameradriver.cpp:212 //* Jun 15, 2024 <MLS> Fixed case bug in Put_SaveAsPNG()
alpaca_defs.h:100 //* Jun 16, 2024 <MLS> Build 179 - pushed to github
Makefile:68 #++ Jun 16, 2024 <MLS> Updated QSI Makefile entry
alpacadriver.cpp:194 //* Jun 17, 2024 <MLS> Fixed bug in ProcessCmdLineArgs(), -p6502 caused a segmentation fault
cameradriver_QSI.cpp:42 //* Jun 17, 2024 <MLS> Fixed bug in CreateCameraObjects_QSI() invalid camera count
cameradriver.cpp:214 //* Jan 1, 2119 <TODO> ----------------------------------------
cameradriver.cpp:215 //* Jun 26, 2119 <TODO> Add support for sub frames
cameradriver_png.cpp:33 //* Jan 31, 2120 <TODO> Add support for libpng
Expand All @@ -3501,19 +3504,19 @@ controller_camera.cpp:79 //* Feb 6, 2121 <TODO> Move downloading of images to
cameradriver_QHY.cpp:52 //* Oct 10, 2122 <TODO> Add support for percentcompleted to QHY camera driver
spectrodriver.cpp:33 //* May 7, 2123 <TODO> Add support for SlitID, SlitAngle, SlitWidth
controller_dome.cpp:47 //* Jun 25, 2123 <ADD> Add slaved to DeviceState
History Comments found = 3502 in 522 files
Total lines = 246837
Total comment Lines = 40475 (16.4%)
Total comments = 45460 (18.4%)
Total history comments = 3502 (1.4%)
History Comments found = 3505 in 522 files
Total lines = 246878
Total comment Lines = 40487 (16.4%)
Total comments = 45472 (18.4%)
Total history comments = 3505 (1.4%)
Total C files = 69
Total C++ files = 196
Total H files = 255
Preprocssor cnt = 7892
Total SLOC = 156858
Total SLOC-Logical = 120969
Preprocssor cnt = 7893
Total SLOC = 156884
Total SLOC-Logical = 120997
Programmer comment summary
MLS = 3092
MLS = 3095
TODO = 11
DDB = 1
JMH = 3
Expand Down
2 changes: 1 addition & 1 deletion download_extra_data.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ then
echo "Something is wrong, the folder exists but the data folder is missing"
fi
else
echo "Downloading via git................."
echo "Downloading milkyway outline data via git................."
git clone https://github.com/ofrohn/d3-celestial.git
fi

Expand Down
23 changes: 19 additions & 4 deletions src/alpacadriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@
//* May 18, 2024 <MLS> Added _DEBUG_MANAGEMENT_
//* May 18, 2024 <MLS> Fixed cSendJSONresponse bug, not initialized to true
//* Jun 1, 2024 <MLS> Global GPS now looks for Emlid and if found, uses that port
//* Jun 17, 2024 <MLS> Fixed bug in ProcessCmdLineArgs(), -p6502 caused a segmentation fault
//*****************************************************************************
//* to install code blocks 20
//* Step 1: sudo add-apt-repository ppa:codeblocks-devs/release
Expand Down Expand Up @@ -4376,6 +4377,8 @@ int iii;
char theChar;
int newListenPort;

// CONSOLE_DEBUG(__FUNCTION__);

for (iii=1; iii<argc; iii++)
{
if (argv[iii][0] == '-')
Expand Down Expand Up @@ -4427,16 +4430,28 @@ int newListenPort;

// -p specifies a port
case 'p':
iii++;
newListenPort = atoi(argv[iii]);
// CONSOLE_DEBUG_W_STR("argv[iii]\t=", argv[iii])

newListenPort = kAlpacaPiDefaultPORT;
if (isdigit(argv[iii][2]))
{
newListenPort = atoi(&argv[iii][2]);
}
else if (iii < (argc -1))
{
iii++;
newListenPort = atoi(argv[iii]);
}
if ((newListenPort > 1024) && (newListenPort <= 65535))
{
gAlpacaListenPort = newListenPort;
// CONSOLE_DEBUG_W_NUM("gAlpacaListenPort\t=", gAlpacaListenPort)
}
else
{
CONSOLE_DEBUG("Invalid listen port specified");
CONSOLE_ABORT(__FUNCTION__);
CONSOLE_DEBUG("Invalid listen port specified, using default");
CONSOLE_DEBUG_W_NUM("gAlpacaListenPort\t=", gAlpacaListenPort)
// CONSOLE_ABORT(__FUNCTION__);
}
break;

Expand Down
89 changes: 41 additions & 48 deletions src/cameradriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2478,63 +2478,55 @@ char gainString[32];

// CONSOLE_DEBUG(__FUNCTION__);

if (reqData != NULL)
gainFound = GetKeyWordArgument( reqData->contentData,
"Gain",
gainString,
(sizeof(gainString) -1));
if (gainFound)
{
gainFound = GetKeyWordArgument( reqData->contentData,
"Gain",
gainString,
(sizeof(gainString) -1));
if (gainFound)
if (IsValidNumericString(gainString))
{
if (IsValidNumericString(gainString))
newGainValue = atoi(gainString);
if ((newGainValue >= cCameraProp.GainMin) && (newGainValue <= cCameraProp.GainMax))
{
newGainValue = atoi(gainString);
if ((newGainValue >= cCameraProp.GainMin) && (newGainValue <= cCameraProp.GainMax))
{
alpacaErrCode = Write_Gain(newGainValue);
if (alpacaErrCode == kASCOM_Err_Success)
{
cCameraProp.Gain = newGainValue;
}
}
else
alpacaErrCode = Write_Gain(newGainValue);
if (alpacaErrCode == kASCOM_Err_Success)
{
alpacaErrCode = kASCOM_Err_InvalidValue;
reqData->httpRetCode = 400;
GENERATE_ALPACAPI_ERRMSG(alpacaErrMsg, "Gain value outside of min/max");
CONSOLE_DEBUG(alpacaErrMsg);
cCameraProp.Gain = newGainValue;
}
}
else
{
alpacaErrCode = kASCOM_Err_InvalidValue;
reqData->httpRetCode = 400;
GENERATE_ALPACAPI_ERRMSG(alpacaErrMsg, "Gain value is non-numeric");
GENERATE_ALPACAPI_ERRMSG(alpacaErrMsg, "Gain value outside of min/max");
CONSOLE_DEBUG(alpacaErrMsg);
}
}
else
{
alpacaErrCode = kASCOM_Err_InvalidValue;
reqData->httpRetCode = 400;
GENERATE_ALPACAPI_ERRMSG(alpacaErrMsg, "Gain not specified");
GENERATE_ALPACAPI_ERRMSG(alpacaErrMsg, "Gain value is non-numeric");
CONSOLE_DEBUG(alpacaErrMsg);
}
cBytesWrittenForThisCmd += JsonResponse_Add_Int32( reqData->socket,
reqData->jsonTextBuffer,
kMaxJsonBuffLen,
gValueString,
cCameraProp.Gain,
INCLUDE_COMMA);
}
else
{
alpacaErrCode = kASCOM_Err_InternalError;
alpacaErrCode = kASCOM_Err_InvalidValue;
reqData->httpRetCode = 400;
GENERATE_ALPACAPI_ERRMSG(alpacaErrMsg, "Gain not specified");
CONSOLE_DEBUG(alpacaErrMsg);
}
cBytesWrittenForThisCmd += JsonResponse_Add_Int32( reqData->socket,
reqData->jsonTextBuffer,
kMaxJsonBuffLen,
gValueString,
cCameraProp.Gain,
INCLUDE_COMMA);
return(alpacaErrCode);
}


//*****************************************************************************
TYPE_ASCOM_STATUS CameraDriver::Get_GainMax(TYPE_GetPutRequestData *reqData, char *alpacaErrMsg, const char *responseString)
{
Expand Down Expand Up @@ -2827,20 +2819,13 @@ TYPE_ASCOM_STATUS alpacaErrCode = kASCOM_Err_InternalError;

if (cOffsetSupported)
{
if (reqData != NULL)
{
cBytesWrittenForThisCmd += JsonResponse_Add_Int32( reqData->socket,
reqData->jsonTextBuffer,
kMaxJsonBuffLen,
responseString, //gValueString,
cCameraProp.Offset,
INCLUDE_COMMA);
alpacaErrCode = kASCOM_Err_Success;
}
else
{
alpacaErrCode = kASCOM_Err_InternalError;
}
cBytesWrittenForThisCmd += JsonResponse_Add_Int32( reqData->socket,
reqData->jsonTextBuffer,
kMaxJsonBuffLen,
responseString, //gValueString,
cCameraProp.Offset,
INCLUDE_COMMA);
alpacaErrCode = kASCOM_Err_Success;
}
else
{
Expand Down Expand Up @@ -3695,18 +3680,19 @@ double myExposureDuration_secs;
double myExposure_usecs;
bool lightFrame;

if (cVerboseDebug)
// if (cVerboseDebug)
{
CONSOLE_DEBUG(__FUNCTION__);
CONSOLE_DEBUG_W_NUM("currentROIimageType\t=", cROIinfo.currentROIimageType);
CONSOLE_DEBUG_W_STR("contentData \t=", reqData->contentData);
// CONSOLE_DEBUG_W_STR("contentData \t=", reqData->contentData);
// CONSOLE_DEBUG_W_STR("htmlData\r\n", reqData->htmlData);
DumpRequestStructure(__FUNCTION__, reqData);
}

if (reqData != NULL)
{
lightFrame = true;


//* first we are going to check a bunch of stuff to make CONFORM happy
if ((cCameraProp.CanAsymmetricBin == false) && (cCameraProp.BinX != cCameraProp.BinY))
{
Expand Down Expand Up @@ -3790,6 +3776,13 @@ bool lightFrame;
"exposure",
currExposure_secs,
INCLUDE_COMMA);

cBytesWrittenForThisCmd += JsonResponse_Add_Bool(reqData->socket,
reqData->jsonTextBuffer,
kMaxJsonBuffLen,
"Light",
lightFrame,
INCLUDE_COMMA);
}
else
{
Expand Down
24 changes: 22 additions & 2 deletions src/cameradriver_QSI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
//* May 18, 2022 <MLS> Added Write_SensorTemp()
//* May 18, 2022 <MLS> SUPPORTED: QSI cameras
//* Jun 7, 2022 <MLS> Added maxbinx/y override until binning is implemented
//* Jun 17, 2024 <MLS> Fixed bug in CreateCameraObjects_QSI() invalid camera count
//*****************************************************************************

#if defined(_ENABLE_CAMERA_) && defined(_ENABLE_QSI_)
Expand Down Expand Up @@ -78,11 +79,29 @@ std::string text;
std::string lastError("");
int numCamerasFound;
QSICamera cQSIcam;
bool rulesFileOK;
char rulesFileName[] = "99-qsi.rules";

CONSOLE_DEBUG(__FUNCTION__);

numCamerasFound = 0;
camSerial[0] = "";
numCamerasFound = 0;
cameraCreatedCount = 0;
camSerial[0] = "";

//----------------------------------------------------------------------
//* check the rules file
rulesFileOK = Check_udev_rulesFile(rulesFileName);
if (rulesFileOK == false)
{
LogEvent( "camera",
"Problem with QSI rules",
NULL,
kASCOM_Err_Success,
rulesFileName);
CONSOLE_DEBUG_W_STR("QSI Rules file is not installed:", rulesFileName);
}


cQSIcam.put_UseStructuredExceptions(false);
qsi_Result = cQSIcam.get_DriverInfo(info);
if (qsi_Result == QSI_OK)
Expand Down Expand Up @@ -118,6 +137,7 @@ QSICamera cQSIcam;
{
//* for debugging without a camera
new CameraDriverQSI(0, camSerial[0]);
cameraCreatedCount++;
}
}
else
Expand Down
3 changes: 1 addition & 2 deletions src_skytravel/windowtab_fov.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -932,7 +932,6 @@ char textString[512];
char offsetsString[64];
char tempString[64];
int myDevCount;
bool hostNameIsIncluded;
int hostNameLen;

// CONSOLE_DEBUG(__FUNCTION__);
Expand Down Expand Up @@ -965,7 +964,7 @@ int hostNameLen;
if (cRemoteDeviceList[iii].alpacaDeviceNum > 0)
{
//* if the device number is not 0, we want to display it
sprintf(tempString, "%:%d",cRemoteDeviceList[iii].alpacaDeviceNum);
sprintf(tempString, ":%d",cRemoteDeviceList[iii].alpacaDeviceNum);
strcat(nameString, tempString);
}

Expand Down
Loading

0 comments on commit 90d1a41

Please sign in to comment.