我有以下代码使用 POS for .NET 查找 MSR 设备,并返回与我的设备名称匹配的实例。然后我打开并声明即使 MSR 设备未连接到计算机也成功找到的实例。这怎么可能?有没有办法在打开和认领之前知道设备是否真正连接?当设备未连接时,我在调用 Open() 或 Claim() 时没有收到异常或任何东西。非常感谢任何指导。
PosExplorer explorer = new PosExplorer();
var devices = explorer.GetDevices(DeviceType.Msr);
foreach (DeviceInfo deviceInfo in devices)
{
if (deviceInfo.ServiceObjectName.ToLower() == deviceName.ToLower())
{
PosDevice posDevice = explorer.CreateInstance(deviceInfo);
if (posDevice is PosCommon)
{
posCommon = posDevice as PosCommon;
_log.Debug(string.Format("Instance of device {0} created.", deviceName));
break;
}
}
}