Skip to content

Commit

Permalink
Updated focuser sdk and filter wheel sdk, and support macOS (#1009)
Browse files Browse the repository at this point in the history
* Oasis Focuser INDI driver initial version

* Find Astroasis libraries

* Initial version for Oasis Focuser INDI driver

* Initial version for Oasis Focuser INDI driver

* Oasis Focuser SDK header file

* Added Astroasis driver

* Added readme and installation files

* Use version info from CMakeLists.txt

* Updated sdk version to 1.0.5

* Added spec file

* Updated for coding style

* Oasis focuser sdk lib file for armhf

* Oasis focuser sdk lib file for armhf

* Implemented ambient temeperature and backlash compensation direction setting, and optimized firmware version info

* Oasis focuser sdk lib file for x64

* Disable build for x86

* Fix incorrect Vender ID for Astroasis USB devices

* Fixed incorrect max position value

* Added libastroasis for building indi-astroasis on Fedora COPR

* Fix spelling

* Update for compilation and installation instructions

* Add Oasis Filter Wheel driver

* Add Oasis Filter Wheel driver

* Add Oasis filter wheel library file for 32bit arm

* Add Oasis filter wheel library file for 64bit arm

* Update indi-astroasis change log

* Add Oasis Filter Wheel driver library files

* Update for coding style

* Updated liboasisfocuser to improve stability of USB HID communication with Raspberry PI

* Updated liboasisfocuser to improve stability of USB HID communication with Raspberry PI

* Updated liboasisfocuser to improve stability of USB HID communication with Raspberry PI

* Updated focuser sdk and filer wheel sdk

* Add focuser and filter wheel dynamic library file for macOS

* Enable astroasis for macOS
  • Loading branch information
astroasis authored Dec 16, 2024
1 parent a3cdd79 commit 0cd5c62
Show file tree
Hide file tree
Showing 14 changed files with 92 additions and 38 deletions.
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,6 @@ IF (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(WITH_GPSD Off)
set(WITH_AHP_XC Off)
set(WITH_AHP_GT Off)
set(WITH_ASTROASIS Off)
# The drivers below are not yet compatible with Apple Silicon since their libraries are not universal binaries
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64")
SET(WITH_ASICAM Off)
Expand Down
44 changes: 22 additions & 22 deletions indi-astroasis/oasis_filter_wheel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ bool OasisFilterWheel::initProperties()
{
INDI::FilterWheel::initProperties();

// Mode
IUFillSwitch(&ModeS[0], "MODE_0", "Fast", ISS_OFF);
IUFillSwitch(&ModeS[1], "MODE_1", "Normal", ISS_OFF);
IUFillSwitch(&ModeS[2], "MODE_2", "Slow", ISS_OFF);
IUFillSwitchVector(&ModeSP, ModeS, 3, getDeviceName(), "MODE", "Mode",
// Speed
IUFillSwitch(&SpeedS[0], "SPEED_FAST", "Fast", ISS_OFF);
IUFillSwitch(&SpeedS[1], "SPEED_NORMAL", "Normal", ISS_OFF);
IUFillSwitch(&SpeedS[2], "SPEED_SLOW", "Slow", ISS_OFF);
IUFillSwitchVector(&SpeedSP, SpeedS, 3, getDeviceName(), "SPEED", "Speed",
MAIN_CONTROL_TAB, IP_RW, ISR_ATMOST1, 0, IPS_IDLE);

// Auto run on power up
Expand Down Expand Up @@ -87,23 +87,23 @@ bool OasisFilterWheel::updateProperties()
AutoRunS[INDI_ENABLED].s = config.autorun ? ISS_ON : ISS_OFF;
AutoRunS[INDI_DISABLED].s = config.autorun ? ISS_OFF : ISS_ON;

ModeS[0].s = (config.mode == 0) ? ISS_ON : ISS_OFF;
ModeS[1].s = (config.mode == 1) ? ISS_ON : ISS_OFF;
ModeS[2].s = (config.mode == 2) ? ISS_ON : ISS_OFF;
SpeedS[0].s = (config.speed == 0) ? ISS_ON : ISS_OFF;
SpeedS[1].s = (config.speed == 1) ? ISS_ON : ISS_OFF;
SpeedS[2].s = (config.speed == 2) ? ISS_ON : ISS_OFF;
}
else
{
AutoRunSP.s = IPS_ALERT;
}

defineProperty(&ModeSP);
defineProperty(&SpeedSP);
defineProperty(&AutoRunSP);
defineProperty(&FactoryResetSP);
defineProperty(&CalibrateSP);
}
else
{
deleteProperty(ModeSP.name);
deleteProperty(SpeedSP.name);
deleteProperty(AutoRunSP.name);
deleteProperty(FactoryResetSP.name);
deleteProperty(CalibrateSP.name);
Expand Down Expand Up @@ -240,38 +240,38 @@ bool OasisFilterWheel::ISNewSwitch(const char *dev, const char *name, ISState *s
{
if (dev != nullptr && !strcmp(dev, getDeviceName()))
{
if (!strcmp(name, ModeSP.name))
if (!strcmp(name, SpeedSP.name))
{
OFWConfig config;
AOReturn ret;
int prev, target;

prev = IUFindOnSwitchIndex(&ModeSP);
IUUpdateSwitch(&ModeSP, states, names, n);
target = IUFindOnSwitchIndex(&ModeSP);
prev = IUFindOnSwitchIndex(&SpeedSP);
IUUpdateSwitch(&SpeedSP, states, names, n);
target = IUFindOnSwitchIndex(&SpeedSP);

config.mask = MASK_MODE;
config.mode = target;
config.mask = MASK_SPEED;
config.speed = target;

ret = OFWSetConfig(mID, &config);

if (ret == AO_SUCCESS)
{
ModeSP.s = IPS_OK;
SpeedSP.s = IPS_OK;
}
else
{
LOGF_ERROR("Failed to set Oasis filter wheel mode, ret = %d\n", ret);
LOGF_ERROR("Failed to set Oasis filter wheel speed, ret = %d\n", ret);

IUResetSwitch(&ModeSP);
IUResetSwitch(&SpeedSP);

if ((prev >= 0) && (prev < 3))
ModeS[prev].s = ISS_ON;
SpeedS[prev].s = ISS_ON;

ModeSP.s = IPS_ALERT;
SpeedSP.s = IPS_ALERT;
}

IDSetSwitch(&ModeSP, nullptr);
IDSetSwitch(&SpeedSP, nullptr);

return true;
}
Expand Down
6 changes: 3 additions & 3 deletions indi-astroasis/oasis_filter_wheel.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ class OasisFilterWheel : public INDI::FilterWheel

bool GetConfig(OFWConfig *config);

// Mode
ISwitchVectorProperty ModeSP;
ISwitch ModeS[3];
// Speed
ISwitchVectorProperty SpeedSP;
ISwitch SpeedS[3];

// Auto run on power up
ISwitchVectorProperty AutoRunSP;
Expand Down
32 changes: 29 additions & 3 deletions libastroasis/AOFocus.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 Suzhou Astroasis Vision Technology, Inc. All Rights Reserved.
* Copyright 2024 Suzhou Astroasis Vision Technology, Inc. All Rights Reserved.
*
* This is header file for Astroasis Oasis Focuser.
*
Expand Down Expand Up @@ -31,6 +31,7 @@
* AOFocuserMove(int id, int step);
* AOFocuserMoveTo(int id, int position);
* AOFocuserStopMove(int id);
* AOFocuserClearStall(int id);
* AOFocuserFirmwareUpgrade(int id, unsigned char *data, int len);
* AOFocuserGetSDKVersion(char *version);
*
Expand All @@ -50,12 +51,22 @@ extern "C" {
#define AOAPI
#endif

#define VERSION_INVALID 0

#define PROTOCAL_VERSION_16_0_3 0x10000300
#define PROTOCAL_VERSION_16_1_0 0x10010000

#define AO_FOCUSER_MAX_NUM 32 /* Maximum focuser numbers supported by this SDK */
#define AO_FOCUSER_VERSION_LEN 32 /* Buffer length for version strings */
#define AO_FOCUSER_NAME_LEN 32 /* Buffer length for name strings */

#define TEMPERATURE_INVALID 0x80000000 /* This value indicates the invalid value of ambient temperature */

#define AO_LOG_LEVEL_QUIET 0
#define AO_LOG_LEVEL_ERROR 1
#define AO_LOG_LEVEL_INFO 2
#define AO_LOG_LEVEL_DEBUG 3

typedef enum _AOReturn {
AO_SUCCESS = 0, /* Success */
AO_ERROR_INVALID_ID, /* Device ID is invalid */
Expand Down Expand Up @@ -85,6 +96,10 @@ typedef enum _AOReturn {
#define MASK_BEEP_ON_MOVE 0x00000020
#define MASK_BEEP_ON_STARTUP 0x00000040
#define MASK_BLUETOOTH 0x00000080
#define MASK_STALL_DETECTION 0x00000100
#define MASK_HEATING_TEMPERATURE 0x00000200
#define MASK_HEATING_ON 0x00000400
#define MASK_USB_POWER_CAPACITY 0x00000800
#define MASK_ALL 0xFFFFFFFF

typedef struct _AOFocuserVersion
Expand All @@ -105,6 +120,10 @@ typedef struct _AOFocuserConfig {
int beepOnMove; /* 0 - Turn off beep for move, others - Turn on beep for move */
int beepOnStartup; /* 0 - Turn off beep for device startup, others - Turn on beep for device startup */
int bluetoothOn; /* 0 - Turn off Bluetooth, others - Turn on Bluetooth */
int stallDetection; /* 0 - Turn off motor stall detection, others - Turn on motor stall detection */
int heatingTemperature; /* Target heating temperature in 0.01 degree unit */
int heatingOn; /* 0 - Turn off heating, others - Turn on heating */
int usbPowerCapacity; /* 0 - 500mA, 1 - 1000mA or higher */
} AOFocuserConfig;

/*
Expand All @@ -117,7 +136,12 @@ typedef struct _AOFocuserStatus {
int temperatureExt; /* External (ambient) temperature in 0.01 degree unit */
int temperatureDetection; /* 0 - ambient temperature probe is not inserted, others - ambient temperature probe is inserted */
int position; /* Current motor position */
int moving; /* 0 - Motor is not moving, others - Motor is moving */
int moving; /* 0 - motor is not moving, others - Motor is moving */
int stallDetection; /* 0 - motor stall is not detected, others - motor stall detected */
int heatingOn; /* 0 - heating is disabled, others - heating is enabled */
int heatingPower; /* Current heating power in 1% unit */
int dcPower; /* Current DC power in 0.1V unit */
int reserved[20];
} AOFocuserStatus;

/*
Expand All @@ -142,7 +166,7 @@ typedef struct _AOFocuserStatus {
*
* Remarks
* This function should be called before any other APIs except for
* AOCameraGetSDKVersion().
* AOFocuserGetSDKVersion().
* Each focuser has a unique ID. If one focuser is removed from USB port
* and then plugged in again, it will be considered as different focuser
* and will be assigned with different ID during next scan. If one focuser
Expand Down Expand Up @@ -170,9 +194,11 @@ AOAPI AOReturn AOFocuserSyncPosition(int id, int position);
AOAPI AOReturn AOFocuserMove(int id, int step);
AOAPI AOReturn AOFocuserMoveTo(int id, int position);
AOAPI AOReturn AOFocuserStopMove(int id);
AOAPI AOReturn AOFocuserClearStall(int id);
AOAPI AOReturn AOFocuserUpgrade(int id);
AOAPI AOReturn AOFocuserFirmwareUpgrade(int id, unsigned char *data, int len);
AOAPI AOReturn AOFocuserGetSDKVersion(char *version);
AOAPI AOReturn AOFocuserSetLogLevel(int level);

#ifdef __cplusplus
}
Expand Down
6 changes: 3 additions & 3 deletions libastroasis/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
cmake_minimum_required(VERSION 3.16)
project (libastroasis)

set (OASIS_FOCUSER_VERSION "1.0.7")
set (OASIS_FOCUSER_SOVERSION "1")
set (OASIS_FOCUSER_VERSION "2.0.2")
set (OASIS_FOCUSER_SOVERSION "2")

set (OASIS_FILTER_WHEEL_VERSION "1.0.0")
set (OASIS_FILTER_WHEEL_VERSION "1.2.1")
set (OASIS_FILTER_WHEEL_SOVERSION "1")

list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules/")
Expand Down
41 changes: 35 additions & 6 deletions libastroasis/OasisFilterWheel.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Copyright 2023 Suzhou Astroasis Vision Technology, Inc. All Rights Reserved.
* Copyright 2024 Suzhou Astroasis Vision Technology, Inc. All Rights Reserved.
*
* This is header file for Astroasis Oasis Filter Wheel .
* This is header file for Astroasis Oasis Filter Wheel.
*
* Note:
* 1. OFWScan() should be called before any other APIs (except for
Expand Down Expand Up @@ -40,6 +40,7 @@
* OFWGetCalibrateData(int id, AOCalibrateData* calibrate);
* OFWFirmwareUpgrade(int id, unsigned char *data, int len);
* OFWGetSDKVersion(char *version);
* OFWSetLogLevel(int level);
*
* Refer to SDK demo application for the details of the API usage.
*/
Expand All @@ -57,11 +58,21 @@ extern "C" {
#define AOAPI
#endif

#define VERSION_INVALID 0

#define PROTOCAL_VERSION_1_1_0 0x01010000
#define PROTOCAL_VERSION_1_2_0 0x01020000

#define OFW_MAX_NUM 32 /* Maximum filter wheel numbers supported by this SDK */
#define OFW_VERSION_LEN 32 /* Buffer length for version strings */
#define OFW_NAME_LEN 32 /* Buffer length for name strings */
#define OFW_SLOT_NAME_LEN 16 /* Buffer length for slot name strings */

#define AO_LOG_LEVEL_QUIET 0
#define AO_LOG_LEVEL_ERROR 1
#define AO_LOG_LEVEL_INFO 2
#define AO_LOG_LEVEL_DEBUG 3

typedef enum _AOReturn {
AO_SUCCESS = 0, /* Success */
AO_ERROR_INVALID_ID, /* Device ID is invalid */
Expand All @@ -83,9 +94,10 @@ typedef enum _AOReturn {
/*
* Used by OFWSetConfig() to indicate which field wants to be set
*/
#define MASK_MODE 0x00000001
#define MASK_SPEED 0x00000001
#define MASK_AUTORUN 0x00000002
#define MASK_BLUETOOTH 0x00000004
#define MASK_TURBO 0x00000008
#define MASK_ALL 0xFFFFFFFF

/*
Expand All @@ -104,20 +116,36 @@ typedef struct _OFWVersion
char built[24]; /* Null-terminated string which indicates firmware building time */
} OFWVersion;

/*
* Since protocal version 1.1.0:
* 1. Changed field "mode" to "speed"
* 2. Added field "turbo"
*/
typedef struct _OFWConfig {
unsigned int mask; /* Used by OFWSetConfig() to indicates which field wants to be set */
int mode; /* Mode of the filter wheel operation */
int autorun; /* Automatic switch to the target slot when power on */
unsigned int mask; /* Used by OFWSetConfig() to indicate which field wants to be set */
int speed; /* Motor speed. 0 - Fast, 1 - Normal, 2 - Slow */
int autorun; /* Automatic switch to the target slot when power on. 0 - Do not switch, 1 - Auto switch */
int bluetoothOn; /* 0 - Turn off Bluetooth, others - Turn on Bluetooth */
int turbo; /* 0 - Turn off turbo mode, others - Turn on turbo mode */
} OFWConfig;

typedef struct _OFWStatus {
int temperature; /* Internal (on board) temperature in 0.01 degree unit */
int filterStatus; /* Current motor position */
int filterPosition; /* Current motor position, zero - unknown position */
int seq; /* Sequence number for debug purpose */
} OFWStatus;

/*
* Since protocal version 1.1.0
* 1. Added field "index"
* 2. Added field "active"
* 3. Added field "temperature"
*/
typedef struct _OFWCalibrateData {
int index; /* Index of the calibration data */
int active; /* 0 - Non-active calibration data, 1 - Active calibration data */
int temperature; /* Calibration temperature */
int low[4]; /* Calibration low value */
int high[4]; /* Calibration high value */
} OFWCalibrateData;
Expand Down Expand Up @@ -182,6 +210,7 @@ AOAPI AOReturn OFWGetCalibrateData(int id, OFWCalibrateData *calibrate);
AOAPI AOReturn OFWUpgrade(int id);
AOAPI AOReturn OFWFirmwareUpgrade(int id, unsigned char *data, int len);
AOAPI AOReturn OFWGetSDKVersion(char *version);
AOAPI AOReturn OFWSetLogLevel(int level);

#ifdef __cplusplus
}
Expand Down
Binary file modified libastroasis/arm64/liboasisfilterwheel.bin
Binary file not shown.
Binary file modified libastroasis/arm64/liboasisfocuser.bin
Binary file not shown.
Binary file modified libastroasis/armhf/liboasisfilterwheel.bin
Binary file not shown.
Binary file modified libastroasis/armhf/liboasisfocuser.bin
Binary file not shown.
Binary file added libastroasis/mac/liboasisfilterwheel.bin
Binary file not shown.
Binary file added libastroasis/mac/liboasisfocuser.bin
Binary file not shown.
Binary file modified libastroasis/x64/liboasisfilterwheel.bin
Binary file not shown.
Binary file modified libastroasis/x64/liboasisfocuser.bin
Binary file not shown.

0 comments on commit 0cd5c62

Please sign in to comment.