|
/* * ID: console.c * DESCRIBE: Contorlling to call of "/dev/console",that is speaker of computer's board. * Author: shengguai168@yahoo.com.cn * DATE: Mon Nov 12 18:30:24 CST 2007 */
#include <fcntl.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <sys/ioctl.h> #include <sys/types.h> #include <linux/kd.h>
int console_fd; int i; int j=100000;
int main (int argc, char **argv) { if ((console_fd = open ("/dev/console", O_WRONLY)) == -1) { printf ("Failed to open console.\n"); exit (1); } for (i = 0; i < 10; i++) { ioctl (console_fd, KDMKTONE, (2000 | (300 << 16))); /* setting*/ ioctl (console_fd, KIOCSOUND, 500); /* tone begining*/ usleep (j); /*delay*/ ioctl (console_fd, KIOCSOUND, 0); /* stop tone*/ usleep (j); /* delay*/ } /* repeat play*/ return 0; }
|