FindAllAsync can't find device in windows store app - winapi

The vendor Id and product Id is being passed to FindAllAsync and there is no device returned from FindAllAsync. We've verified that these are the right device IDs and works on other platforms. It's not a plug and play device.
Here is the code below:
UInt32 VendorId = 0x1D1B;
UInt32 ProductId = 0x1202;
string aqs = UsbDevice.GetDeviceSelector(VendorId, ProductId);
var myDevices = await Windows.Devices.Enumeration.DeviceInformation.FindAllAsync(aqs);
if (myDevices.Count == 0)
{
return;
}
There are no devices found. Any ideas?
Clarification
I should clarify. It's not behaving like it's PNP and not appearing in the device manager in win8 and win7. The device works with a native application for driving the device even though it does not appear in the device manager.

if (myDevices.Count == 0) then you AQS filter doesn't match any device interface in the system.
This means that there are not USB interfaces with VendorId = 0x1D1B & ProductId = 0x1202.
You should probably walk thorough the system device interfaces, and see what they actually are. I can show you how to do that if you need.

Related

Add i2s Audio in device tree for SAM9x60 board

Our team has a SAM9x60 board and recently add an external audio board (UDA1334A, link: Documents). Unfortunately, this document has guide for Raspberry Pi only, and somehow it's really different with our board device tree. So I have tried myself to add into device tree, mostly based on SAM9x60's Tutorial with another board, but it's really different.
As I understand, the audio board use UDA1334 codec, and I have to add a sound tag to device tree, like SAM9x60 tutorial:
sound {
compatible = "mikroe,mikroe-proto";
model = "wm8731 # sam9x60ek";
i2s-controller = <&i2s>;
audio-codec = <&wm8731>;
dai-format = "i2s";
};
But I haven't found any driver for this card. After look around, I tried with simple-audio-card
sound {
compatible = "simple-audio-card";
simple-audio-card,name = "1334 Card";
simple-audio-card,format = "i2s";
simple-audio-card,widgets = "Speaker", "Speakers";
simple-audio-card,routing = "Speakers", "Speaker";
simple-audio-card,bitclock-master = <&codec_dai>;
simple-audio-card,frame-master = <&codec_dai>;
simple-audio-card,cpu {
#sound-dai-cells = <0>;
sound-dai = <&i2s>;
};
codec_dai: simple-audio-card,codec {
#sound-dai-cells = <1>;
sound-dai = <&uda1334>;
};
};
uda1334: codec#1a {
compatible = "nxp,uda1334";
nxp,mute-gpios = <&pioA 8 GPIO_ACTIVE_LOW>;
nxp,deemph-gpios = <&pioC 3 GPIO_ACTIVE_LOW>;
status = "okay";
};
When booting, I received message:
OF: /sound/simple-audio-card,codec: could not get #sound-dai-cells for /codec#1a
asoc-simple-card sound: parse error -22
asoc-simple-card: probe of sound failed with error -22
So have I do the right way with simple-audio-card? Or any other way? In normal, ALSA recorded a classD sound card, but I think it is just a amplifier. Sorry because I'm an Android SW Developer and have to do the HW job from a quit people.
External Question: I have investigate on Raspberry device tree based on UDA1334 document, it's so different, as I understand, Rasp use HiFiberry Dac already, but how could it work with an external DAC like UDA1334? No external node in device tree I've seen? Look like they just open dtoverlay=hifiberry-dac, dtoverlay=i2s-mmap and it work.

Getting the icon for an audio device

In the Sound Control Panel in Windows, and in the Volume Mixer, all audio devices have a specific icon set.
Is it possible to get which icon is set for a device through the Windows API?
Sound Control Panel
Volume Mixer
As suggested by Simon Mourier in the comments above, there is a PKEY that can access that data.
You can follow along with most of this sample and just replace PKEY_Device_FriendlyNamewith PKEY_DeviceClass_IconPath.
In short, it's something like this:
// [...]
IMMDevice *pDevice; // the device you want to look up
HRESULT hr = S_OK;
IPropertyStore *pProps = NULL;
PROPVARIANT varName;
hr = pDevice->OpenPropertyStore(STGM_READ, &pProps);
EXIT_ON_ERROR(hr);
PropVariantInit(&varName);
hr = pProps->GetValue(PKEY_DeviceClass_IconPath, &varName);
EXIT_ON_ERROR(hr);
// [...]

Sending raw print commands to Zebra from Windows 10 IoT on RPi3

