📄 led.c
字号:
/******************************************************************************* This is a small application that demonstrates how to make the LEDs on* the Quicknet Technologies, Inc. Internet LineJack card go blinky blink.** Written by Ed Okerson (eokerson@quicknet.net)* Quicknet Technologies, Inc.** The ixj driver uses the ioctl IXJCTL_SET_LED to determine which LED to* turn on, you pass it a char value and each of the l.s. bits represents* an LED. If the bit is 1 the LED will come on, if the bit is 0 the LED* will go off.******************************************************************************/#include <stdio.h> #include <stdlib.h> #include <strings.h> #include <sys/ioctl.h>#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>#include "ixjuser.h"int ixj;void led(char en){ printf("LED 1 = %d\t", en & 0x1?1:0); printf("LED 2 = %d\t", en & 0x2?1:0); printf("LED 3 = %d\t", en & 0x4?1:0); printf("LED 4 = %d\t", en & 0x8?1:0); printf("en = %d\n", en); ioctl(ixj, IXJCTL_SET_LED, en);}void closeall(void){ close(ixj);}int main(int argc, char *argv[]){ char pname[80]; sprintf(pname, "/dev/ixj%s", argv[1]); ixj = open(pname, O_RDWR); atexit(closeall); sleep(1); led(0x1); sleep(1); led(0x2); sleep(1); led(0x4); sleep(1); led(0x8); sleep(1); led(0x3); sleep(1); led(0xC); sleep(1); led(0x5); sleep(1); led(0xA); sleep(1); led(0x9); sleep(1); led(0x6); sleep(1); led(0x0); sleep(1); led(0xF); sleep(1); led(0x0); sleep(1); led(0xF); sleep(1); led(0x0); sleep(1); led(0xF); sleep(1); led(0x0); sleep(1);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -