我在Linux设备驱动程序3的示例中尝试使用short.c
我的电脑有并行端口,在Ubuntu启动后,我可以看到:
cat /proc/ioports
0378-037a : parport0
037b-037f : parport0
outp 0x378 1
(outp is another example in LDD3 which write data to ports)
the LED on the port is ON.
然后我运行这些命令来删除模块
rmmod lp
rmmod parport_pc
cat /proc/ioports
(There is no module on 0378-037f any more.)
我再次运行,但这次LED不亮。
outp 0x378 1
然后我安装short.ko和request_region()成功。
cat /proc/ioports
0378-037f : short
cat /proc/devices
249 short
outp 0x378 1
the LED is not ON this time either.
我也尝试了这些,但结果相同(LED不亮)
mknod /dev/short0 c 249 0
echo -n "a" > /dev/short0
""是0x61,因此最后一位是1.
虽然我有I / O区域但为什么不能写出数据?
感谢您的回答。
答案 0 :(得分:0)
最后,我找到了解决方案。
确保未将“parport”模块加载或编译到内核中。仅仅卸载parport模块是不够的,因为它使端口处于不一致状态。您必须重启机器并保持parport和所有相关的模块/代码不被加载。
一种方法是编辑/etc/modprobe.d/blacklist.conf文件并添加以下行:
blacklist ppdev
blacklist lp
blacklist parport_pc
blacklist parport
似乎partport已经修改了并行端口的模式。
如果安装了cups,你应该修改/etc/modules-load.d/cups-filters.conf:
#lp
#ppdev
#parport_pc