实现N938相关的传感器打开函数

需调整
MQTTtest
Matthew 10 months ago
parent 74358c21c1
commit 92f61a3a4f

@ -131,3 +131,63 @@ std::string GpioControl::getString(int cmd)
}
return "";
}
#ifdef USING_N938
bool GpioControl::SetN938Cmd(int cmd, int val)
{
char buf[32] = { 0 };
snprintf(buf, "out %d %d", cmd, val);
IOT_PARAM param;
int len = MAX_STRING_LEN < strlen(buf) ? MAX_STRING_LEN : strlen(buf);
param.cmd = cmd;
memset(param.str, 0, MAX_STRING_LEN);
memcpy(param.str, value.c_str(), len);
int fd = open(GPIO_NODE_MP, O_RDONLY);
if( fd > 0 )
{
ioctl(fd, IOT_PARAM_WRITE, &param);
close(fd);
}
return;
}
bool GpioControl::OpenSensors()
{
GpioControl::setInt(CMD_SET_CAM_3V3_EN_STATE, true ? 1 : 0);
GpioControl::setInt(CMD_SET_485_EN_STATE, true ? 1 : 0);
int igpio;
GpioControl::setInt(CMD_SET_WTH_POWER, 1);
GpioControl::setInt(CMD_SET_PULL_POWER, 1);
GpioControl::setInt(CMD_SET_ANGLE_POWER, 1);
GpioControl::setInt(CMD_SET_OTHER_POWER, 1);
GpioControl::setInt(CMD_SET_PIC1_POWER, 1);
igpio = GpioControl::getInt(CMD_SET_WTH_POWER);
igpio = GpioControl::getInt(CMD_SET_PULL_POWER);
igpio = GpioControl::getInt(CMD_SET_ANGLE_POWER);
igpio = GpioControl::getInt(CMD_SET_OTHER_POWER);
igpio = GpioControl::getInt(CMD_SET_PIC1_POWER);
GpioControl::setInt(CMD_SET_SPI_POWER, 1);
GpioControl::setInt(CMD_SET_485_en0, 1);
GpioControl::setInt(CMD_SET_485_en1, 1);
GpioControl::setInt(CMD_SET_485_en2, 1);
GpioControl::setInt(CMD_SET_485_en3, 1);
GpioControl::setInt(CMD_SET_485_en4, 1);
igpio = GpioControl::getInt(CMD_SET_SPI_POWER);
igpio = GpioControl::getInt(CMD_SET_485_en0);
igpio = GpioControl::getInt(CMD_SET_485_en1);
igpio = GpioControl::getInt(CMD_SET_485_en2);
igpio = GpioControl::getInt(CMD_SET_485_en3);
igpio = GpioControl::getInt(CMD_SET_485_en4);
return 0;
}
#endif

@ -40,6 +40,7 @@
#ifdef USING_N938
#define CMD_SET_WTH_POWER 490
#define CMD_SET_PULL_POWER 491
#define CMD_SET_ANGLE_POWER 492
@ -52,17 +53,19 @@
#define CMD_SET_485_en4 305
#define CMD_485_0_DE 156 // 485_0 DE信号
#define CMD_485_0_PWR_EN 157 // 485_0 电源使能
#define CMD_485_0_1_DE_EN 171 // 485_0&1DE电平转换芯片使能信号
#define CMD_485_1_DE 172 //
#define CMD_SET_CAM_3V3_EN_STATE 72 // 整板3V3上电使能
#define CMD_3V3_SWITCH_EN 45 // 整板485_3V3信号电平转换电源使能
#define CMD_UART0_EN 73 // 预留UART0电平转换芯片使能
#define CMD_485_1_PWR_EN 5 // 485_1 电源使能
#define CMD_485_3_DE 6 // 485_3 DE信号
#define CMD_485_2_DE 7 // 485_2 DE信号
#define CMD_485_4_DE 13 // 485_4 DE信号
@ -77,9 +80,7 @@
#define CMD_485_2_3_DE_EN 26 // 485_2&3 DE电平转换芯片使能信号
#define CMD_5V_PWR_EN 14 // 整板5V0上电使能
#define CMD_SD_CARD_DECT 15 // SD CARD DECT
#define CMD_PIC1_EN 16
#define CMD_OTHER_EN 21
@ -227,6 +228,12 @@ public:
setInt(CMD_SET_12V_EN_STATE, z ? 1 : 0);
}
#ifdef USING_N938
static bool SetN938Cmd(int cmd, int val);
static bool OpenSensors();
static bool CloseSensors();
#endif
};

Loading…
Cancel
Save