简体   繁体   中英

IIO: can't open file /sys/bus/iio/devices/iio\:device1/in_voltage_1

I'm trying to use the raw value from an ADC channel. In my application I do:

open("/sys/bus/iio/devices/iio\:device1/in_voltage_1", O_RDONLY);

That returns errno 2 "No such file or directory", the file is there though since if I do:

$> cat /sys/bus/iio/devices/iio\:device1/in_voltage_1

I get the value I expect.

It also works if I make a soft link:

/etc/mylink -> /sys/bus/iio/devices/iio\:device1/in_voltage_1

And opens that link instead. The link has the same permissions as the original file.

What am I missing?

I'll leave this up despite of my shame, it may help someone.

It's obviously the backslash in the string argument to open. The path is actually:

/sys/bus/iio/devices/iio:device1/in_voltage_1

but the backslash is needed as an escape in the shell.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM