Hello.
Does anyone know can make my PC speaker play a beep from a C program on QNX 6?
Thank you,
Jose
Hello.
Does anyone know can make my PC speaker play a beep from a C program on QNX 6?
Thank you,
Jose
Jose A. Galvez <jagalvez@iai.csic.es> wrote:
Hello.
Does anyone know can make my PC speaker play a beep from a C program on QNX 6?
Thank you,
Jose
–
// beep the PC speaker
#include <stdlib.h>
#include <stdio.h>
#include <x86/inout.h>
#include <sys/neutrino.h>
#include <unistd.h>
int main()
{
int system_control=0;
unsigned long i;
unsigned long kbd, ctr;
// turn on bits 0 & 1 of kbd 0x61
ThreadCtl(_NTO_TCTL_IO, 0);
kbd = mmap_device_io(4,0x60);
ctr = mmap_device_io(4,0x40);
system_control=in8(kbd + 1);
out8(kbd + 1,system_control | 0x03);
// load control word for 8254
out8(ctr + 3, 0xb7); // bcd count, square wave,
// r/w lsb then msb, channel 2
// load counts
// to get 440Hz tone, divide 8254 clock (1.1892 MHz) by 2702
out8(ctr + 2, 0x02); // lsb count
out8(ctr + 2, 0x27); // msb count
// pause a bit…
for(i=0; i<50000000; i++);
// shut it off
system_control=in8(kbd + 1);
out8(kbd + 1,system_control & 0xfc);
return(0);
Dave Green (dgreen@qnx.com)
QNX Software Systems Ltd.
http://www.qnx.com
simple solution
printf("\a");
“Jose A. Galvez” <jagalvez@iai.csic.es> wrote in message
news:3CBD9B73.587F35F4@iai.csic.es…
Hello.
Does anyone know can make my PC speaker play a beep from a C program on
QNX 6?Thank you,
Jose
Just output a control-G to the terminal window (to which stdout and stderr
are connected by default). Control-G is ASCII code 7, or \a within strings.
dB
“Jose A. Galvez” <jagalvez@iai.csic.es> wrote in message
news:3CBD9B73.587F35F4@iai.csic.es…
Hello.
Does anyone know can make my PC speaker play a beep from a C program on
QNX 6?Thank you,
Jose
// pause a bit…
for(i=0; i<50000000; i++);
// shut it off
Iiiiihhhh… that will not work sooo good on faster machines, why not use a
timer instead?
didnt think ppl used to modern computers did such things
“John Hertell” <john.hertell@removedizonetopreventspam.accom.se> wrote in
message news:a9oosp$kji$1@inn.qnx.com…
// pause a bit…
for(i=0; i<50000000; i++);
// shut it off
Iiiiihhhh… that will not work sooo good on faster machines, why not use
a
timer instead?didnt think ppl used to modern computers did such things >
I hope that modern people on modern computers with modern operating systems
use smth like Beep(,) so system speacker is supported by os on
driver’s level and you don’t need to access hardware by hands just to say
“be-beep”
// wbr
if you want a bell beep, another short answer is
printf ("%c", 0x07);
Javier
“Jose A. Galvez” <jagalvez@iai.csic.es> escribió en el mensaje
news:3CBD9B73.587F35F4@iai.csic.es…
Hello.
Does anyone know can make my PC speaker play a beep from a C program on
QNX 6?Thank you,
Jose