修复gpio bug和优化

rtmpsuck
Matthew 6 months ago
parent a59144c97b
commit 0243d9b7d4

@ -47,7 +47,7 @@ size_t GpioControl::turnOnImpl(const IOT_PARAM& param)
if (it->cmd == param.cmd) if (it->cmd == param.cmd)
{ {
it->references++; it->references++;
it->closeTime = 0; // it->closeTime = 0;
references = it->references; references = it->references;
SetCamerastatus(it->cmd, true); SetCamerastatus(it->cmd, true);
break; break;
@ -360,7 +360,7 @@ void GpioControl::PowerControlThreadProc()
if (it->references == 0 && it->closeCmds == 0 && it->closeTime == 0) if (it->references == 0 && it->closeCmds == 0 && it->closeTime == 0)
{ {
#ifdef _DEBUG #ifdef _DEBUG
ALOGI("PWR TH cmd=%d ref=%u closeCmds=%u", it->cmd, (uint32_t)it->references, (uint32_t)it->closeCmds); ALOGI("PWR THREAD cmd=%d ref=%u closeCmds=%u", it->cmd, (uint32_t)it->references, (uint32_t)it->closeCmds);
#endif #endif
continue; continue;
} }
@ -389,7 +389,7 @@ void GpioControl::PowerControlThreadProc()
setInt(it->cmd, 0); setInt(it->cmd, 0);
it->closeTime = 0; it->closeTime = 0;
#ifdef _DEBUG #ifdef _DEBUG
ALOGI("PWR TH DO TurnOff cmd=%d", it->cmd); ALOGI("PWR THREAD DO TurnOff cmd=%d", it->cmd);
#endif #endif
SetCamerastatus(it->cmd, false); SetCamerastatus(it->cmd, false);
} }
@ -404,7 +404,7 @@ void GpioControl::PowerControlThreadProc()
} }
} }
#ifdef _DEBUG #ifdef _DEBUG
ALOGI("PWR TH cmd=%d ref=%u closeCmds=%u", it->cmd, (uint32_t)it->references, (uint32_t)it->closeCmds); ALOGI("PWR THREAD cmd=%d ref=%u closeCmds=%u", it->cmd, (uint32_t)it->references, (uint32_t)it->closeCmds);
#endif #endif
} }
m_locker.unlock(); m_locker.unlock();