I am trying to setup a simple app where my Raspberry Pi 3 can send a raw print command to a Zebra printer over USB.
I have a working WPF c# app that will run on my desktop using the RawPrinterHelper class similar to: https://support.microsoft.com/en-us/kb/322091, but the winspool.Drv won't work on the Pi3 because of the ARM processor (from what I understand).
Seeing as Windows 10 IoT requires UWP apps, I am trying to re-write the app in UWP. I have the app working, but can't figure out how to send the raw commands over USB without the winspool.Drv from the RawPrinterHelper class.
I have also tried sending over Bluetooth as described here: Windows IoT - Zebra Bluetooth Printer
but can't seem to open a connection to my paired device as var devices = await DeviceInformation.FindAllAsync(RfcommDeviceService.GetDeviceSelector(RfcommServiceId.SerialPort)); doesn't return any devices. Here is my code:
private async void PrintAsync()
{
textBox.Text = "Searching for devices";
var devices = await DeviceInformation.FindAllAsync(RfcommDeviceService.GetDeviceSelector(RfcommServiceId.SerialPort));
if(devices.Count() == 0)
{
textBox.Text = "No devices found";
return;
}
textBox.Text = "Number of paired devices found: " + devices.Count();
var service = await RfcommDeviceService.FromIdAsync("DepotPrinter");
var socket = new StreamSocket();
await socket.ConnectAsync(service.ConnectionHostName, service.ConnectionServiceName);
var writer = new DataWriter(socket.OutputStream);
var command = "^XA"
+ "^FO20,175^A0N,40,25^FD" + "Yo." + "^FS"
+ "^FO20,250^A0N,40,25^FD" + "IT WORKED!" + "^FS"
+ "^XZ";
writer.WriteString(command);
await writer.StoreAsync();
}
I would be willing to run my app on mono and Raspbian if it can work.
Any help or direction would be appreciated!
Thanks in advance!
UPDATE: I am using the on-board bluetooth of the RP3 and not a dongle.

How to set speaker configuration programatically using Core Audio API on Mac OS X?

I have a 7.1 channel audio output device and a custom kext to drive that. My custom application needs to send 7.1 rear channel audio data to the device but the device receives only 2 channel audio data. I checked "Configure Speaker" option in "Audio MIDI setup" application and it's set to stereo. When I set it to "7.1 Rear Surround" everything works fine. In my final product, I don't want the user to have to do all of this manually. So, the question is - Is there any Core Audio API or any other means of doing this programatically?
Ok, after playing around with some Core Audio APIs, finally I could get this done.
Get the AudioDeviceID:
AudioDeviceID audioDevice = getMyAwesomeDeviceID();
Create an AudioObjectPropertyAddress:
AudioObjectPropertyAddress propertyAddress;
propertyAddress.mSelector = kAudioDevicePropertyPreferredChannelLayout;
propertyAddress.mScope = kAudioDevicePropertyScopeOutput;
propertyAddress.mElement = kAudioObjectPropertyElementMaster;
Query if the audio object has this property:
AudioObjectHasProperty(audioDevice, &propertyAddress)
Get the data size of this property and create AudioChannelLayout:
UInt32 propSize(0);
AudioObjectGetPropertyDataSize(audioDevice, &propertyAddress, 0, NULL, &propSize);
AudioChannelLayout* layout = (AudioChannelLayout*)malloc(propSize);
Configure your AudioChannelLayout structure (eg: stereo layout):
AudioChannelLabel labels[2] = {kAudioChannelLabel_Right, kAudioChannelLabel_Left};
layout->mNumberChannelDescriptions = 2;
for (UInt32 i = 2; i < layout->mNumberChannelDescriptions; i++) {
layout->mChannelDescriptions[i].mChannelLabel = labels[i];
layout->mChannelDescriptions[i].mChannelFlags = kAudioChannelFlags_AllOff;
}
Set the AudioObject property data:
AudioObjectSetPropertyData(audioDevice, &propertyAddress, 0, NULL, propSize, layout);

How to get wp7 ppi or physical screen size?

I'm creating (yet another) ruler app for wp7.
I know the res. is always 480x800, but devices have different screen sizes.
I tried searching around, but i couldn't find out how to get the ppi, so i can map the pixels to the physical dimension.
so how do i get the ppi of the current device, or the physical screen size ?
There is no way to retrieve the PPI on the device, you best shot would be to maintain a list of devices and their respective PPI. You can use this helper method to access device properties:
Using Microsoft.Phone.Info;
...
private static string GetDeviceProperty(string propertyName)
{
object propertyValue;
if (!DeviceExtendedProperties.TryGetValue(propertyName, out propertyValue))
return String.Empty;
return propertyValue as string ?? String.Empty;
}
Now the relevant properties would be:
string manufacturer = GetDeviceProperty("DeviceManufacturer");
string devicename = GetDeviceProperty("DeviceName");
Hope this helps! More information about DeviceExtendedProperties can be found on MSDN

Resources