他的回复:
程序如下:typedef struct{ unsigned long time; unsigned int value;} di_read_cfg_s; int len = 0; di_read_cfg_s ucDioCfg; unsigned int debounce = 0; int fd; fd = open("/dev/di1", O_RDWR | O_NOCTTY | O_NONBLOCK); if (fd 0) { perror("IO"); exit(-1); } printf("\nIO端口文件打开成功!\n"); while (1) { len = read(fd, &ucDioCfg, sizeof(ucDioCfg)); if (0 > len) { printf("read file fail \r\n"); return -1; } printf("read di time[%d]\r\n", ucDioCfg.time); printf("read di value[%d]\r\n", ucDioCfg.value); sleep(1); }进入无限循环后,时钟回复ucDioCfg.value的数值为0ucDioCfg.time的数值,会随着短路和断路变换,找不到原因,请帮忙解决一下。