简体   繁体   English

IIO:无法打开文件/ sys / bus / iio / devices / iio \\:device1 / in_voltage_1

[英]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. 我试图从一个ADC通道使用原始值。 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: 返回错误2“没有这样的文件或目录”,该文件是存在的,虽然,因为如果我这样做:

$> 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. 显然是要打开的string参数中的反斜杠。 The path is actually: 路径实际上是:

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

but the backslash is needed as an escape in the shell. 但是反斜杠是外壳程序中的转义符。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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