无法使用outb()调用来点亮键盘LED

问题描述 投票:2回答:1

我正在尝试使用以下程序(在Internet上找到此程序)点亮Linux中的键盘LED,但似乎什么也没发生。我有什么遗漏吗?

/* sample.c: very simple example of port I/O
 *
 * This code does nothing useful, just a port write, a pause,
 * and a port read. Compile with `gcc -O2 -o example example.c',
 * and run as root with `./example'.
 */

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/io.h>

#define BASEPORT 0x0060 /* lp1 */

int main()
{
        /* Get access to the ports */
        if (ioperm(BASEPORT, 3, 1)) {perror("ioperm"); exit(1);}

        /* Set the data signals (D0-7) of the port to all low (0) */
        outb(0xED, BASEPORT);

        /* Sleep for a while (100 ms) */
        usleep(1000);
        printf("\n here ");
        outb(0x07, BASEPORT);
        usleep(1000);

        /* We don't need the ports anymore */
        if (ioperm(BASEPORT, 3, 0)) {perror("ioperm"); exit(1);}
    exit(0);
}
c linux-device-driver device-driver hardware-port
1个回答
-1
投票

使用此逐步指南来控制键盘LED的https://www.youtube.com/watch?v=AP9eXT8HqlA&feature=youtu.be

© www.soinside.com 2019 - 2024. All rights reserved.