优化代码

master
Matthew 10 months ago
parent 1dde17b714
commit f28eeb3122

@ -43,7 +43,7 @@ typedef struct{
void GpioControl::setInt(int cmd, int value) void GpioControl::setInt(int cmd, int value)
{ {
int fd = open("/dev/mtkgpioctrl", O_RDONLY); int fd = open(GPIO_NODE_MP, O_RDONLY);
IOT_PARAM param; IOT_PARAM param;
param.cmd = cmd; param.cmd = cmd;
param.value = value; param.value = value;
@ -59,7 +59,7 @@ void GpioControl::setInt(int cmd, int value)
int GpioControl::getInt(int cmd) int GpioControl::getInt(int cmd)
{ {
int fd = open("/dev/mtkgpioctrl", O_RDONLY); int fd = open(GPIO_NODE_MP, O_RDONLY);
// LOGE("get_int fd=%d,cmd=%d\r\n",fd, cmd); // LOGE("get_int fd=%d,cmd=%d\r\n",fd, cmd);
if( fd > 0 ) if( fd > 0 )
{ {
@ -77,7 +77,7 @@ int GpioControl::getInt(int cmd)
void GpioControl::setLong(int cmd, long value) void GpioControl::setLong(int cmd, long value)
{ {
int fd = open("/dev/mtkgpioctrl", O_RDONLY); int fd = open(GPIO_NODE_MP, O_RDONLY);
IOT_PARAM param; IOT_PARAM param;
param.cmd = cmd; param.cmd = cmd;
param.value2 = value; param.value2 = value;
@ -93,7 +93,7 @@ void GpioControl::setLong(int cmd, long value)
long GpioControl::getLong(int cmd) long GpioControl::getLong(int cmd)
{ {
int fd = open("/dev/mtkgpioctrl", O_RDONLY); int fd = open(GPIO_NODE_MP, O_RDONLY);
// LOGE("get_long fd=%d,cmd=%d\r\n",fd, cmd); // LOGE("get_long fd=%d,cmd=%d\r\n",fd, cmd);
if( fd > 0 ) if( fd > 0 )
{ {
@ -110,8 +110,7 @@ long GpioControl::getLong(int cmd)
void GpioControl::setString(int cmd, const std::string& value) void GpioControl::setString(int cmd, const std::string& value)
{ {
IOT_PARAM param; IOT_PARAM param;
// char *pval = jstringToChars(env, value); int fd = open(GPIO_NODE_MP, O_RDONLY);
int fd = open("/dev/mtkgpioctrl", O_RDONLY);
int len = MAX_STRING_LEN < value.size() ? MAX_STRING_LEN : value.size(); int len = MAX_STRING_LEN < value.size() ? MAX_STRING_LEN : value.size();
param.cmd = cmd; param.cmd = cmd;
@ -129,7 +128,7 @@ void GpioControl::setString(int cmd, const std::string& value)
std::string GpioControl::getString(int cmd) std::string GpioControl::getString(int cmd)
{ {
int fd = open("/dev/mtkgpioctrl", O_RDONLY); int fd = open(GPIO_NODE_MP, O_RDONLY);
// LOGE("get_string fd=%d,cmd=%d\r\n",fd, cmd); // LOGE("get_string fd=%d,cmd=%d\r\n",fd, cmd);
if( fd > 0 ) if( fd > 0 )
{ {

@ -48,6 +48,9 @@
#define CMD_SET_485_en4 305 #define CMD_SET_485_en4 305
#define GPIO_NODE_MP "/dev/mtkgpioctrl"
#define GPIO_NODE_N938 "/sys/devices/platform/1000b000.pinctrl/mt_gpio"
class GpioControl class GpioControl
{ {
public: public:

Loading…
Cancel
Save