生产现场设备检测完正确亮绿灯不正确亮红灯
作者:互联网
static int ReadGpioValue(int r) { char commandBuf[COMMAND_BUF_MAX_SIZE] = {0}; FILE *fp = NULL; int ret = -1, value = -1; snprintf(commandBuf, COMMAND_BUF_MAX_SIZE, "cat /sys/class/gpio/gpio%d/value > /tmp/resetgpio.txt", r); system(commandBuf); fp = fopen("/tmp/resetgpio.txt", "r"); if(fp == NULL){printf("fopen error!\n"); return -1;} fscanf(fp, "%d", &value); fclose(fp); return value; }
这几行代码就实现了生产现场设备检测完正确亮绿灯不正确亮红灯……有时候很简单的方法就是想不到……
标签:fp,commandBuf,正确,int,value,绿灯,亮红灯 来源: https://www.cnblogs.com/hshy/p/15898808.html