在我的学校里,我的项目是制作一个控制 LED 灯的简单程序
我的教授说 outp() 在 conio.h 中,我知道 conio.h 不是标准的。
outp() 的例子
//assume that port to be used is 0x378
outp(0x378,1); //making the first LED light
提前致谢
最佳答案
只要您对 /dev/port
具有写入权限(root 或某些用户具有写入权限)。您可以在 shell 中使用:
echo -en '\001' | dd of=/dev/port bs=1 count=1 skip=888
(注意 888 十进制是 378 十六进制)。我曾经用这种方式完全用 shell 脚本为 Linux 编写了一个可工作的并行端口驱动程序。 (虽然它相当慢!)
你可以像这样在 Linux 中用 C 实现:
f = open("/dev/port", O_WRONLY);
lseek(f, 0x378, SEEK_SET);
write(f, "\01", 1);
显然,添加#include
和错误处理。
关于c - gcc 编译器中的 outp() 对应项是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7634549/