@ -26,16 +26,16 @@
#define CMD_SET_NETWORK_STATE 106 #define CMD_SET_NETWORK_STATE 106
#define CMD_SET_OTG_STATE 107 #define CMD_SET_OTG_STATE 107
#define CMD_GET_OTG_STATE 108 #define CMD_GET_OTG_STATE 108
#define CMD_GET_CHARGING_VOL_STATE 110 //#define CMD_GET_CHARGING_VOL_STATE 110
#define CMD_GET_CHARGING_SHUNT_VOLTAGE_STATE 111 //#define CMD_GET_CHARGING_SHUNT_VOLTAGE_STATE 111
#define CMD_GET_CHARGING_BUS_VOLTAGE_STATE 112 #define CMD_GET_CHARGING_BUS_VOLTAGE_STATE 112
#define CMD_GET_CHARGING_POWER_STATE 113 //#define CMD_GET_CHARGING_POWER_STATE 113
#define CMD_GET_CHARGING_CURRENT_STATE 114 //#define CMD_GET_CHARGING_CURRENT_STATE 114
#define CMD_GET_BAT_VOL_STATE 115 //#define CMD_GET_BAT_VOL_STATE 115
#define CMD_GET_BAT_SHUNT_VOLTAGE_STATE 116 //#define CMD_GET_BAT_SHUNT_VOLTAGE_STATE 116
#define CMD_GET_BAT_BUS_VOLTAGE_STATE 117 #define CMD_GET_BAT_BUS_VOLTAGE_STATE 117
#define CMD_GET_BAT_POWER_STATE 118 //#define CMD_GET_BAT_POWER_STATE 118
#define CMD_GET_BAT_CURRENT_STATE 119 //#define CMD_GET_BAT_CURRENT_STATE 119
#define CMD_SET_485_STATE 121 #define CMD_SET_485_STATE 121
#define CMD_SET_SPI_MODE 123 #define CMD_SET_SPI_MODE 123
#define CMD_SET_SPI_BITS_PER_WORD 124 #define CMD_SET_SPI_BITS_PER_WORD 124
@ -56,18 +56,13 @@
#define CMD_GET_OTG_STATE 108 #define CMD_GET_OTG_STATE 108
#define CMD_SET_SPI_POWER 129 #define CMD_SET_SPI_POWER 129
#define CMD_SET_12V_EN_STATE 0 // TO BE ADDED #define CMD_SET_12V_EN_STATE 0 // TO BE ADDED
#define CMD_SET_SYSTEM_RESET 0 // TO BE ADDED #define CMD_SET_SYSTEM_RESET 202
#define CMD_GET_CHARGING_VOL_STATE 0 // TO BE ADDED #define CMD_GET_LIGHT_ADC 101
#define CMD_GET_CHARGING_SHUNT_VOLTAGE_STATE 0 // TO BE ADDED #define CMD_SET_LIGHT_ADC 102
#define CMD_GET_CHARGING_BUS_VOLTAGE_STATE 0 // TO BE ADDED #define CMD_GET_CHARGING_BUS_VOLTAGE_STATE 112
#define CMD_GET_CHARGING_POWER_STATE 0 // TO BE ADDED #define CMD_GET_BAT_BUS_VOLTAGE_STATE 117
#define CMD_GET_CHARGING_CURRENT_STATE 0 // TO BE ADDED
#define CMD_GET_BAT_VOL_STATE 0 // TO BE ADDED
#define CMD_GET_BAT_SHUNT_VOLTAGE_STATE 0 // TO BE ADDED
#define CMD_GET_BAT_BUS_VOLTAGE_STATE 0 // TO BE ADDED
#define CMD_GET_BAT_POWER_STATE 0 // TO BE ADDED
#define CMD_GET_BAT_CURRENT_STATE 0 // TO BE ADDED
#define CMD_SET_SPI_MODE 0 // TO BE ADDED #define CMD_SET_SPI_MODE 0 // TO BE ADDED
#define CMD_SET_SPI_BITS_PER_WORD 0 // TO BE ADDED #define CMD_SET_SPI_BITS_PER_WORD 0 // TO BE ADDED
#define CMD_SET_SPI_MAXSPEEDHZ 0 // TO BE ADDED #define CMD_SET_SPI_MAXSPEEDHZ 0 // TO BE ADDED
@ -132,6 +127,9 @@
#define CMD_SET_485_EN_STATE 131 #define CMD_SET_485_EN_STATE 131
#define CMD_SET_OTG_STATE 107 #define CMD_SET_OTG_STATE 107
#define CMD_GET_CHARGING_BUS_VOLTAGE_STATE 112
#define CMD_GET_BAT_BUS_VOLTAGE_STATE 117
#endif // USING_N938 #endif // USING_N938
@ -320,12 +318,13 @@ public:
static int getChargingVoltage() static int getChargingVoltage()
{ {
#ifndef USING_N938 #ifndef USING_N938
return getInt(CMD_GET_CHARGING_VOL_STATE); return getInt(CMD_GET_CHARGING_BUS_VOLTAGE_STATE);
#else #else
return -1; return -1;
#endif #endif
} }
#if 0
static int getChargingShuntVoltage() static int getChargingShuntVoltage()
{ {
#ifndef USING_N938 #ifndef USING_N938
@ -334,6 +333,7 @@ public:
return -1; return -1;
#endif #endif
} }
#endif
static int getChargingBusVoltage() { static int getChargingBusVoltage() {
#ifndef USING_N938 #ifndef USING_N938
@ -343,6 +343,7 @@ public:
#endif #endif
} }
#if 0
static int getChargingPower() { static int getChargingPower() {
#ifndef USING_N938 #ifndef USING_N938
return getInt(CMD_GET_CHARGING_POWER_STATE); return getInt(CMD_GET_CHARGING_POWER_STATE);
@ -358,15 +359,13 @@ public:
return -1; return -1;
#endif #endif
} }
#endif
static int getBatteryVoltage() { static int getBatteryVoltage() {
#ifndef USING_N938 return getInt(CMD_GET_BAT_BUS_VOLTAGE_STATE);
return getInt(CMD_GET_BAT_VOL_STATE);
#else
return -1;
#endif
} }
#if 0
static int getBatteryShuntVoltage() { static int getBatteryShuntVoltage() {
#ifndef USING_N938 #ifndef USING_N938
return getInt(CMD_GET_BAT_SHUNT_VOLTAGE_STATE); return getInt(CMD_GET_BAT_SHUNT_VOLTAGE_STATE);
@ -374,15 +373,13 @@ public:
return -1; return -1;
#endif #endif
} }
#endif
static int getBatteryBusVoltage() { static int getBatteryBusVoltage() {
#ifndef USING_N938
return getInt(CMD_GET_BAT_BUS_VOLTAGE_STATE); return getInt(CMD_GET_BAT_BUS_VOLTAGE_STATE);
#else
return -1;
#endif
} }
#if 0
static int getBatteryPower() { static int getBatteryPower() {
#ifndef USING_N938 #ifndef USING_N938
return getInt(CMD_GET_BAT_POWER_STATE); return getInt(CMD_GET_BAT_POWER_STATE);
@ -398,6 +395,7 @@ public:
return -1; return -1;
#endif #endif
} }
#endif
static void set485WriteMode() { static void set485WriteMode() {
#if 0 #if 0
@ -463,7 +461,7 @@ public:
m_cmds.resize(4, cmd1); m_cmds.resize(4, cmd1);
m_cmds[1] = cmd2; m_cmds[1] = cmd2;
m_cmds[2] = cmd3; m_cmds[2] = cmd3;
m_cmds[3] = cmd3; m_cmds[3] = cmd4;
TurnOn(); TurnOn();
} }
PowerControl(int cmd1, int cmd2, int cmd3, int cmd4, int cmd5, uint32_t closeDelayTime) : m_delayCloseTime(closeDelayTime) PowerControl(int cmd1, int cmd2, int cmd3, int cmd4, int cmd5, uint32_t closeDelayTime) : m_delayCloseTime(closeDelayTime)
@ -471,8 +469,18 @@ public:
m_cmds.resize(5, cmd1); m_cmds.resize(5, cmd1);
m_cmds[1] = cmd2; m_cmds[1] = cmd2;
m_cmds[2] = cmd3; m_cmds[2] = cmd3;
m_cmds[3] = cmd3; m_cmds[3] = cmd4;
m_cmds[4] = cmd4; m_cmds[4] = cmd5;
TurnOn();
}
PowerControl(int cmd1, int cmd2, int cmd3, int cmd4, int cmd5, int cmd6, uint32_t closeDelayTime) : m_delayCloseTime(closeDelayTime)
{
m_cmds.resize(5, cmd1);
m_cmds[1] = cmd2;
m_cmds[2] = cmd3;
m_cmds[3] = cmd4;
m_cmds[4] = cmd5;
m_cmds[4] = cmd6;
TurnOn(); TurnOn();
} }
@ -534,7 +542,7 @@ public:
PowerControl(CMD_SET_OTG_STATE, CMD_SET_NETWORK_POWER_EN, CMD_SET_PIC1_POWER, CMD_SET_485_EN_STATE, closeDelayTime) PowerControl(CMD_SET_OTG_STATE, CMD_SET_NETWORK_POWER_EN, CMD_SET_PIC1_POWER, CMD_SET_485_EN_STATE, closeDelayTime)
#else // USING_N938 #else // USING_N938
#ifdef USING_PLZ #ifdef USING_PLZ
PowerControl(CMD_SET_OTG_STATE, CMD_SET_PTZ_PWR_ENABLE, CMD_SET_100M_ENABLE, CMD_SET_100M_SWITCH_PWR_ENABLE, CMD_SET_12V_EN_STATE, closeDelayTime) PowerControl(CMD_SET_OTG_STATE, CMD_SET_PTZ_PWR_ENABLE, CMD_SET_100M_ENABLE, CMD_SET_100M_SWITCH_PWR_ENABLE, CMD_SET_485_ENABLE, CMD_SET_12V_EN_STATE, closeDelayTime)
#else // USING_PLZ #else // USING_PLZ
PowerControl(CMD_SET_OTG_STATE, CMD_SET_12V_EN_STATE, closeDelayTime) PowerControl(CMD_SET_OTG_STATE, CMD_SET_12V_EN_STATE, closeDelayTime)
#endif // USING_PLZ #endif // USING_PLZ

