Read internal counters of USB scanning device - c#

I am trying to programmatically access internal device counters of a document scanning device that is connected via USB to my computer. I am NOT interested in the data that a scanner normally outputs (content of scanned pages, etc)! Instead, I would like to know how many pages were scanned so far. Does anyone have a clue on how to access such data? SNMP is usually the way to go for such device counters, but not with USB devices (at least I am not aware of how to do it).
OS is Windows 7, programming language is C#, and the scanning device is a Canon DR-M160 (hopefully this shouldn't matter, as I try to create a vendor-independend solution).

Related

Power cycling a USB device?

I'm working on troubleshooting a device that only works once it has been unplugged and plugged back into its USB port on the PC.
The application that talks to the device is written in C#. So I need a programmatic way in C# or perhaps batch files, etc. to reset a USB device.
Thus far I've tried using the devcon.exe tool, but that doesn't seem to do the same job that physically removing and adding it back does.
Is it possible to use Win32_USBController to control a USB device's power through the port somehow? MSDN Link
Perhaps in a similar fashion, I found the CIM_Controller class, which has Reset() function. MSDN Link
The tools for resetting a USB port in the Windows Driver Framework/Kit don't appear to be readily accessible via a library or otherwise without first creating an actual driver unless I'm mistaken.
Thanks
I would recommend that you navigate to the directory and find the device. Right click on it and in the short cut menu click on eject. The application and the OS should handle the device. It is a bad idea to "unplug" a USB device, especially flash drives without ejecting them. You could end up with open file errors.
If the problem is not ejecting the device then the issue is probably with the application. If the application is opening a file on the device and the device has to be unplugged in order to function properly then the application may not be closing the open file properly...
Just saying
You might look at the SO link: How to programmatically unplug & replug an arbitrary USB device?
and read through that...
it sounds to me like your scanner is completing a task then shutting it's post down. it remains plugged into the PC but the PC does not 'see' it. go to the directory and see if it is still in the directory...
unplugging once the device shuts down the port does nothing. replugging reconnects the electronics and the PC becomes aware of the device which completes one more task. then shuts down its port again.
Dr t

Audio stream from phone to pc via serial port in C#

I'm looking for a way to stream audio from a phone directly to the pc. I'm not talking about music or something but every sound of the phone (voice, ringing etc). Is this possible over an USB cable and the Serial Port of the PC without using third party tools or libraries? I'm currently developing in C#.
No! Do not connect your phone line to the microphone port. The high voltage on the line (60-120V when ringing) may damage your PC.
What you need is a PHONE-to-LINE in adaptor (or sometimes PHONE-TO-MIC adapter) found in electronic stores. Here is an example from AMAZON:
http://www.amazon.com/TRX-20-Direct-Connect-Telephone-ADAPTER/dp/B000KL0XA6/ref=sr_1_1?ie=UTF8&qid=1459033666&sr=8-1&keywords=phone+recording+device (I have no ties or experience with this particular one).
Then, your plug it in to your PC's LINE-IN or MIC (see instructions of the device). From this point on you should be able to record the audio from a call using any sound recording application.
Please keep in mind that PHONE recording may be illegal in some states, if the parties involved are not informed.
If your objective is to detect if a telephone number exists, your method may be intrusive, since it will attempt a call.
In any case, a voice modem could be a better choice, assuming you can find one. Windows used to have a voice modem API & Stack, which should enable you to dial a phone number, wait for the answer or no answer, and then, capture the audio from the remote end. Under most conditions it should detect the ring, busy, or number not available.
The open source project Asterisk (asterisk.org) has "heavy duty machinery" to do this job, albeit it requires specialised programming. There is even an answering machine detection: Asterisk Answering machine detection (AMD) always detects receiver as MACHINE

Is it possible to have our windows Handheld application as a USB receiver?

apologies if the question is quite basic, I am inexperienced in USB programming and I might be missing some conceptual detail here.
For our industrial solution we are supposed to provide communication between our PC wpf application and windows embedded HH 8.1 application. Ideally we would like this to be over USB.
I see a lot of sample code to connect directly to USB devices from host role.
However in our case the Windows Embedded HH device (Panasonic FZ-E1) will have the device role listening. I could not find any way to register to raw data sent from our PC application via USB events. I examined UMDF (user mode driver framework) which has examples about writing drivers for usb devices, yet it seems like it is for device manufacturers and us not being the manufacturer for Panasonic HH we should not/cannot use our own driver and we have to use the WinUSB driver it already has in place.
Windows Embedded 8.1 HH has some USB apis unlike windows phone, yet all the functionality provided in the API seems like connecting to external USB devices with the host role. When we use USBlyzer I see that there is some USB traffic towards the device from the PC so it looks it should be possible for the HH to have the listening device role. What am I missing here, any ideas?
Any help/direction is greatly appreciated.
P.S: I also tried windows connectivity api examining the source code of windows phone power tools yet it seems like the the dlls for addon packages here to handle transfer via agents is not there for newer versions of windows phone anymore.

c# communicating with an usb port

I'm trying to contact an usb barcode scanner as a serial port, using his virtual COM port name and the Serial Port class.
The reason I'm trying to do it this way is to avoid using the scanner as a keyboard wedge since I need the possibility to scan even when the form is hidden.
Problem is that when I connect the barcode scanner to the usb port, and I run the "GetPortNames" function, I get an empty list. Any suggestions why? Thanks
Typically many USB barcode scanners will just appear as virtual keyboard devices - not virtual COM ports. That would explain why it doesn't appear.
Does your scanner support some kind of serial emulation mode? You may need to configure it or install different drivers to enable this. Does it appear as a serial port in Device Manager? (Look under the Ports tree)
As an aside:
Take a look at this question if you find that the 'keyboard mode' is the only one supported:
Reading a barcode using a USB barcode scanner along with ignoring keyboard data input while scanner product id and vendor id are not known
This question refers to this article with a large amount of good information relating to keyboard hooks and filtering out the scanned barcodes:
http://nicholas.piasecki.name/blog/2009/02/distinguishing-barcode-scanners-from-the-keyboard-in-winforms/
I cannot guarantee that it will work with your specific device, but I've seen code that solved a similar problem once. The solution was looking for the port name in the registry.
The code for it can be found in the open source project ez430chronosnet; a .NET library that can access TI's EZ430 Chronos watch via its USB dongle.
You'll want to look at the PortName.cs file that looks for the name in the registry (it will at least point you to the right keys) and the Chronos.cs file that does the actual port opening with SerialPort.

How to detect USB Wifi plug into computer via C#?

I want to write a simple program that detect USB Wifi plugged computer and unplug it. I am finding code or library help me to do that (C# or Delphi). Tell me if you know :)
Or
Code or lib that list all USB devices on computer ?
Thanks !
I can only answer part of the question. You can "eject" USB devices using this API:
CM_Request_Device_Eject (MSDN link)
I'm using it to eject USB thumb drives after I copy stuff onto them in a backup application. I'm pretty sure there are ways of enumerating available USB devices using one of the many CM_XXX routines, but I was only interested in storage devices connected via USB, so I can't comment on WiFi devices.
An other sugestion: Maybe you can solve your problem at an other layer, maybe you can detect the addition of a new network adapter and disable that. Not all USB devices can be ejected, it's probably a driver-related issue. But I guess, if you can eject it from the notification area icon, you can eject it from code.
may have a look at http://sourceforge.net/projects/libusbdotnet/ (never used it by myself)

Categories

Resources