I am wondering how can I ask Windows and retrieve a list over current input devices?
Language is C++.
The goal is to select from the list in a program I am making.
Tried searching a bit, but found nothing..
Please help :)
Thank you.
For the sake of future reference, it might be worth mentioning the RtAudio library, which is also written in C++ and is multiplatform on Windows, OS-X and Linux.
On Windows you can compile it either using the ASIO SDK (in case your devices have an ASIO driver), DirectSound (part of DirectX, old and deprecated, but still working), or WASAPI (introduced in Windows Vista).
With RtAudio you can manage devices very easily with class method calls such as:
RtAudio::startStream();
RtAudio::stopStream();
RtAudio::getDeviceCount();
RtAudio::getDefaultInputDevice();
RtAudio::getDeviceInfo(uint deviceID);
You can also manage output devices in the same fashion.
This can be done through the WaveIn Windows API. Since there is already a post with code to enumarate and retrieve the names of input devices here I won't make a new one.
Related
I need to implement an application on Linux that drives a USB connected device (a medical instrument). The application will be written in C++ (2011 standard).
The current application is written for Windows 10 in C# and uses the standard Winusb driver enumerated for the device. I have a complete protocol specification for the commands and the events/interrupts coming back. Unfortunately, I'm not sure how I can pass these to the USB layer in Linux. If it was a simple serial device, there would be no problem but I'm guessing the command responses and the interrupt events are multiplexed by the driver using the functionality in the Winusb driver.
Where's the best place to start in terms of documentation? Alternatively, is there a Linux library (or driver) that provides more or less the same functionality as winusb for Linux?
Any help appreciated. Thanks
Alternatively, is there a Linux library (or driver) that provides more or less the same functionality as winusb for Linux?
One way is using directly the generic kernel API for USB (see the Asynchronous I/O parts to get the interrupts):
https://www.kernel.org/doc/html/v4.15/driver-api/usb/usb.html
This is the strict Linux equivalent of WinUSB.
The potentially less hard way is using libusb, which also get you cross-platform features.
(I am assuming your device is recognized correctly by the kernel, and doesn't need a custom driver)
Is there a Linux library (or driver) that provides more or less the same functionality as winusb for Linux?
Yes. libusb is a popular USB abstraction library that supports Linux, macOS, and Windows. I also wrote a similar library called libusbp with a different set of features that were more useful for my applications. These are C libraries so it will take some work to interoperate with them from C#, but once you do that, you can probably use the same code on either Windows or Linux (so you wouldn't have to maintain your code for calling WinUSB).
I am developing C++/Qt application which interacts with Tektronix TDS2002 oscilloscope via USB. The oscilloscope appears as "USB Test and Measurement device (IVI)".
Currently I use TekVISA library supplied by the oscilloscope's vendor. It works, but it is huge, old, buggy and poorly maintained. Therefore I would like to bypass the library and interface the device directly.
So far I have found this simple library: https://github.com/xyphro/WinUsbTmc It is exactly what I am looking for, but it uses libusb which requires to install some device filter and in addition it is advised to be more development tool than customer solution. Do you have any experience on this?
What is the easiest way to interact with USB Test and Measurement device in Windows/C++/Qt?
Thank you for your suggestions :)
You need a USB driver. My oscilloscope works with the driver included in this VISA package (the driver can be extracted very easily): http://www.keysight.com/main/software.jspx?cc=CZ&lc=eng&nid=-11143.0.00&id=2504667&pageMode=CV I assume all USB TMC devices can use the same driver, but I have no possibility to check this.
USB driver can be accessed via standard Windows functions. Guys on this forum were really close:
https://forum.tek.com/viewtopic.php?f=568&t=137573 and also this document was very useful: http://www.ivifoundation.org/downloads/Class%20Specifications/Ivi-6%202_USBTMC_2010-03-23.doc
You cannot write commands to OSC directly - data you send and receive have certain header which has to be in the correct format, otherwise the oscilloscope ignores the message. See reading and writting implementation in this simple library: https://github.com/xyphro/WinUsbTmc I didn't use this library because it uses libusb library which uses some kind of device filter and I personally do not like this concept (and in addition I have genuine working driver).
Data you read have also a simple header. To ensure you fit the header structure on input data well, you should first flush the input buffer. Then you issue reading request (using write command - see WinUsbTmc library above) and finally you receive the data and fit the header on its beginning.
I hope this will help to somebody :)
With regards
klasyc
I am looking to communicate via RFCOMM to another Bluetooth device. I want to use C++ (VS2008) for the application. I already know of the 32feet library, but was unsure if it would work for C++. Does anyone know of a good starting point for this kind of project? Or possibly 32feet samples written in C++? I want a simple, easy to use API for Bluetooth using C++.
This question is rather old, I know.
Just wanted to update, that Qt Framework has now Qt Bluetooth for C++ that looks very promising -- http://doc.qt.io/qt-5/qtbluetooth-module.html
You can do Bluetooth programming using BT sockets into the OS Bluetooth stack. This page discusses socket usage:
http://msdn.microsoft.com/en-us/library/windows/desktop/aa362928(v=vs.85).aspx
This page has links to download Bluetooth SDK from Microsoft:
http://msdn.microsoft.com/en-us/library/windows/desktop/aa363058(v=vs.85).aspx
Building apps using the Microsoft stack works fairly well (XP and Vista work great, trying to run the same apps under Windows 7-64bit does not work so well...)
The real advantage to 32feet.net is that the Bluetooth support on Windows is heavily Balkanized - you never know on a given machine whether it is using the Microsoft, Broadcom, Toshiba, BlueSolei, or some other stack. While these are all mostly compatible over-the-air, the APIs are completely different for each. Building with 32feet.net lets your application run on a larger subset of machines... That said, I have not tried building it into a C++ application - sorry.
I've tried to find a way to detect when a new device (like a USB) is inserted into a computer, but everything I've seen required MFC, which I don't have. Is there a way to do this without MFC? If not, I understand, but I haven't seen anything of the like in my Google searches.
Thanks,
C++ by itself does not have any platform-dependent hardware-level functionality. You will need to use some API, like Win32 or MFC or .NET on Windows.
You can do this using libusb and there's a port of libusb for win32, so you might have some luck using that instead of MFC, with the added bonus of being more portable.
Handle the WM_DEVICECHANGE message.
See http://msdn.microsoft.com/en-us/library/aa363480(v=vs.85).aspx
EDIT: Of course, this is Windows only, which the OP didn't specify. There's no way to do this without external libraries or platform specific APIs.
I'm a long time Windows developer, and it looks like I'm going to be involved in porting a Windows app to the Mac.
We've decided to use Flex/Air for the gui for both sides, which looks really slick BTW.
My Windows application has a C++ DLL that controls network adapters (wired and wireless). This is written using the standard library and Boost, so most of it should work cross platform.
On the Mac, what IDE/complier do most folks use if they want to write C++? Also, can someone provide a pointer to whatever APIs the Mac has that can control WiFi adapters (associate, scan, disconnect, etc)?
Xcode is the IDE for Mac OS X, you can download the latest version by joining the Apple Developer Connection with a free Online membership.
I don't believe there are any supported APIs for controlling wireless networking adaptors. The closest thing would be the System Configuration framework, but I don't know if it will let you do everything you want.
Also, I would strongly recommend against trying to use Flex/Air for your application's user experience. It may look slick to you on Windows as a Windows developer, but when it comes to providing a full Macintosh user experience such technologies aren't always a great choice.
For one example, I think Air applications don't support the full range of Mac OS X text editing keystrokes. While not all Mac users will use all keystrokes, for those people used to them trying to type in a text field that doesn't handle (say) control-A and control-E to go to the beginning and end of field is like swimming through syrup.
For a new application that needs to be cross-platform, I'd strongly consider building the core logic in C++ while using Cocoa on the Mac and WPF on Windows to get the best user experience on each platform. Both Mac OS X and Windows have modern native user experience technologies that their respective users are getting used to, and also have good ways for C++ code to interoperate with these technologies.
The de-facto OS X IDE and compiler is Xcode. It comes with every Mac, you just install it from the OS X install CD.
Apple's developer site is the place to get more information on OS X APIs
Xcode and a custom GCC I believe...
xcode is the hotness, as people have already pointed out.
Having maintained a windows/mac codebase in the past, take a look at MVC.
So long as you keep the background logic distinct from the UI and from the platform-specific stuff (like file handling, networks, drawing to the screen, etc). That way, when you want to go to Linux in the future, you just have to write those platform specific components.
As for mac networking, are you on the level of connecting and so forth? Why not just let the OS handle that, and then you just see what connections are available? Why bother with whether or not the connection is wired or wireless? Because the OS has a lot of those tools already built in and users are used to making sure that the connection is there to do work, it seems odd to have an extra program to want to manipulate the network.
Xcode is used a lot, as far as I know the combination editor (e.g. Textmate), command line gcc is in fairly heavy use too. (that's what I do on OS X)
For all API needs head to Apple's developer site e.g. the networking API's