如何与我自己的内核模块中导出到SYSF的sysfs或驱动程序进行互动?

发布于 2025-02-06 17:02:04 字数 421 浏览 2 评论 0原文

我正在尝试制作一个内核模块,该模块将多个设备曝光到单个字符设备。我成功编写了GPIO和CDEV部分,但我无法弄清楚W1_therm设备。

我在config.txt中使用带有DS18B20温度传感器的Raspberry Pi和DS18B20温度传感器和W1-GPIO-PULLUP驱动器,带有dtoverlay = W1-GPIO-PULLUP,GPIOPIN = 10在Config.txt中。它检测到温度传感器,我可以通过/sys/bus/w1/设备/28-062194159C7D/温度文件读取温度。但是,我想在内核模块中阅读它,并且我对如何与W1驱动程序进行互动。

我是否必须重写DS18B20驱动程序的驱动程序,还是可以以某种方式与已加载的驱动程序进行交互?还是可以从内核空间读取SYSFS文件?请有人可以指向正确的方向或提供示例代码?

I'm trying to make a kernel module that exposes multiple devices to a single character device. I successfully written the gpio and cdev portion but I can't figure out the w1_therm device.

I use a raspberry pi with a DS18B20 temperature sensor and the w1-gpio-pullup driver with dtoverlay=w1-gpio-pullup,gpiopin=10 in the config.txt. It detects the temperature sensor and I can read the temperature via the /sys/bus/w1/devices/28-062194159c7d/temperature file. However I want to read it in my kernel module and I'm stuct on how do I interact with the w1 driver.

Do I have to rewrite the driver for the DS18B20 driver or can I somehow interact with the loaded driver? Or can I read the sysfs file from kernel space? Please can someone point me in the right direction or provide an example code?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文