Motherboard beep on Windows CE - c++

I wish to emit a "beep" from the motherboard of a system running Windows CE. Most information / code I have come across use MessageBeep which, from what I can tell, attempts to use the soundcard as opposed to the hardware on the motherboard.
I am using C++ but can you C#.NET if required.
I am running Windows CE 6 on a small PC and not a hand held device.

Have you tried printing a bell character?
cout << '\a';

If the OS audio driver isn't plumbed down to that device (and it sounds like it isn't since it's coming from the sound card's device) then you're going to have to go directly to it with ASM code. You might even have to put it into a driver (user mode should work fine) in order to get access to the hardware.
Assuming you're on an X86 (I've never seen an ARM device with a speaker on the motherboard) then the code is no different than that used by someone running any other OS (since you're going direct to the hardware). A quick search for "x86 beep in asm" turned up a couple promising leads.

Related

How to program a virtual sound output device on windows 7+?

I want to add a new sound device on windows 7+ so that I can redirect the computer sound on the network (using a protocol of my own or PulseAudio for example).
Basically, I think I want to write a kernel driver that expose a new sound output device to the OS. If there's a way to write the driver so that I only have to deal with a simple sample buffer input to process it would be great (the simpler the better). I don't care too much about latency, I just want it to be as transparent as possible for the system and the applications running so that everything goes through this virtual device out of the box.
I have some experience in Linux kernel development but I know next to nothing about Windows driver development. I have a genuine Visual Studio 2013 ultimate and I want to target Windows 7 (above would be nice but it has to work on W7).
I would like to know which API/framework/system should I use to achieve my goal and possibly link to dev ressources to get me started.

Why don't I hear any sound after calling the Beep function in Windows 7?

I have the following code:
#include <windows.h>
#include <stdio.h>
int main(void)
{
Beep(523, 500);
Sleep(1000);
return 0;
}
I am compiling it using MinGW with Dev-C++. My problem is that I can't hear anything, although I don't get an error. I have Windows 7. Any ideas?
Turn your speakers on. If they're already on, turn up the volume. If you don't have speakers and a sound card installed on your computer, then get some and install them, then try running the program again.
All of these things are required to hear anything from the Beep function on Windows 7. It no longer plays sound from the built-in hardware system speaker. Instead, the sound is passed to the default sound device for your user session. In a standard local user session, that would be your sound card. The documentation explains this important detail in the "Remarks" section:
A long time ago, all PC computers shared a common 8254 programable interval timer chip for the generation of primitive sounds. The Beep function was written specifically to emit a beep on that piece of hardware.
On these older systems, muting and volume controls have no effect on Beep; you would still hear the tone. To silence the tone, you used the following commands:
net stop beep
sc config beep start= disabled
Since then, sound cards have become standard equipment on almost all PC computers. As sound cards became more common, manufacturers began to remove the old timer chip from computers. The chips were also excluded from the design of server computers. The result is that Beep did not work on all computers without the chip. This was okay because most developers had moved on to calling the MessageBeep function that uses whatever is the default sound device instead of the 8254 chip.
Eventually because of the lack of hardware to communicate with, support for Beep was dropped in Windows Vista and Windows XP 64-Bit Edition.
In Windows 7, Beep was rewritten to pass the beep to the default sound device for the session. This is normally the sound card, except when run under Terminal Services, in which case the beep is rendered on the client.

Play sound on internal speakers and possibility to use old xp api function?

After the release of windows vista the Windows Function Beep plays a beep on your connected speakers instead of the internal one.
Is there anyway to access the old function? Would it be possible by getting hold in an older windows api? Or is there any other way i can make this possible? If so i would like the ability to set both the frequency and duration.
I should mention that I´m actually targeting the windows xp platform.
No. The function is implemented in a Kernel32.dll, which is loaded at runtime from whatever version of the OS you're currently running. Since the code isn't there in either your executable or in a system DLL, you can't run it (don't even think about copying over Kernel32.dll from a different OS version, that's just screaming for trouble).
You can try using MessageBeep instead of Beep, but that gives you less control over the output and will probably still use your sound card instead of the internal
For an interesting history of the MessageBeep function, see Larry Osterman's blog.
The majority of computers now don't have internal speakers, so there's nothing there to access.
The function was intentionally removed in Windows 7, according to Larry Osterman's blog; this post from the archives specifically discusses that issue. It seems that Beep.sys was removed, and the functionality of that old pseudo-device driver was changed to intentionally redirect sound to the sound card instead. The article is an interesting read from a historical standpoint.
Larry is a MS employee who worked on the new audio framework for Vista and Win7, and he's been at MS since the dinosaur days (MS-DOS at least :D) so he'd probably know. :)

