GPIO控制的调整

hdrplus
Matthew 7 months ago
parent 1b0d0f421f
commit 9e260d2b93

@ -498,6 +498,7 @@ void CPhoneDevice::SetListener(IListener* listener)
void CPhoneDevice::SetRecognizationCfg(const IDevice::CFG_RECOGNIZATION* pRecognizationCfg)
{
return;
if (m_pRecognizationCfg == NULL && pRecognizationCfg != NULL && (pRecognizationCfg->enabled != 0))
{
// TODO
@ -1167,6 +1168,9 @@ bool CPhoneDevice::RegisterHandlerForSignal(int sig)
void CPhoneDevice::handleTimer(union sigval v)
{
#ifdef _DEBUG
setThreadName("bztimer");
#endif
TIMER_CONTEXT* context = (TIMER_CONTEXT*)(v.sival_ptr);
context->device->handleTimerImpl(context);
}
@ -3200,8 +3204,6 @@ int CPhoneDevice::GetIceData(IDevice::ICE_INFO *iceInfo, IDevice::ICE_TAIL *iceT
return true;
}
int CPhoneDevice::GetWData(IDevice::WEATHER_INFO *weatherInfo)
{
Collect_sensor_data(); //15s
@ -3238,7 +3240,11 @@ bool CPhoneDevice::OpenSensors(int sensortype)
GpioControl::setRS485Enable(true);
// GpioControl::setInt(CMD_SET_485_EN_STATE, 1); // 打开RS485电源
#ifndef USING_N938
#ifndef USING_PLZ
GpioControl::setInt(CMD_SET_485_EN_STATE, 1);
#else
GpioControl::setInt(CMD_SET_485_ENABLE, 1);
#endif
#else
GpioControl::setInt(CMD_SPI2SERIAL_POWER_EN, 1);
GpioControl::setInt(CMD_RS485_3V3_EN, 1);
@ -3247,30 +3253,43 @@ bool CPhoneDevice::OpenSensors(int sensortype)
}
if(sensortype == CAMERA_SENSOR_OPEN)
{
#ifndef USING_N938
#ifndef USING_PLZ
#else
GpioControl::setInt(CMD_SET_PTZ_PWR_ENABLE, 1);
#endif
#else
GpioControl::setInt(CMD_SET_PIC1_POWER, 1);
GpioControl::setInt(CMD_SET_485_EN4, 1);
#endif
// GpioControl::setInt(CMD_SET_CAM_3V3_EN_STATE, 1); // 打开3.3V电压
// GpioControl::setInt(CMD_SET_3V3_PWR_ENABLE, 1);
#ifndef USING_N938
GpioControl::setInt(CMD_SET_PTZ_PWR_ENABLE, 1);
#endif
}
if(sensortype == WEATHER_SENSOR_OPEN || sensortype == ICETHICK_SENSOR_OPEN)
{
#ifndef USING_N938
#else
GpioControl::setInt(CMD_SET_WTH_POWER, 1);
GpioControl::setInt(CMD_SET_485_EN3, 1);
#endif
}
if(sensortype == ICETHICK_SENSOR_OPEN)
{
#ifndef USING_N938
#else
GpioControl::setInt(CMD_SET_PULL_POWER, 1);
GpioControl::setInt(CMD_SET_ANGLE_POWER, 1);
GpioControl::setInt(CMD_SET_485_EN1, 1);
GpioControl::setInt(CMD_SET_485_EN0, 1);
#endif
}
if(sensortype == OTHER_SENSOR)
{
#ifndef USING_N938
#else
GpioControl::setInt(CMD_SET_OTHER_POWER, 1);
GpioControl::setInt(CMD_SET_485_EN2, 1);
#endif
}
return 0;
}
@ -3285,7 +3304,11 @@ bool CPhoneDevice::CloseSensors(int sensortype)
GpioControl::setRS485Enable(false);
// GpioControl::setInt(CMD_SET_485_EN_STATE, 0);
#ifndef USING_N938
#ifndef USING_PLZ
GpioControl::setInt(CMD_SET_485_EN_STATE, 0);
#else
GpioControl::setInt(CMD_SET_485_ENABLE, 0);
#endif
#else
GpioControl::setInt(CMD_SPI2SERIAL_POWER_EN, 0);
GpioControl::setInt(CMD_RS485_3V3_EN, 0);
@ -3294,30 +3317,45 @@ bool CPhoneDevice::CloseSensors(int sensortype)
}
if(sensortype == CAMERA_SENSOR_OPEN)
{
#ifdef USING_N938
GpioControl::setInt(CMD_SET_PIC1_POWER, 0);
GpioControl::setInt(CMD_SET_485_EN4, 0);
// GpioControl::setInt(CMD_SET_CAM_3V3_EN_STATE, 0);
#endif
#ifndef USING_N938
GpioControl::setInt(CMD_SET_3V3_PWR_ENABLE, 0);
// GpioControl::setInt(CMD_SET_3V3_PWR_ENABLE, 0);
#ifndef USING_PLZ
#else
GpioControl::setInt(CMD_SET_PTZ_PWR_ENABLE, 0);
#endif
#endif
}
if(sensortype == WEATHER_SENSOR_OPEN || sensortype == ICETHICK_SENSOR_OPEN)
{
#ifndef USING_N938
#else
GpioControl::setInt(CMD_SET_WTH_POWER, 0);
GpioControl::setInt(CMD_SET_485_EN3, 0);
#endif
}
if(sensortype == ICETHICK_SENSOR_OPEN)
{
#ifndef USING_N938
#else
GpioControl::setInt(CMD_SET_PULL_POWER, 0);
GpioControl::setInt(CMD_SET_ANGLE_POWER, 0);
GpioControl::setInt(CMD_SET_485_EN1, 0);
GpioControl::setInt(CMD_SET_485_EN0, 0);
#endif
}
if(sensortype == OTHER_SENSOR)
{
#ifndef USING_N938
#else
GpioControl::setInt(CMD_SET_OTHER_POWER, 0);
GpioControl::setInt(CMD_SET_485_EN2, 0);
#endif
}
return 0;
}

