Re: Beeping in Linux

Liste des GroupesRevenir à cu programmer 
Sujet : Re: Beeping in Linux
De : wyniijj5 (at) *nospam* gmail.com (wij)
Groupes : comp.unix.programmer
Date : 27. Oct 2024, 13:00:34
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <185a06463a1c6a2af69508bd1ec2d2a64587ce7f.camel@gmail.com>
References : 1
User-Agent : Evolution 3.50.2 (3.50.2-1.fc39)
On Sun, 2024-10-27 at 08:21 +0000, Muttley@dastardlyhq.com wrote:
I'm looking at a way of making the machine beep without relying on having a
TTY available to send \7 to or going all heavyweight with ALSA.
 
I've found something online that mentioned ioctl() + the KDMTONE option but I
can't find any example code. Does anyone know how its done?
 
Thanks for any help
 

This is the beep(..) implement in libwy https://sourceforge.net/projects/cscall/files/latest/download
Root privilege is required.

/* Copyright is licensed by GNU LGPL, see file COPYING.       by I.J.Wang 2018
 
   This file is header only
*/
#ifndef WY_IOCTL_H__
#define WY_IOCTL_H__
#define WY_IOCTL_VERSION 69

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

#ifndef CLOCK_TICK_RATE
#define CLOCK_TICK_RATE 1193180
#endif

namespace Wy {

inline
Wy::Errno beep(Wy::FileHandle fh, unsigned int freq, unsigned int msec)
{
 Wy::Errno r;
 if(((msec&0xffff)!=msec)||(freq<=0)||(CLOCK_TICK_RATE/freq>0xffff)) {
   WY_RETURN( EINVAL );
 }
 if((::ioctl(fh.fd(),KDMKTONE,( (msec<<16)|(CLOCK_TICK_RATE/freq) )))==-1) {
   WY_RETURN(errno);
 }
 return Wy::Ok;
};

}; // end namespce Wy

#endif // end WY_IOCTL_H__



Date Sujet#  Auteur
27 Oct 24 * Beeping in Linux4Muttley
27 Oct 24 +- Re: Beeping in Linux1Marcel Mueller
27 Oct 24 `* Re: Beeping in Linux2wij
27 Oct 24  `- Re: Beeping in Linux1Muttley

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal