Unable to enable a claimed device using POS for .Net - c#

I am using a Motorola DS4208 hand held barcode reader. In the past I was able to successfully setup and use this device, however recently it has stopped working. This may be the result of installing other devices that also use OPOS and POS for .Net interfaces.
This is a USB device so I created a Control Configuration file named *Moto_Scanner.xml* and placed it in the correct location.
<PointOfServiceConfig Version="1.0">
<ServiceObject Type="Scanner" Name="Example Scanner">
<HardwareId
From="HID\VID_05E0&PID_1300&REV_0100"
To="HID\VID_05E0&PID_1300&REV_0100" />
<HardwareId
From="HID\VID_05E0&PID_1300"
To="HID\VID_05E0&PID_1300" />
</ServiceObject>
</PointOfServiceConfig>
Using SOMgr.exe I can see the device in POSDevices with the proper path. I then created a LogicalName of MotoScan. It then appears in the Logical Names list as expected.
Using Microsoft Point Of Service\SDK\Samples\Sample Application\TestApp.exe I am able to open and claim the device. However, after attempting click the enable checkbox I get the following error message.
POSControlException ErrorCode(Failure) ExtendedErrorCode(0) occurred: Unable to enable the device. See inner exception for details.
System.ComponentModel.Win32Exception: The process cannot access the file because it is being used by another process
at Microsoft.PointOfService.ExampleServiceObjects.HidReader.HidThread.StartReading()
at Microsoft.PointOfService.ExampleServiceObjects.HidReader.OpenDevice()
at Microsoft.PointOfService.ExampleServiceObjects.ExampleScanner.set_DeviceEnabled(Boolean value)
Opened device: Example Scanner
Created instance of device: Example Scanner
Motorola provides an app called 123Scan to assist with configuration and testing. Using this app I can confirm the device works. This app was eventually uninstalled as part of troubleshooting.
Any suggestions will be appreciated.

Have you tried installing the OPOS driver?
EDIT:
Instead of re-linking this every time it expires, you should proactively search for "OPOS Driver" at http://support.symbol.com so that you can download the driver for the appropriate platform.

Through the learning process it became clear that opening and claiming a device does not mean it is actually connected. POS Explorer will allow you to open a connection and claim a device for exclusive use even if it not physically connected. This is partially because POS Explorer is using a Service Object to communicate with the hardware.
It is not until you enable a device, that you will have positive confirmation the device is available. In fact, if enable fails you have confirmation the device is not connected.
The Motorola DS4208 hand held scanner does not require a custom made configuration mapping file. After installing the Motorola ADK the correct Service Objects are installed and they have the Hardware Ids internally stored. In my previous code I attempted to use the "Example Scanner" Service Object available in the POS Explorer SDK to communicate with that hardware, that was my primary mistake.
After the OPOS Driver for Symbol Scanners v3.31 were installed I had not trouble testing the hardware.

Related

How to use UWP PointOfService API for SocketScan D700 in SPP mode