Interaction between Bluetooth and a computer

I'm developing a device and writing the software for it under Windows (MFC with Visual Studio).
I would like to start a measurement with a remote. It would be nice if it worked over Bluetooth, but I don't have a clue where to start.
What book can recommended or is there a site where such things are described?
Is it even possible to make my own Bluetooth device or do I have to pay some fee for licences?
What I would like to have, is a Bluetooth-remote with one button, which sends a signal to a Windows PC where a program then starts specific subroutines.
As Dan wrote in the comment when it comes to Microsoft the best place to start is with MSDN. For me his link didn't work, but I guess he wanted to point here.
MFC does not offer you support for Bluetooth, instead you have to work with a Bluetooth driver stack API. On Windows there are more stacks, but most widely used are: Microsoft Bluetooth driver stack and Widcomm/Broadcom. If you decide to use the Microsoft Bluetooth driver stack you might want to look on this thread. The stack that you choose it depends on the Bluetooth dongle attached/incorporated at your PC.
Is it even possible to make my own Bluetooth device or do I have to pay some fee for licences?
Yes, it is possible to make your own Bluetooth device. The fee depends from case to case, first if you want to be assigned your own IDs from SIG you have to pay them a fee, otherwise you can use the ones already bought by the chip manufacturer. Also if you want to re-write the firmware from the chip you could be forced to buy a software from the chip manufacturer. Usually it's enough with their firmware.
What I would like to have, is a Bluetooth-remote with one button, which sends a signal to a Windows PC where a Software then starts specific subroutines.
Well, it seems you will have to take care of the device discovery aspect and second make the pairing. After this you could use Serial Port Profile to communicate with your device like any other RS-232 enabled device. If your device is dedicated you might want to modify the IAC - Inquiry Access Code so in discovery phase only you that you know the code, can see the device.

Blink LED using Visual C++

I am new to vc++, I have to create a simple vc++ application so that I can turn off or turn on an LED ( or an electrical bulb powered by a cell), How can I take the control out from my program, I would like to use a USB for connecting the output.
Is there any library available for implementing USB integrating in the program ?
Have a look into the FTDI FT232RL series of chips. They're so common that the driver is already included in most operating systems. It's a USB-to-serial device, but it has a "bit bang" mode which turns the serial lines into individually addressable IO lines that can be used either as signal lines for your own protocol, or to so simple things like drive an LED.
Hack a Day has a great tutorial on using this device to (believe it or not) blink an LED connected via USB, including sample code written in C. Find the tutorial here: http://hackaday.com/2009/09/22/introduction-to-ftdi-bitbang-mode/
The chips are easy to come by. The chip itself costs about $4 on its own, or you can spend about $15 to get it on a breakout board with a USB connector and such. Many USB-to-serial cables or converter boxes, or even the adapter cables for older cell phones contain this chip inside to do the actual translation, so if you have such a thing lying around already, you may want to try it.
USB does not have any ability to drive a LED directly; you will need an interface circuit. That circuit will need driver software, and this will determine how the software will operate. It is impossible to know how to write the program without knowing the driver.
You might have better luck using the legacy parallel port rather than USB. I can't direct you to any resources, but a quick search (even here on StackOverflow) should turn up something.