Home > Net >  Honeywell OH3503 scanning gun usbhid no focus for scanning
Honeywell OH3503 scanning gun usbhid no focus for scanning

Time:01-12

The scanning gun using a wireless receiver is a little thing like a wireless network card, see is hid input in equipment management,
Now want to pick up on the software, no input box, scan was obtained from the background, the content of the Internet to download a lot of examples, all not line, are connected, only scan trigger events,
Scanning gun in front of the development to what set to receive the content (normal focal point in the text is available)? Now haven't got a clue, huo's official technical telephone 1 hangs, no resistance to
The following is the key code
Public HID_RETURN OpenDevice (UInt16 vID, UInt16 pID, string serial)
{
If (deviceOpened==false)
{
//to obtain a list of connected HID
List DeviceList=new List (a);
GetHidDeviceList (ref deviceList);
If (deviceList. Count==0)
Return HID_RETURN. NO_DEVICE_CONECTED;
for (int i=0; I & lt; DeviceList. Count; I++)
{
IntPtr device=CreateFile (deviceList [I],
DESIREDACCESS. GENERIC_READ | DESIREDACCESS GENERIC_WRITE,
0,
0,
CREATIONDISPOSITION OPEN_EXISTING,
FLAGSANDATTRIBUTES FILE_FLAG_OVERLAPPED,
0);
If (device!=INVALID_HANDLE_VALUE)
{
HIDD_ATTRIBUTES attributes;
IntPtr serialBuff=Marshal. AllocHGlobal (512);
HidD_GetAttributes (device, out attributes);
HidD_GetSerialNumberString (device, serialBuff, 512);
String deviceStr=Marshal. PtrToStringAuto (serialBuff);
Marshal. FreeHGlobal (serialBuff);
If (the attributes. The VendorID==vID & amp; & The attributes. The ProductID==pID & amp; & DeviceStr. The Contains (serial))
{
IntPtr preparseData;
HIDP_CAPS caps.
HidD_GetPreparsedData (device, out preparseData);
HidP_GetCaps (preparseData out caps);
HidD_FreePreparsedData (preparseData);
OutputReportLength=caps. OutputReportByteLength;
InputReportLength=caps. InputReportByteLength;

HidDevice=new FileStream (new SafeFileHandle (device, false), FileAccess. ReadWrite, inputReportLength, true);
DeviceOpened=true;
BeginAsyncRead ();

HHubDevice=device;
Return HID_RETURN. SUCCESS;
}
}
}
Return HID_RETURN. DEVICE_NOT_FIND;
}
The else
Return HID_RETURN. DEVICE_OPENED;
}

///& lt; summary>
///a asynchronous read
///& lt;/summary>
Private void BeginAsyncRead ()
{
Byte [] inputBuff=new byte [InputReportLength];
HidDevice. BeginRead (inputBuff, 0, InputReportLength, new AsyncCallback (ReadCompleted), inputBuff);
}

No fire again into the reflection for the first time, scan, please give directions

CodePudding user response:

Previously done a lot of honeywell's products, the website has the code examples, there are various types of gun use, next example look at society

CodePudding user response:

AsyncCallback this kind of writing, you need to write a similar "tail recursion" approach, to sustainable read on,
Directly, of course, my personal advice to use the others written
https://github.com/mikeobrien/HidLibrary/tree/master/examples/Honeywell4000Series
  •  Tags:  
  • C#
  • Related