- 论坛徽章:
- 1
|
Following code works correctly with MX35, but does not work with MX28. It seems that empty string is read from the gpio file when running with MX28:
attrFile = fopen("gpioFilename", "r");
n = fscanf(attrFile, "%hd", &pin_state);
fclose(attrFile);
It does not work even I read twice:
attrFile = fopen("gpioFilename", "r");
n = fscanf(attrFile, "%hd", &pin_state);
n = fscanf(attrFile, "%hd", &pin_state);
fclose(attrFile);
I have to add dummy reading to a different data type, then the correct pin state can be read:
attrFile = fopen("gpioFilename", "r");
n = fscanf(attrFile, "%c", &chVal);
n = fscanf(attrFile, "%hd", &pin_state);
fclose(attrFile);
MX35 does not have this problem.
Anybody has any clue?
Thanks, |
|