RE: Programing in C...
I stand corrected...here's the modified code then: int main(void) { printf("\a"); return(0); } -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of Hamish Moffatt Sent: Friday, April 21, 2000 12:23 AM To: [EMAIL PROTECTED] Subject: Re: Programing in C... On Thu, Apr 20, 2000 at 08:02:32AM -0700, Michael Anderson wrote: > if you just want a beep, then try for more portable code: > #include > > void main(void) > { > printf("\7"); > } Actually, printf("\a") would be more portable. \7 assumes your computer is using the ASCII character set. If you want to get really picky, a lot of ANSI C compilers will not compile "void main" because it is not a valid prototype for main. main must return an int. Hamish -- Hamish Moffatt VK3SB <[EMAIL PROTECTED]> <[EMAIL PROTECTED]>
Re: Programing in C...
On Thu, Apr 20, 2000 at 08:02:32AM -0700, Michael Anderson wrote: > if you just want a beep, then try for more portable code: > #include > > void main(void) > { > printf("\7"); > } Actually, printf("\a") would be more portable. \7 assumes your computer is using the ASCII character set. If you want to get really picky, a lot of ANSI C compilers will not compile "void main" because it is not a valid prototype for main. main must return an int. Hamish -- Hamish Moffatt VK3SB <[EMAIL PROTECTED]> <[EMAIL PROTECTED]>
RE: Programing in C...
if you just want a beep, then try for more portable code: #include void main(void) { printf("\7"); } -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of Shawn T. Rutledge Sent: Thursday, April 20, 2000 7:43 AM To: [EMAIL PROTECTED] Subject: Re: Programing in C... Thanks! I was wanting to do that just the other day, for tuning up my radio... wanted to write a script to beep whenever an incoming packet was decoded, with a different tone for different senders... I was pinging two stations at once, and watching the "quality" signal from my TNC, so my eyes were busy and I would've liked to hear the beeps when I had it tuned right and it actually got a packet (hiss - voltage goes up - "beep!"). Was tweaking the discriminator can in a Mitrek, and it's really touchy. So now I know how to write a beep utility to call from a shell script. On Thu, Apr 20, 2000 at 07:46:36AM -0400, Dave Mielke wrote: > [quoted lines by r00t the LiNuXeRRR on April 20, 2000, at 10:59] > > > Does exist a sound(); function like the one from Borland C from > >dos that turns on the speaker at a given frequance... The sound(); > >function doesn't work in linux... > > Yes. You do it through ioctl. Open a file descriptor to the console: > > int fd = open("/dev/tty0", O_WRONLY); > > Start the tone by: > > ioctl(fd, KIOCSOUND, (119 / herz)); > > Stop the tone by: > > ioctl(fd, KIOCSOUND, 0); > > For O_WRONLY, you'll need: > > #include > > For KIOCSOUND, you'll need: > > #include -- ___ Shawn T. Rutledge / KB7PWD [EMAIL PROTECTED] (_ | |_) http://www.bigfoot.com/~ecloud [EMAIL PROTECTED] __) | | \ Get money for spare CPU cycles at http://www.ProcessTree.com/?sponsor=5903
Re: Programing in C...
Thanks! I was wanting to do that just the other day, for tuning up my radio... wanted to write a script to beep whenever an incoming packet was decoded, with a different tone for different senders... I was pinging two stations at once, and watching the "quality" signal from my TNC, so my eyes were busy and I would've liked to hear the beeps when I had it tuned right and it actually got a packet (hiss - voltage goes up - "beep!"). Was tweaking the discriminator can in a Mitrek, and it's really touchy. So now I know how to write a beep utility to call from a shell script. On Thu, Apr 20, 2000 at 07:46:36AM -0400, Dave Mielke wrote: > [quoted lines by r00t the LiNuXeRRR on April 20, 2000, at 10:59] > > > Does exist a sound(); function like the one from Borland C from > >dos that turns on the speaker at a given frequance... The sound(); > >function doesn't work in linux... > > Yes. You do it through ioctl. Open a file descriptor to the console: > > int fd = open("/dev/tty0", O_WRONLY); > > Start the tone by: > > ioctl(fd, KIOCSOUND, (119 / herz)); > > Stop the tone by: > > ioctl(fd, KIOCSOUND, 0); > > For O_WRONLY, you'll need: > > #include > > For KIOCSOUND, you'll need: > > #include -- ___ Shawn T. Rutledge / KB7PWD [EMAIL PROTECTED] (_ | |_) http://www.bigfoot.com/~ecloud [EMAIL PROTECTED] __) | | \ Get money for spare CPU cycles at http://www.ProcessTree.com/?sponsor=5903
Re: Programing in C...
r00t the LiNuXeRRR wrote: > Does exist a sound(); function like the one from Borland C from > dos that turns on the speaker at a given frequance... The sound(); > function doesn't work in linux... > Thanx for help... > Seby... I'm not positive, but I know that some compilers, Borland for one, have their own proprietary way of doing some things, especially if its for one platform only (like DOS)- so in some cases all the stuff you can do with Borland C in DOS you couldn't do with GCC in UNIX/Linux. It's non-standard functions. GCC (egcs, whatever) is a Standard C compiler, conforms to ANSI C standard, so it wouldn't have any of those things that are extra/proprietary (as you probably know). I think there may be a function in std C libs for doing that though but I can't recall it off the top of my head. So to answer your question I can't say I know the answer.. ;-). I have my C textbook lying around I can look it up... -- Matt M LinuxKnight [EMAIL PROTECTED]