如何从通过USB连接的扫描仪获取信号

我有一台KODAK i2600扫描仪通过SX Virtual Link连接到网络,该网络中的每台PC都模拟与扫描仪的usb连接。 我可以像这样轻松地找到模拟的usbs pid和vid: 设备管理器检测到扫描仪,就好像它是通过USB连接一样

或这个: 注册表编辑器还显示信息,因为它通过USB连接

我试图用LibUsbDotNet检测信号,但是用他们的例子它不起作用。 我试过这个例子:

public static UsbDevice MyUsbDevice; #region SET YOUR USB Vendor and Product ID! public static UsbDeviceFinder MyUsbFinder = new UsbDeviceFinder(int.Parse("040a", System.Globalization.NumberStyles.HexNumber), int.Parse("601d", System.Globalization.NumberStyles.HexNumber)); #endregion public static void Main(string[] args) { ErrorCode ec = ErrorCode.None; try { // Find and open the usb device. MyUsbDevice = UsbDevice.OpenUsbDevice(MyUsbFinder); // If the device is open and ready if (MyUsbDevice == null) throw new Exception("Device Not Found."); // If this is a "whole" usb device (libusb-win32, linux libusb-1.0) // it exposes an IUsbDevice interface. If not (WinUSB) the // 'wholeUsbDevice' variable will be null indicating this is // an interface of a device; it does not require or support // configuration and interface selection. IUsbDevice wholeUsbDevice = MyUsbDevice as IUsbDevice; if (!ReferenceEquals(wholeUsbDevice, null)) { // This is a "whole" USB device. Before it can be used, // the desired configuration and interface must be selected. // Select config #1 wholeUsbDevice.SetConfiguration(1); // Claim interface #0. wholeUsbDevice.ClaimInterface(0); } // open read endpoint 1. UsbEndpointReader reader = MyUsbDevice.OpenEndpointReader(ReadEndpointID.Ep01); byte[] readBuffer = new byte[1024]; while (ec == ErrorCode.None) { int bytesRead; // If the device hasn't sent data in the last 5 seconds, // a timeout error (ec = IoTimedOut) will occur. ec = reader.Read(readBuffer, 5000, out bytesRead); if (bytesRead == 0) throw new Exception(string.Format("{0}:No more bytes!", ec)); Console.WriteLine("{0} bytes read", bytesRead); // Write that output to the console. Console.Write(Encoding.Default.GetString(readBuffer, 0, bytesRead)); } Console.WriteLine("\r\nDone!\r\n"); } catch (Exception ex) { Console.WriteLine(); Console.WriteLine((ec != ErrorCode.None ? ec + ":" : String.Empty) + ex.Message); } finally { if (MyUsbDevice != null) { if (MyUsbDevice.IsOpen) { // If this is a "whole" usb device (libusb-win32, linux libusb-1.0) // it exposes an IUsbDevice interface. If not (WinUSB) the // 'wholeUsbDevice' variable will be null indicating this is // an interface of a device; it does not require or support // configuration and interface selection. IUsbDevice wholeUsbDevice = MyUsbDevice as IUsbDevice; if (!ReferenceEquals(wholeUsbDevice, null)) { // Release interface #0. wholeUsbDevice.ReleaseInterface(0); } MyUsbDevice.Close(); } MyUsbDevice = null; // Free usb resources UsbDevice.Exit(); } // Wait for user input.. Console.ReadKey(); } } 

在此示例中,当我尝试打开USB设备时,结果为null 。 因此,我尝试使用此示例检测来自任何USB设备的任何信号:

 public static IDeviceNotifier UsbDeviceNotifier = DeviceNotifier.OpenDeviceNotifier(); private static void Main(string[] args) { // Hook the device notifier event UsbDeviceNotifier.OnDeviceNotify += OnDeviceNotifyEvent; // Exit on and key pressed. Console.Clear(); Console.WriteLine(); Console.WriteLine("Waiting for system level device events.."); Console.Write("[Press any key to exit]"); while (!Console.KeyAvailable) Application.DoEvents(); UsbDeviceNotifier.Enabled = false; // Disable the device notifier // Unhook the device notifier event UsbDeviceNotifier.OnDeviceNotify -= OnDeviceNotifyEvent; } private static void OnDeviceNotifyEvent(object sender, DeviceNotifyEventArgs e) { // A Device system-level event has occured Console.SetCursorPosition(0,Console.CursorTop); Console.WriteLine(e.ToString()); // Dump the event info to output. Console.WriteLine(); Console.Write("[Press any key to exit]"); }` 

在这个例子中,我只能检测connectdisconnect信号。 所以我试图用LibUsbDotNet连接到USB键盘/鼠标端口,这也没有用。

似乎我severely不明白这里需要做些什么。

接下来,我甚至试图通过这个例子来检查某个USB设备是否完全连接起来: USB设备连接即使这样也行不通。

总结一下,我需要这样做:

  1. 连接到扫描仪所连接的USB端口(并侦听它通过该端口发送的信号)。
  2. 检测扫描按钮的信号: 按钮扫描纸张
  3. 当检测到来自2.的信号时,我向扫描仪发送信号,用我自己的配置用TWAIN或ISIS lib扫描。

我想你可以从供应商那里获得柯达完美页面SDK 。 Pinvoke供应商提供的电话。

查看链接http://www.kodak.com/eknec/PageQuerier.jhtml?pq-path=2714&pq-locale=en_US&_requestid=3863链接中的开发人员工具部分