@ -706,7 +706,10 @@ char Gm_GetSensorsPowerState(int port)
void BytestreamLOG(int commid, char* describe, u_char* buf, int len, char flag)
{
int i;
char szbuf[4096];
// char szbuf[4096];
char* szbuf = new char[4096];
std::unique_ptr<char[]> bufptr(szbuf);
memset(szbuf, 0, sizeof(szbuf));
if (NULL != describe)
@ -743,7 +746,8 @@ void BytestreamLOG(int commid, char* describe, u_char* buf, int len, char flag)
void Gm_OpenSerialPort(int devidx)
{
int fd = -1;
char szbuf[512];
char* szbuf = new char[512];
std::unique_ptr<char[]> bufptr(szbuf);
if ((devidx < 0) || (devidx >= MAX_SERIAL_DEV_NUM))
return;
@ -792,7 +796,8 @@ void Gm_CloseSerialPort()
int GM_SerialComSend(unsigned char * cSendBuf, size_t nSendLen, int commid)
{
int i, len;
char szbuf[512];
char* szbuf = new char[512];
std::unique_ptr<char[]> bufptr(szbuf);
memset(szbuf, 0, sizeof(szbuf));
len = write(serialport[commid].fd, cSendBuf, (size_t)nSendLen);/* 向串囗发送字符串 */
@ -1700,7 +1705,9 @@ void GM_IsCloseSensors()
void GM_AllSerialComRecv()
{
int i, j, recvlen;
u_char recvbuf[RECVDATA_MAXLENTH];
u_char* recvbuf = new u_char[RECVDATA_MAXLENTH];
std::unique_ptr<u_char[]> recvbufptr(recvbuf);
char buf[256];
for (j = 0; j < MAX_SERIAL_PORT_NUM; j++)
@ -1732,7 +1739,7 @@ void GM_AllSerialComRecv()
int GM_CloseTimer()
{
int i, j, iretime;
char buf[256];
char buf[32];
for (i = 0; i < MAX_SERIAL_DEV_NUM; i++)
{
@ -1810,7 +1817,17 @@ int SaveLogTofile(int commid, char *szbuf)
{
int status;
time_t now;
char filename[512], filedir[512], buf[128];
// char filename[512], filedir[512], buf[128];
char* filename = new char[512];
char* filedir = new char[512];
char* buf = new char[128];
std::unique_ptr<char[]> fnptr(filename);
std::unique_ptr<char[]> fdptr(filedir);
std::unique_ptr<char[]> bufptr(buf);
FILE *fp = NULL;
struct tm t0;
struct timeval tv;
@ -1856,7 +1873,7 @@ int SaveImageDataTofile(int devno)
u_char *image = NULL, *tempphoto = NULL;
int i, status;
size_t len;
char filename[512]/*, filedir[512]*/, szbuf[128];
char szbuf[32];
FILE *fp = NULL;
SERIAL_DEV_DEF *pPortParam;
@ -3394,7 +3411,8 @@ int Gm_CtrlPtzCmd(u_char channel, uint32_t ptzcmd)
time_t now = time(NULL);
DIR *dir = opendir(path);
struct dirent *entry;
char szbuf[1024];
char* szbuf = new char[1024];
std::unique_ptr<char[]> szbufptr(szbuf);
char fullpath[256];
memset(szbuf, 0, sizeof(szbuf));

Loading…
Cancel
Save