Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Hardware
User Name
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?


  Search this Thread
Old 08-30-2005, 05:23 PM   #1
LQ Newbie
Registered: Mar 2004
Posts: 17

Rep: Reputation: 2
How do I beep PC speaker without a console?


I have a linux firewall that sits in a closet in a dark forgotten basement. It doesn't have a graphics card, so I've made the console be the serial port.

In a previous project on a different computer, I was able to make the console beep a couple of times at a different frequency when it had successfully booted. Unfortunately, that required a normal vga console to make it work.

If I do "/bin/echo -e \\a > /dev/console", it shows up as data on the serial port.

I've got the pcspkr module loaded, and it shows up in /proc/bus/input/devices, but now what? What device do I have to open and what ioctl do I have to run, or alternatively, what program do I download and run?

Old 08-30-2005, 07:52 PM   #2
LQ Newbie
Registered: Mar 2004
Posts: 17

Original Poster
Rep: Reputation: 2
Lightbulb Solution!

After much searching and sending email to the maintainer (Vojtech Pavlik), a solution was found!

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <linux/kd.h>
#include <stdio.h>

#define ERROR (-1)

main() {
  int fd=open("/dev/tty0",O_RDWR|O_NDELAY);

  if (fd<0) {

  /* 125 = 125 milliseconds, or 1/8th of a second;
      0x637 is the number of clock cycles in the standard kernel beep */ 
  if (ioctl(fd,KDMKTONE,(125<<16)+0x637) == ERROR) {
    perror("/dev/tty0: ioctl");

Initially this was tried with /dev/tty and /dev/console, and it didn't work with either of them. Only /dev/tty0 worked, and even that would not have worked if CONFIG_VT was disabled in the kernel configuration.

Many thanks to Vojtech!
1 members found this post helpful.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to make pc speaker beep in slackware vrillusions Linux - Hardware 5 03-02-2010 11:15 PM
obsd: constant pc speaker beep with gigabyte board Fonk *BSD 0 09-26-2005 04:07 AM
Incredibly annoying pc speaker beep on error in MySql in Windows XP nazdrowie Programming 2 07-15-2005 02:26 AM
FC3 no console beep Soabirw Linux - Software 2 06-21-2005 05:22 PM
Disable the console beep? csvke Linux - General 6 03-01-2004 05:00 AM > Forums > Linux Forums > Linux - Hardware

All times are GMT -5. The time now is 03:56 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration