Re: PC Speaker

Ely Wilson (plexus@ionet.net)
Wed, 4 Nov 1998 11:59:58 -0700 (MST)


On Wed, 4 Nov 1998, Steven S. Dick wrote:

> You wrote:
> >Okay, i checked the lkml faq, libc info and man pages, KHG and the LPG. I
> >cannot find out what device to be using the ioctl(,KDMKTONE,); fucntion
> >'against'.
>
>
> In 2.0 kernels, I have used /dev/console or /dev/tty1 ...
>

Well, /dev/console is only writable by root.root executed programs, so i
opt'd for /dev/tty.. I can get the file open (with a mode 666 it's no
surprise) but the following code does not produce a tone as expected.

----snip----
/*
spt.c

test pc speaker coding
*/

#include <fcntl.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <linux/kd.h>

int main(void)
{
int tfd;
long tone;

tfd=open("/dev/tty", O_RDWR);

if (tfd==-1)
{
printf("Error opening file.\n");
return -1;
}

tone = 0x0fff0fff;
ioctl(tfd, KDMKTONE, tone);
sleep(1);

close(tfd);
return 0;
}
----snip----

So.. :) What exactly did I miss? I've been tinkering with these few lines
of code for over an hour now.. I'm out of coffee and quite frustrated.
I have tried both /dev/tty and /dev/console both as root and a user to no
avail. I've tried several values for tone, as well as a pointer dereference
to the values (even though documentation doesn't say to.. i had to try.)

Anyhow, thanks for your help.

----------------------------------------------------
ely <plexus@ionet.net>

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/