@ -970,6 +970,7 @@ bool CPhoneDevice::QuerySystemProperties(std::map<std::string, std::string>& pro
int val = GpioControl::getLightAdc(); int val = GpioControl::getLightAdc();
it->second = std::to_string(val); it->second = std::to_string(val);
} }
#if 0
else if (it->first == (PROP_CHARGING_CURRENT)) else if (it->first == (PROP_CHARGING_CURRENT))
{ {
it->second = std::to_string(GpioControl::getChargingCurrent()); it->second = std::to_string(GpioControl::getChargingCurrent());
@ -978,6 +979,7 @@ bool CPhoneDevice::QuerySystemProperties(std::map<std::string, std::string>& pro
{ {
it->second = std::to_string(GpioControl::getChargingPower()); it->second = std::to_string(GpioControl::getChargingPower());
} }
#endif
else if (it->first == (PROP_CHARGING_BUS_VOL) || it->first == (PROP_CHARGING_VOLTAGE)) else if (it->first == (PROP_CHARGING_BUS_VOL) || it->first == (PROP_CHARGING_VOLTAGE))
{ {
double val = -1; double val = -1;
@ -994,10 +996,12 @@ bool CPhoneDevice::QuerySystemProperties(std::map<std::string, std::string>& pro
break; break;
} }
} }
#if 0
else if (it->first == (PROP_BATTERY_POWER)) else if (it->first == (PROP_BATTERY_POWER))
{ {
it->second = std::to_string(GpioControl::getBatteryPower()); it->second = std::to_string(GpioControl::getBatteryPower());
} }
#endif
else if (it->first == (PROP_BATTERY_BUS_VOL) || it->first == (PROP_BATTERY_VOLTAGE)) else if (it->first == (PROP_BATTERY_BUS_VOL) || it->first == (PROP_BATTERY_VOLTAGE))
{ {
int val = QueryBatteryVoltage(DEFAULT_BATTERY_QUERY_RETRIES); // // BatVol int val = QueryBatteryVoltage(DEFAULT_BATTERY_QUERY_RETRIES); // // BatVol

Loading…
Cancel
Save