You need to enable JavaScript to run this app. 为何已接入的LS2208扫码枪未出现在PosExplorer.GetDevices()列表中
优惠活动
大模型
产品
解决方案
定价
更多

为何已接入的LS2208扫码枪未出现在PosExplorer.GetDevices()列表中

LS2208扫码枪接入异常记录

已完成的配置验证

  • 已将LS2208扫码枪通过USB接入电脑,对照手册扫描对应配置条码切换工作模式
  • 已验证的可正常工作的模式:
    • USB HID Keyboard
    • OPOS (IBM Hand-held with Full Disable)
      以上两种模式下,扫码枪可正常将条码内容输入到文本文档
  • 扫码枪支持的全量配置模式列表:
    • USB HID Keyboard
    • IMB Table Top USB
    • IBM Hand-Held USB
    • OPOS (IBM Hand-held with Full Disable)
    • Simple COM Port Emulation

异常1:POS框架无法枚举到实体扫码枪

枚举扫描设备的代码逻辑:

explorer = new PosExplorer();
scannerList = new ArrayList(explorer.GetDevices("Scanner"));

代码执行后返回的设备列表存在固定特征:即便未接入任何外接扫码硬件,列表也始终仅存在两款虚拟扫码设备,无实体设备枚举记录:

// 第一款虚拟设备
Service Object Name: Microsoft Scanner Simulator
Description: Simulated service object for scanner
Manufacturer: Microsoft Corporation
Type: Scanner
Service Object Version: 1.14.1.0
UPOS Version: 1.14
Compatibility: CompatibilityLevel1
Hardware Description: 
Hardware Id: 
Hardware Path: 
Default: False
// 第二款虚拟设备
Service Object Name: Example Scanner
Logical Names: 
Description: Service object for Example scanner
Manufacturer: Microsoft Corporation
Type: Scanner
Service Object Version: 1.14.1.0
UPOS Version: 1.14
Compatibility: CompatibilityLevel1
Hardware Description: 
Hardware Id: 
Hardware Path: 
Default: False

尝试连接上述任意一款虚拟设备时,会抛出异常:

调用Open()方法前,必须由服务对象定义DevicePath属性的值

异常2:COM口模拟模式未生成对应系统串口

原本预期Simple COM Port Emulation模式会将扫码枪模拟为标准系统串口输入设备,但切换到该模式后,系统串口列表中未出现对应设备。
枚举系统串口的代码逻辑:

System.IO.Ports.SerialPort.GetPortNames();

内容的提问来源于stack exchange,提问作者KalAnd

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.12.06 05:45:02