linuxiio

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?


Solution

  • 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.