When I pair a SocketScan D700 via Bluetooth to a Windows 10 (1803/17134.286) desktop computer in SPP mode, then the barcode scanner is listed in "Other devices" in the settings menu "Bluetooth & other devices".
According to Terry Warwick this shouldn't prevent the Windows.Devices.PointofService.BarcodeScanner API to work with the scanner.
However, the sample UWP app is unable to claim the D700 barcode scanner once it's paired.
Also the API call below returns a null value
var x = await Windows.Devices.PointOfService.BarcodeScanner.GetDefaultAsync();
My question now, is how do I claim the D700 barcode scanner using the PointOfService API?
The SocketScan 10 desktop (binary) application from SocketScan does work and is able to 'claim' the scanner and function in keyboard wedge mode. Indicating that the scanner itself is working fine. (Of course I'm not running the socketscan software when testing the UWP sample app.)
In order to set the scanner to SPP mode I (1) first unpaired the scanner on both the PC and the scanner itself. (2) performed a factory reset of the scanner, and then (3) scanned the SPP mode barcode #FNB00F40000#, and then (4) simply paired it again with the computer. Subsequently the sample app is unable to claim the scanner.
I paired the scanner using the settings dialogs from win10:
#Jasper,
I am pretty sure the problem is that this 'version' of the D700 friendly name is not what Windows 10 POS is looking for, and I am guessing this scanner predates our addition of the Windows POS UUID we added to the SDP record.
So, your option is:
1) Change the friendly Name to what Windows 10 is looking for ("Socket CHS" I think but need to double check). The only way you can do this is to setup and run our SocketScan10 Keyboard wedge software (available on our web site). Then, using ScannerSettings, there is an option to change the friendly name.
Or 2) alternatively, I think I could generate a barcode for you to scan that will do it also. Send me your Serial Number so we can do it 'right'.
Regards,
Len - Socket Mobile
#Jasper,
Without using the Bluetooth Pairing APIs to actually connect the device you will need to connect the paired device within Settings then you should be able to discover and pair.
I would not suggest using GetDefault as there is no guarantee which device it will find each time it is run. Please review the documentation here on other discovery mechanisms to use. I would suggest starting with the Device Picker.
Terry Warwick, Microsoft
Just an update in case anyone is looking into a similar solutions:
The newer Socket Mobile devices, i.e., scanners made after mid 2018, or any S700, S740, are equipped with a feature called Auto Connect Capability (ACC mode, in which the scanner tries to connect to the host). This mode turned out to be in conflict with Microsoft POS APIs. If you are using Windows POS, make sure your scanner is set in the normal SPP mode (the SPP barcode for Android 7 or older version, if you want to find it in your scaner's user guide or on the paper insert that comes with the package) before pairing in Windows Settings.
Regards,
Long - Socket Mobile

Compact framework application gets deleted when the battery dies

I am developing an application in C# .Net 3.5 Compact framework for a Handheld Computer which runs on Microsoft Windows CE 6.0.
I am able to create the installer and run the application, the hurdle what I am facing right now is, say the battery dies/you perform a Cold Boot on the device (the device is Datalogic Memor X3 http://www.datalogic.com/eng/products/healthcare/mobile-computers/memor-x3-healthcare-pd-814.html#), the application gets deleted, the user will have to re-install the application. I would like to know how to get rid off this problem? Is there something I need to do while building the Setup/Installer? There are other applications in the device which do not get deleted when performed a Cold boot.
Please advise.
Usually, the root filesystem of a Windows CE devices is RAM-based, using the object store. Mass storage devices are mounted as subfolders. This means that any application that is not installed on a folder connected to a mass-storage device will disappear when RAM contents are erased. In your case this happens when the battery dies because the device never actually turns off, just suspends and resumes.
You should try to install your application on a permanent folder, they should show a different icon in file explorer.
Most if not all vendors of Windows CE based devices offer a persistent storage area and factory reset / autoinstall procedure.
If the device is clean/cold booted, the 'normal' storage area is reset to factory default. So all custom applications and changes are deleted. When the device boots up, there is a OEM specific autoinstall process. You need to integrate your setup with the autoinstall.
Please see the Datalogic Memor X3 support page and look at the user manual on how to persist your application with this Datalogic device (I would have done that for you, but they require a registration).
UPDATE: see https://www.manualslib.com/manual/850035/Datalogic-Memor-X3.html?page=64#manual and read about Save Session and Save Setup.
At least you can use a SD Card with a special folder (ie 2577 for devices with ARM processor) and a custom autorun.exe inside. This will be executed automatically on every boot.

Is there a way to detect whether Windows is installing a device driver?

The situation:
We have a software suite that interacts with a device we built in-house. The device uses WinUSB for communications, EXCEPT when in boot mode during firmware updates. When in boot mode, the device uses a different VendorID and ProductID and uses HID for communication.
The problem:
To update firmware, we send a command across and tell the device to enter boot mode. The device re-enumerates with the new VID and PID. When updating firmware on a new machine that hasn't had a device in boot mode connected before, Windows does the "installing driver" dance when the bootloader shows up. (There's no driver to be installed). Software gets a DEVICE ATTACHED event, and so we begin the firmware update. Once Windows finishes "installing" the driver, it de-enumerates and re-enumerates the device, closing our file handle in the middle of the update.
The question:
Is there a way to detect if Windows is installing a driver so that we can wait for the device to be re-enumerated before beginning the update process? Is there something we can do in our install to preempt this behavior? Maybe a way to tell Windows that we don't want to allow driver installation while we're connected to the device?
Maybe a way to tell Windows that we don't want to allow driver installation while we're connected to the device?
Microsoft's Developer Network has a section for Hardware Development. They have an article specifically about this issue. Importantly, the document states that your device installation application should "determine whether other installation activities are in progress before performing its installations" (emphasis mine) and - if pending installations are found - "should exit".
This last part of the statement seems to indicate Microsoft gives precedence to already installing or pending device application installations.
If your problem statement is accurate:
When updating firmware on a new machine that hasn't had a device in boot mode connected before, Windows does the "installing driver" dance when the bootloader shows up.
It sounds like you may be out of luck - or breaking a convention - by attempting to preempt the driver installation behavior.
I would utilize the above mentioned CMP_WaitNoPendingInstallEvents function, and then firmware update your device. I think the VID/PID are irrelevant, here, depending upon where your firmware update code is running. It looks like the OSR Online Forum has a question of the same nature and assumes the same precedence (driver installation).

GPS Windows Mobile 6 (using Microsoft.WindowsMobile.Samples.Location;)

well guys, i am part of one team. (I dont have the project yet, i am new).
They did a application using gps, problem is it fail sometimes...
why? they think gps fails because users has the device in "energy saving" mode; then the device hibernates
after 5 minutes if they dont use it.
GPS brings sometimes bad coordinates (for example coordinate shows users is on "SEA" or in "Japan". I repeat, My partners thinks problem is because device is in "energy saving" mode. how can i change this configuration with C# while application is running (maybe back old configuration when application has been closed).
I am using this library.
using Microsoft.WindowsMobile.Samples.Location;
I can't check if it works because now i dont have a device, and i my computer doesn't have GPS, do you have any idea for i can check the application?.
i am using
`"Windows Mobile 6.0 SDK"`
You can install networking functionality while using the Microsoft Device Emulator. This blog explains how to setup network functionality on Windows 7. Follow the official documentation if you're not using Windows 7.
You can emulate GPS functionality using the FakeGPS program supplied by Microsoft. If you want anything close to real data you'll need a text file containing raw NMEA to feed into FakeGPS. You can simply record bytes passed through the GPS COM port to a file to generate a NMEA file. If fake GPS doesn't like your file then remove the non-standard NMEA lines and try again.
You should do some research on Windows Mobile Power Management first to understand the problem. The quickest hack is to simply call SystemIdleTimerReset() more frequently than the battery idle timeout (use SystemParametersInfo() and SPI_GETBATTERYIDLETIMEOUT) to prevent the device from sleeping. This will decrease the battery life of the device! There are other more elegant solutions available such as using the Power Management API.

Connect and disconnect USB programmaticaly "WITHOUT UNPLUG AND REPLUG"

I need to connect and disconnect USB programmatically. That is, I have inserted the USB device. I need to transfer the file using C#, .NET application. The application will watch the particular folder and transfer the file from that folder to a USB drive. I need to disconnect the USB device after the file is transfered and connect the USB when needed - without unplug and replug.
What would be some code to do it or is there any DLL file available?
Main thing: NOTE, NOTE: Without unplugging and replugging the USB device.
If your goal is to make a certain disk volume unavailable while you're not using it, a more sensible approach might be to use the volume management APIs, e.g. by using the IOCTL_VOLUME_OFFLINE control code. (I'm assuming that you know which drive letter belongs to your USB disk.)
Alternatively, you can disable and enable the volume device programmatically with the CfgMgr / SetupAPI -- the same as right-clicking the volume in Device Manager and choosing Disable would do. (For information about using SetupAPI, please review the DevCon sample code provided with the Windows WDK, and see MSDN for functions such as SetupDiChangeState.)
The latter option might require a privileged user account.
I'm not exactly sure, but it can be done. In Linux, I've experienced certain situations where power is disconnected to a device programmatically. The kernel usually does this if the connected USB device is exhibiting too many errors. So, it should be possible to do this even in Windows. You may need to write your own external DLL to do it though.

Categories