博客首页 注册 建议与交流 排行榜 加入友情链接
推荐 投诉 搜索: 帮助

GNU/LINUX!My first love

爱她就要像爱自己的GIRL一样,不断发现她的优点...
   pxebxp.cublog.cn
关于作者  
姓名:
职业:
年龄:
位置:
个性介绍:

我的分类  




Contorlling to call of "/dev/console"
/*
 * 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;
}

 发表于: 2007-11-12,修改于: 2007-11-12 23:55 已浏览323次,有评论2条 推荐 投诉

  网友评论
  wuzhao 时间:2008-01-22 23:27:15 IP地址:221.222.248.★
请问博主,这种控制响铃的方法是否跟内核相关?因为我在发行版的linux上测试没问题,但用自己编译内核后的系统测试却不行~~~

  本站网友 时间:2008-04-12 11:07:44 IP地址:116.25.80.★
这个问题我明年给你答复,我还没深入研究过内核的相关问题。


  发表评论



Copyright © 2001-2006 ChinaUnix.net All Rights Reserved

感谢所有关心和支持过ChinaUnix的朋友们
页面生成时间:2.1332

京ICP证041476号