PC speaker...

…OK, this should be an easy one,
What library call can you use to beep the PC speaker under QNX 6?

(I told you it was easy.)

Pete Eddy

“Pete Eddy” <peter.w.eddy@lmco.com> wrote in message
news:3D89CD20.20002@lmco.com

…OK, this should be an easy one,
What library call can you use to beep the PC speaker under QNX 6?

printf("\007" );

(I told you it was easy.)

Pete Eddy

David Donohoe wrote:

Using the devctl would be silly if you were building an embedded system,

You mean a “resource constrained” system, of course.

Our company does embedded systems with 2GHz processors, and 256MB ram.

Running a console driver would not be an issue (neither would writing
the code to drive the speaker - assuming the customer ever decided they
simply must have a unit that emits annoying sounds :slight_smile:. So IMO neither
approach is “silly” given the constraints previously discussed.

Rennie

Is there a command that gives you a little more control than that?
Such as the duration, pitch?

“Mario Charest” postmaster@127.0.0.1 wrote in message
news:amdih6$8aj$1@inn.qnx.com

“Pete Eddy” <> peter.w.eddy@lmco.com> > wrote in message
news:> 3D89CD20.20002@lmco.com> …
…OK, this should be an easy one,
What library call can you use to beep the PC speaker under QNX 6?


printf("\007" );

(I told you it was easy.)

Pete Eddy

Bob Smith <bobsmith@home.com> wrote:

Is there a command that gives you a little more control than that?
Such as the duration, pitch?

This code can be fairly easily converted to a function where the
duration and pitch are passed as arguments…

// 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, clk;


ThreadCtl(_NTO_TCTL_IO, 0);

kbd = mmap_device_io(4,0x60);
clk = mmap_device_io(4,0x40);

// turn on bits 0 & 1 of kbd 0x61
system_control=in8(kbd + 1);
out8(kbd + 1,system_control | 0x03);

// load control word for 8254

out8(clk + 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(clk + 2,0x02); // lsb count
out8(clk + 2,0x27); // msb count - remember, we’re using BCD

// pause a bit…
sleep(1);

// shut it off
system_control=in8(kbd + 1);
out8(kbd + 1,system_control & 0xfc);
return(0);

}


“Mario Charest” postmaster@127.0.0.1 wrote in message
news:amdih6$8aj$> 1@inn.qnx.com> …

“Pete Eddy” <> peter.w.eddy@lmco.com> > wrote in message
news:> 3D89CD20.20002@lmco.com> …
…OK, this should be an easy one,
What library call can you use to beep the PC speaker under QNX 6?


printf("\007" );

(I told you it was easy.)

Pete Eddy
\

David Green (dgreen@qnx.com)

QNX Software Systems Ltd.
http://www.qnx.com

dgreen@qnx.com wrote:

Bob Smith <> bobsmith@home.com> > wrote:
Is there a command that gives you a little more control than that?
Such as the duration, pitch?

This code can be fairly easily converted to a function where the
duration and pitch are passed as arguments…

David, you’re being silly… there is a devctl() for this, have a look in:

/usr/include/sys/dcmd_misc.h

Using the devctl() should make the code considerably smaller and eliminate the
need for the code to run with root privs.

Cheers,
Camz.

camz@passageway.com wrote:

dgreen@qnx.com > wrote:
Bob Smith <> bobsmith@home.com> > wrote:
Is there a command that gives you a little more control than that?
Such as the duration, pitch?

This code can be fairly easily converted to a function where the
duration and pitch are passed as arguments…

David, you’re being silly… there is a devctl() for this, have a look in:

/usr/include/sys/dcmd_misc.h

Using the devctl() should make the code considerably smaller and eliminate the
need for the code to run with root privs.

Using the devctl would be silly if you were building an embedded system,
and didn’t want the overhead of running the console driver just to make
a beep. Also, if you wanted to make a beep from startup or IPL code,
the devctl approach wouldn’t work.

Dave