Differentiating between identical USB scanners in TWAIN - c#

I am trying to use multiple identical USB flatbed scanners for a C# project using a .Net TWAIN library. The problem with the TWAIN drivers is they are not set up to handle multiple instances of identical USB devices, in this case two Epson V37 scanners. The two scanners show up in device manager as separate but only the first scanner being plugged in shows up in TWAIN. This is not the case when two distinct scanner models are attached. My question is; is there a way i can change the drivers/registry entries enough to make it look like different scanners to TWAIN

Related

How to communicate with DJ Controller (USB hardware)

I have a DJ controller which connects to the computer via USB. It consists of a number of buttons, rotary dials (that look like potentiometers), crossfader and of course a turntable for scratching.
This controller is able to be used in popular DJ programs and works fine.
In the DJ program I am able to map the different buttons and controls on the device to software functions in the DJ program. When mapping, the names of the buttons show up in the DJ program (names such as "FX1" - not simply mapped to keyboard buttons).
I would like to create an application which is able to take input from the USB DJ controller. No fancy audio processing or anything like that, all I want to do is be able to:
Get a list of the buttons and controls available from the device
Get values from these controls instead of from the keyboard
Because the buttons, sliders etc show up in the DJ controller as named controls, this leads me to believe that this information is accessible, perhaps in a similar way to how joysticks work (though I have not actually worked with joysticks in .NET).
How does one go about communicating with such a USB device generally speaking and in particular in C#?
This all depends on what the manufacturer of the controller has made available to you, and how the device enumerates.
Assuming the device is a generic bulk device (requires a third party driver) you could potentially install your own WinUSB driver on the VID/PID for that device. Then you can interface with the device through the WinUSB API. The problem here is that you will need to know the protocol for the device - it's possible that you can get this from the manufacturer, if they are willing to let it go. The other alternative here is to sniff the bus during normal operation (using a hardware analyzer such as an Ellisys).
If the device is enumerating as an HID device then it must conform to some HID standard (such as a Mouse, Keyboard, or maybe a MIDI controller). In this case the specification would be defined already and available outside of the manufacturer. In this case you could use hidapi to open and utilize the device, the same way your DJ application would.

Scanner driver conflicts with 2 same scanners

I have this C#, WIA app that I made to control 1+ scanners. Its on Win7
I start a new instance of the app each time I want to control another scanner. This works fine with 2 different scanners, HP and Epson, but when I add another Epson and try to scan with it, it fails. I believe this is due to the drivers being locked by the first Epson scanner. How do I tell the second Epson scanner to use a different set of drivers? My thoughts are to copy the first scanners drivers to another location. Then search the registry for the first set of driver files. Then see if I can puzzle out individual scanners. I know that there is a unique ID property for the scanners. Then i would tell the second scanner's ID to use these drivers instead.
I have thought about using a Virtual Machine but don’t want to do that.

Audio capturing in C#

I have a MAYA 44 USB sound card and would like to interface it with C#. I want to record from the provided microphones and produce a data array.
I have found examples when using the internal sound card from my laptop but when it comes to external it does not quite work.
Has anyone every connected the above sound card with C# please?
Have you had a look at the DirectSound API (Windows only though, I think). Might provide what you're after.
On how to record audio with C# in general there are already multiple threads on SO, so I won't talk about that.
I see two possible causes for your program which have different solutions:
You need to change which audio sources are muted in the windows volume control ("sndvol32.exe /R")
When opening the audio device there are multiple devices. And you're simply opening device 0 instead of enumerating them and perhaps choosing another one. The external sound-card might appear as a second device.

What determines the order for sound devices in windows when using winmm.dll?

I am trying to use NAudio to create a multiple sound output application. We have 8 USB sound cards installed. NAudio lets me use all 8 but I can't figure out a pattern for determining which device index is which card.
The cards will be hooked up to different hardware so it is important to make sure you know which card you are using.
I have been trying to use WMI to poll for the information but I can't seem to locate any information that determines the order of the sound devices.
Update:
I forgot to include some information about this problem. The sound cards are all USB sound cards hooked up through a 12 port hub.
The order of devices is non deterministic for all versions of Windows. For Vista and above, the devices are typically ordered by the DSound GUID (more-or-less) so they're effectively random.
I'm assuming you are using WaveOut? You can call WaveOut.GetCapabilities(deviceNumber) to get hold of the name of the device, which might help you out.
This is what I have come up with so far and it works for us.
Using WMI you can get the DeviceID from Win32_SoundDevice. Then using that you can access the registery at HKLM\SYSTEM\CurrentControlSet\ENUM\'DeviceID' and get the string value named "Driver". This value contains the ClassGUID plus a number at the end.
Example: {4d36e96c-e325-11ce-bfc1-08002be10318}\0015
If you strip off that last number*(15)* for all of you sound devices and order them, that is the order that the devices are listed from NAudio with uses winmm.dll. There is also a location for these sound devices, either in the registery at the same key or from Win32_PNPEntity using the DeviceID.
In our case the location lets us determine which port of the USB hub that sound device is plugged into.
Have a look at this MSDN article. It uses DirectSound to enumerate the audio devices:
http://msdn.microsoft.com/en-us/library/bb318674(VS.85).aspx

Need a Switch component controlled via USB port

I need device switch component which an be controlled by code(.net,C# Or vb) ON/OFF state is enough..
I have code knowledge in C#, .net window application, I need to make a switch that can be controlled using code via USB port ... so that using that switch I will turn on/off electrical devices (fan,light) for a specific time interval.. For my MINI Project
Note: I need the brief note regarding components needed and how to assemble it.
If you know any link which resembles this type of project pls refer me.
thanks.
You'll probably want to look into using an FTDI chip for this purpose. They do have a .NET interface available as well as traditional C DLLs.
FTDI offers two types of drivers - one emulates a simple COM port (Virtual COM Port, which is probably enough for you), and the other is more of a direct USB control (D2XX), although it still shows up as a COM port when the USB device is connected.
On the other hand, if you really only need on/off support, you could probably just use the .net serial port drivers for the most basic communication. Of course, the serial port drivers don't let you tie a serial port pin high or low, so you will need some method of reading the data coming from the PC. Many microcontrollers have freely available UART libraries exactly for this purpose, but you will need to also obtain an RS232 level shifting IC for this because the serial port from the PC outputs +/- 6V IIRC (might be +/- 12V), while most microcontrollers run off of and accept signals at 0/5V or 0/3.3V.
You could try something like the Arduino or one of its clones like the Sanguino. It's probably a bit overkill for your project, but they come pre-assembled and have a large support base.
You would also (for any low voltage switching circuit) need some form of relay board to switch electrical appliances that run on mains power. See here for some ideas.
Are you sure you have to do this with the USB port?
You'd need a device that implements a whole USB interface. This isn't as simple as using a line on the COM port (RTS/DSR etc...) or using the parallel port.
A quick search found this...

Categories

Resources