diff --git a/drivers.xml b/drivers.xml index 6ccf58b079..da691c0579 100644 --- a/drivers.xml +++ b/drivers.xml @@ -753,10 +753,6 @@ indi_wandererbox_pro_v3 1.0 - - indi_wandererbox_plus_v3 - 1.0 - diff --git a/drivers/auxiliary/CMakeLists.txt b/drivers/auxiliary/CMakeLists.txt index dfb862db22..b68e845325 100644 --- a/drivers/auxiliary/CMakeLists.txt +++ b/drivers/auxiliary/CMakeLists.txt @@ -1,15 +1,6 @@ IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux") INSTALL(FILES 99-indi_auxiliary.rules DESTINATION ${UDEVRULES_INSTALL_DIR}) ENDIF() -# ########## Wanderer Box Plus V3 ############### -SET(indi_wandererbox_plus_v3_SRC - wandererbox_plus_v3.cpp) - -add_executable(indi_wandererbox_plus_v3 ${indi_wandererbox_plus_v3_SRC}) -target_link_libraries(indi_wandererbox_plus_v3 indidriver) -install(TARGETS indi_wandererbox_plus_v3 RUNTIME DESTINATION bin) - - # ########## Wanderer Box Pro V3 ############### SET(indi_wandererbox_pro_v3_SRC wandererbox_pro_v3.cpp) diff --git a/drivers/auxiliary/wandererbox_plus_v3.cpp b/drivers/auxiliary/wandererbox_plus_v3.cpp deleted file mode 100644 index 83ac7e3713..0000000000 --- a/drivers/auxiliary/wandererbox_plus_v3.cpp +++ /dev/null @@ -1,692 +0,0 @@ -/******************************************************************************* - Copyright(c) 2015 Jasem Mutlaq. All rights reserved. - - WandererBox Plus V3 - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2 of the License, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. - - The full GNU General Public License is included in this distribution in the - file called LICENSE. -*******************************************************************************/ - -#include "wandererbox_plus_v3.h" -#include "indicom.h" -#include "connectionplugins/connectionserial.h" -#include -#include -#include -#include -#include -#include -#include -#include - -// We declare an auto pointer to WandererBoxPlusV3. -static std::unique_ptr wandererboxplusv3(new WandererBoxPlusV3()); - - - -WandererBoxPlusV3::WandererBoxPlusV3() -{ - setVersion(1, 0); -} - -bool WandererBoxPlusV3::initProperties() -{ - - INDI::DefaultDevice::initProperties(); - setDriverInterface(AUX_INTERFACE); - - - addAuxControls(); - - - // Calibrate - IUFillSwitch(&CalibrateS[0], "Calibrate", "Calibrate Current", ISS_OFF); - IUFillSwitchVector(&CalibrateSP, CalibrateS, 1, getDeviceName(), "Calibrate_DEVICE", "Calibrate Current", MAIN_CONTROL_TAB, IP_RW, ISR_ATMOST1,60, IPS_IDLE); - - // Power Monitor - IUFillNumber(&PowerMonitorN[VOLTAGE], "VOLTAGE", "Voltage (V)", "%4.2f", 0, 999, 100, 0); - IUFillNumber(&PowerMonitorN[TOTAL_CURRENT], "TOTAL_CURRENT", "Total Current (A)", "%4.2f", 0, 999, 100, 0); - IUFillNumberVector(&PowerMonitorNP, PowerMonitorN, 2, getDeviceName(), "POWER_Monitor", "Power Monitor", MAIN_CONTROL_TAB, IP_RO,60, IPS_IDLE); - - - - // Firmware version - IUFillText(&FirmwareT[0], "Version", "Version", nullptr); - - - // USB Control - IUFillSwitch(&USBControlS[INDI_ENABLED], "INDI_ENABLED", "On", ISS_OFF); - IUFillSwitch(&USBControlS[INDI_DISABLED], "INDI_DISABLED", "Off", ISS_ON); - IUFillSwitchVector(&USBControlSP, USBControlS, 2, getDeviceName(), "USB3.0_1", "USB3.0_1", MAIN_CONTROL_TAB, IP_RW,ISR_1OFMANY, 60, IPS_IDLE); - - - // DC3 - IUFillNumber(&DC3ControlN[DC3], "DC3", "Dew Heater (PWM)", "%.2f", 0, 255, 5, 0); - IUFillNumberVector(&DC3ControlNP, DC3ControlN, 1, getDeviceName(), "PWM", "DC3", DC3_TAB, IP_RW, 60, IPS_IDLE); - - // DC2SET - IUFillNumber(&setDC2voltageN[setDC2voltage], "DC2SET", "Adjustable Voltage", "%.2f", 5, 13.2, 0.1, 0); - IUFillNumberVector(&setDC2voltageNP, setDC2voltageN, 1, getDeviceName(), "DC2voltageSET", "Set DC2", MAIN_CONTROL_TAB, IP_RW, 60, IPS_IDLE); - // DC2 Control - IUFillSwitch(&DC2ControlS[INDI_ENABLED], "INDI_ENABLED", "On", ISS_OFF); - IUFillSwitch(&DC2ControlS[INDI_DISABLED], "INDI_DISABLED", "Off", ISS_ON); - IUFillSwitchVector(&DC2ControlSP, DC2ControlS, 2, getDeviceName(), "DC2", "DC2", MAIN_CONTROL_TAB, IP_RW,ISR_1OFMANY, 60, IPS_IDLE); - - // DC4-6 Control - IUFillSwitch(&DC4_6ControlS[INDI_ENABLED], "INDI_ENABLED", "On", ISS_OFF); - IUFillSwitch(&DC4_6ControlS[INDI_DISABLED], "INDI_DISABLED", "Off", ISS_ON); - IUFillSwitchVector(&DC4_6ControlSP, DC4_6ControlS, 2, getDeviceName(), "DC4-6", "DC4-6", MAIN_CONTROL_TAB, IP_RW,ISR_1OFMANY, 60, IPS_IDLE); - - // DC3 TEMP Difference Control - IUFillSwitch(&DC3diffS[DC3_Manual], "Manual", "Manual", ISS_ON); - IUFillSwitch(&DC3diffS[DC3_DPD_Mode], "DPD_Mode", "DPD Mode", ISS_OFF); - IUFillSwitch(&DC3diffS[DC3_CT_Mode], "CT_Mode", "CT Mode", ISS_OFF); - IUFillSwitchVector(&DC3dewSP, DC3diffS, 3, getDeviceName(), "DC3_DIFF", "DC3 Dew Mode", DC3_TAB, IP_RW,ISR_1OFMANY, 60, IPS_IDLE); - - IUFillNumber(&DC3diffSETN[DC3DIFFSET], "DC3 Auto Control", "Dew Point Difference(C)", "%.2f", 10, 30, 1, 0); - IUFillNumberVector(&DC3diffSETNP, DC3diffSETN, 1, getDeviceName(), "DC3_DIFF_SET", "DPD Mode", DC3_TAB, IP_RW, 60, IPS_IDLE); - - IUFillNumber(&DC3constSETN[DC3CONSTSET], "DC3 Auto Control", "Temperature(C)", "%.2f", 0, 40, 1, 0); - IUFillNumberVector(&DC3constSETNP, DC3constSETN, 1, getDeviceName(), "DC3_CONST_SET", "CT Mode", DC3_TAB, IP_RW, 60, IPS_IDLE); - - //ENV - IUFillNumber(&ENVMonitorN[Probe1_Temp], "Probe1_Temp", "Probe1 Temperature (C)", "%4.2f", 0, 999, 100, 0); - IUFillNumber(&ENVMonitorN[ENV_Humidity], "ENV_Humidity", "Ambient Humidity %", "%4.2f", 0, 999, 100, 0); - IUFillNumber(&ENVMonitorN[ENV_Temp], "ENV_Temp", "Ambient Temperature (C)", "%4.2f", 0, 999, 100, 0); - IUFillNumber(&ENVMonitorN[DEW_Point], "DEW_Point", "Dew Point (C)", "%4.2f", 0, 999, 100, 0); - IUFillNumberVector(&ENVMonitorNP, ENVMonitorN, 4, getDeviceName(), "ENV_Monitor", "Environment",ENVIRONMENT_TAB, IP_RO,60, IPS_IDLE); - serialConnection = new Connection::Serial(this); - serialConnection->setDefaultBaudRate(Connection::Serial::B_19200); - serialConnection->registerHandshake([&]() - { - return getData(); - }); - registerConnection(serialConnection); - - return true; -} - -bool WandererBoxPlusV3::getData() -{ - try - { - PortFD = serialConnection->getPortFD(); - tcflush(PortFD, TCIOFLUSH); - int nbytes_read_name = 0,rc=-1; - char name[64] = {0}; - - //Device Model////////////////////////////////////////////////////////////////////////////////////////////////////// - if ((rc = tty_read_section(PortFD, name, 'A', 3, &nbytes_read_name)) != TTY_OK) - { - char errorMessage[MAXRBUF]; - tty_error_msg(rc, errorMessage, MAXRBUF); - LOGF_INFO("No data received, the device may not be WandererBox Pro V3, please check the serial port!","Updated"); - LOGF_ERROR("Device read error: %s", errorMessage); - return false; - } - name[nbytes_read_name - 1] = '\0'; - if(strcmp(name, "ZXWBProV3")==0||strcmp(name, "WandererCoverV4")==0||strcmp(name, "UltimateV2")==0||strcmp(name, "PlusV2")==0) - { - LOGF_INFO("The device is not WandererBox Pro V3!","Updated"); - return false; - } - if(strcmp(name, "ZXWBPlusV3")!=0) - throw std::exception(); - // Frimware version///////////////////////////////////////////////////////////////////////////////////////////// - int nbytes_read_version = 0; - char version[64] = {0}; - tty_read_section(PortFD, version, 'A', 5, &nbytes_read_version); - - version[nbytes_read_version - 1] = '\0'; - IUSaveText(&FirmwareT[0], version); - IDSetText(&FirmwareTP, nullptr); - if(std::stoi(version)<=20240216) - { - deleteProperty(CalibrateSP.name); - } - - // Temp probe 1////////////////////////////////////////////////////////////////////////////////////////// - char temp1[64] = {0}; - int nbytes_read_temp1= 0; - tty_read_section(PortFD, temp1, 'A', 5, &nbytes_read_temp1); - temp1[nbytes_read_temp1 - 1] = '\0'; - temp1read = std::strtod(temp1,NULL); - - // DHTH////////////////////////////////////////////////////////////////////////////////////////// - char DHTH[64] = {0}; - int nbytes_read_DHTH= 0; - tty_read_section(PortFD, DHTH, 'A', 5, &nbytes_read_DHTH); - DHTH[nbytes_read_DHTH - 1] = '\0'; - DHTHread = std::strtod(DHTH,NULL); - - // DHTT////////////////////////////////////////////////////////////////////////////////////////// - char DHTT[64] = {0}; - int nbytes_read_DHTT= 0; - tty_read_section(PortFD, DHTT, 'A', 5, &nbytes_read_DHTT); - DHTT[nbytes_read_DHTT - 1] = '\0'; - DHTTread = std::strtod(DHTT,NULL); - updateENV(temp1read,DHTHread,DHTTread); - - // Total current////////////////////////////////////////////////////////////////////////////////////////// - char Tcurrent[64] = {0}; - int nbytes_read_Tcurrent= 0; - tty_read_section(PortFD, Tcurrent, 'A', 5, &nbytes_read_Tcurrent); - Tcurrent[nbytes_read_Tcurrent - 1] = '\0'; - Tcurrentread = std::strtod(Tcurrent,NULL); - - - // Voltage////////////////////////////////////////////////////////////////////////////////////////// - char voltage[64] = {0}; - int nbytes_read_voltage= 0; - tty_read_section(PortFD, voltage, 'A', 5, &nbytes_read_voltage); - voltage[nbytes_read_voltage - 1] = '\0'; - voltageread = std::strtod(voltage,NULL); - updatePower(Tcurrentread,voltageread); - - // USB////////////////////////////////////////////////////////////////////////////////////////// - char USB[64] = {0}; - int nbytes_read_USB= 0; - tty_read_section(PortFD, USB, 'A', 5, &nbytes_read_USB); - USB[nbytes_read_USB - 1] = '\0'; - USBread = std::stoi(USB); - updateUSB(USBread); - - // DC2////////////////////////////////////////////////////////////////////////////////////////// - char DC2[64] = {0}; - int nbytes_read_DC2= 0; - tty_read_section(PortFD, DC2, 'A', 5, &nbytes_read_DC2); - DC2[nbytes_read_DC2 - 1] = '\0'; - DC2read = std::stoi(DC2); - updateDC2(DC2read); - - // DC3////////////////////////////////////////////////////////////////////////////////////////// - char DC3[64] = {0}; - int nbytes_read_DC3= 0; - tty_read_section(PortFD, DC3, 'A', 5, &nbytes_read_DC3); - DC3[nbytes_read_DC3 - 1] = '\0'; - DC3read = std::stoi(DC3); - updateDC3(DC3read); - - - // DC4_6////////////////////////////////////////////////////////////////////////////////////////// - char DC4_6[64] = {0}; - int nbytes_read_DC4_6= 0; - tty_read_section(PortFD, DC4_6, 'A', 5, &nbytes_read_DC4_6); - DC4_6[nbytes_read_DC4_6 - 1] = '\0'; - DC4_6read =std::stoi(DC4_6); - updateDC4_6(DC4_6read); - - // DC2SET////////////////////////////////////////////////////////////////////////////////////////// - char DC2SET[64] = {0}; - int nbytes_read_DC2SET= 0; - tty_read_section(PortFD, DC2SET, 'A', 5, &nbytes_read_DC2SET); - DC2SET[nbytes_read_DC2SET - 1] = '\0'; - //LOGF_INFO("All Data Updated","Updated"); - DC2SETread = std::stoi(DC2SET); - updateDC2SET(DC2SETread); - - //DC3 DEW CONTROL - if(DC3DIFFMODE==true ) - { - if(temp1read(values[i])); - } - - DC3ControlNP.s = (rc1) ? IPS_OK : IPS_ALERT; - if (DC3ControlNP.s == IPS_OK) - IUUpdateNumber(&DC3ControlNP, values, names, n); - IDSetNumber(&DC3ControlNP, nullptr); - return true; - } - if (!strcmp(name, DC3diffSETNP.name)) - { - - DC3diffSETNP.s = IPS_OK ; - if (DC3diffSETNP.s == IPS_OK) - IUUpdateNumber(&DC3diffSETNP, values, names, n); - IDSetNumber(&DC3diffSETNP, nullptr); - return true; - } - if (!strcmp(name, DC3constSETNP.name)) - { - - DC3constSETNP.s = IPS_OK ; - if (DC3constSETNP.s == IPS_OK) - IUUpdateNumber(&DC3constSETNP, values, names, n); - IDSetNumber(&DC3constSETNP, nullptr); - return true; - } - - // DC2voltageSET - if (!strcmp(name, setDC2voltageNP.name)) - { - bool rc1 = false; - for (int i = 0; i < n; i++) - { - if (!strcmp(names[i], setDC2voltageN[setDC2voltage].name)) - rc1 = setDewPWM(20, static_cast(10*values[i])); - } - - setDC2voltageNP.s = (rc1) ? IPS_OK : IPS_ALERT; - if (setDC2voltageNP.s == IPS_OK) - IUUpdateNumber(&setDC2voltageNP, values, names, n); - IDSetNumber(&setDC2voltageNP, nullptr); - return true; - } - - - } - return INDI::DefaultDevice::ISNewNumber(dev, name, values, names, n); -} - -bool WandererBoxPlusV3::setDewPWM(uint8_t id, uint8_t value) -{ - char cmd[64] = {0}; - snprintf(cmd, 64, "%d%03d", id, value); - if (sendCommand(cmd)) - { - return true; - } - - return false; -} - -const char *WandererBoxPlusV3::getDefaultName() -{ - return "WandererBox Pro V3"; -} - - -bool WandererBoxPlusV3::sendCommand(std::string command) -{ - int nbytes_written = 0, rc = -1; - std::string command_termination = "\n"; - LOGF_DEBUG("CMD: %s", command.c_str()); - if ((rc = tty_write_string(PortFD, (command + command_termination).c_str(), &nbytes_written)) != TTY_OK) - { - char errorMessage[MAXRBUF]; - tty_error_msg(rc, errorMessage, MAXRBUF); - LOGF_ERROR("Serial write error: %s", errorMessage); - return false; - } - return true; -} - -void WandererBoxPlusV3::TimerHit() -{ - if (!isConnected()) - { - SetTimer(2500); - return; - } - - getData(); - SetTimer(2500); -} - -bool WandererBoxPlusV3::saveConfigItems(FILE * fp) -{ - INDI::DefaultDevice::saveConfigItems(fp); - - IUSaveConfigSwitch(fp, &DC3dewSP); - IUSaveConfigNumber(fp, &DC3diffSETNP); - IUSaveConfigNumber(fp, &DC3constSETNP); - IUSaveConfigNumber(fp, &DC3ControlNP); - - - IUSaveConfigNumber(fp, &setDC2voltageNP); - return true; -} - - diff --git a/drivers/auxiliary/wandererbox_plus_v3.h b/drivers/auxiliary/wandererbox_plus_v3.h deleted file mode 100644 index 3f1194be7e..0000000000 --- a/drivers/auxiliary/wandererbox_plus_v3.h +++ /dev/null @@ -1,170 +0,0 @@ -/******************************************************************************* - Copyright(c) 2015 Jasem Mutlaq. All rights reserved. - -WandererBox Plus V3 - - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the Free - Software Foundation; either version 2 of the License, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. - - The full GNU General Public License is included in this distribution in the - file called LICENSE. -*******************************************************************************/ - -#pragma once - -#include "defaultdevice.h" -#include -#include - -namespace Connection -{ -class Serial; -} - -class WandererBoxPlusV3 : public INDI::DefaultDevice -{ - public: - WandererBoxPlusV3(); - virtual ~WandererBoxPlusV3() = default; - - virtual bool initProperties() override; - virtual bool ISNewNumber(const char *dev, const char *name, double values[], char *names[], int n) override; - virtual bool ISNewSwitch(const char *dev, const char *name, ISState *states, char *names[], int n) override; - virtual bool updateProperties() override; - - - - protected: - const char *getDefaultName() override; - virtual bool saveConfigItems(FILE *fp) override; - virtual void TimerHit() override; - - - private: - - bool sendCommand(std::string command); - bool DC3DIFFMODE=false; - bool DC3CONSTMODE=false; - bool getData(); - static constexpr const char *ENVIRONMENT_TAB {"Sensors"}; - static constexpr const char *DC3_TAB {"DC3"}; - //Current Calibrate - ISwitch CalibrateS[1]; - ISwitchVectorProperty CalibrateSP; - - // Firmware version - ITextVectorProperty FirmwareTP; - IText FirmwareT[1] {}; - //Temp1 - double temp1read = 0; - //DHTH - double DHTHread = 0; - //DHTT - void updateENV(double temp1,double DHTH,double DHTT); - double DHTTread = 0; - //Total Current - double Tcurrentread = 0; - //Power Monitor - void updatePower(double Tcurrent,double voltage); - double voltageread = 0; - //USB - void updateUSB(int value); - int USBread = 0; - //DC2 - void updateDC2(int value); - int DC2read = 0; - //DC3 - void updateDC3(int value); - int DC3read = 0; - //DC4_6 - void updateDC4_6(int value); - int DC4_6read = 0; - //DC2set - void updateDC2SET(double value); - int DC2SETread = 0; - - bool setDewPWM(uint8_t id, uint8_t value); - - //DC Control////////////////////////////////////////////////////////////////////////////////// - ISwitchVectorProperty DC2ControlSP; - ISwitch DC2ControlS[2]; - ISwitchVectorProperty DC4_6ControlSP; - ISwitch DC4_6ControlS[2]; - //USB Control////////////////////////////////////////////////////////////////////////////////// - ISwitchVectorProperty USBControlSP; - ISwitch USBControlS[2]; - //DC3 Control//////////////////////////////////////////////////////////////// - INumber DC3ControlN[1]; - INumberVectorProperty DC3ControlNP; - enum - { - DC3, - }; - ISwitchVectorProperty DC3dewSP; - ISwitch DC3diffS[3]; - enum - { - DC3_Manual, - DC3_DPD_Mode, - DC3_CT_Mode, - }; - - INumber DC3diffSETN[1]; - INumberVectorProperty DC3diffSETNP; - enum - { - DC3DIFFSET, - }; - INumber DC3constSETN[1]; - INumberVectorProperty DC3constSETNP; - enum - { - DC3CONSTSET, - }; - - //DC2 Voltage Control//////////////////////////////////////////////////////////////// - INumber setDC2voltageN[1]; - INumberVectorProperty setDC2voltageNP; - enum - { - setDC2voltage, - }; - - // Power Monitor - INumber PowerMonitorN[2]; - INumberVectorProperty PowerMonitorNP; - enum - { - VOLTAGE, - TOTAL_CURRENT, - }; - - // ENV Monitor - INumber ENVMonitorN[4]; - INumberVectorProperty ENVMonitorNP; - enum - { - Probe1_Temp, - ENV_Humidity, - ENV_Temp, - DEW_Point, - }; - - - - int PortFD{ -1 }; - - Connection::Serial *serialConnection{ nullptr }; -};