Microsoft POS无法识别扫描仪

时间:2009-08-27 17:11:59

标签: c# barcode point-of-sale pos-for-.net

我有Metro Technologies的条形码扫描仪,我正在使用Microsoft POS 检测扫描仪的输入。它使用USB连接到我的系统 港口。但是POS没有识别扫描仪。

public Form1()
{
InitializeComponent();
explorer = new PosExplorer(this);
explorer.DeviceAddedEvent += new
DeviceChangedEventHandler(explorer_DeviceAddedEvent);
}


void explorer_DeviceAddedEvent(object sender, DeviceChangedEventArgs e)
{
if (e.Device.Type == "Scanner")
{
scanner = (Scanner)explorer.CreateInstance(e.Device);
scanner.Open();
scanner.Claim(1000);
scanner.DeviceEnabled = true;
scanner.DataEvent += new
DataEventHandler(activeScanner_DataEvent);
scanner.DataEventEnabled = true;
scanner.DecodeData = true;
}
}

void activeScanner_DataEvent(object sender, DataEventArgs e)
{
UpdateEventHistory("Data Event");
ASCIIEncoding encoder = new ASCIIEncoding();
try
{
// Display the ASCII encoded label text
txtbScanDataLabel.Text =
encoder.GetString(activeScanner.ScanDataLabel);
// Display the encoding type
txtbScanDataType.Text = activeScanner.ScanDataType.ToString();

// re-enable the data event for subsequent scans
activeScanner.DataEventEnabled = true;
}
catch (PosControlException)
{
// Log any errors
UpdateEventHistory("DataEvent Operation Failed");
}
}

4 个答案:

答案 0 :(得分:2)

从某些论坛以及POS SDK文档中:

您必须将其添加到目录中的xml文件中:

C:\Program Files\Common Files\microsoft shared\Point Of Service\Control Configurations\


<PointOfServiceConfig Version="1.0">
 <ServiceObject Type="Scanner" Name="Example scanner">
  <HardwareId From="HID\VID_04B4&amp;PID_0100&amp;REV_0001" To="HID\VID_04B4&amp;PID_0100&amp;REV_0001" />
 </ServiceObject>
</PointOfServiceConfig>

您必须检查设备的硬件ID并将其替换为<HardwareId>标记

这是即插即用配置。

答案 1 :(得分:0)

我不熟悉您正在使用的扫描仪,但在您通常希望确保扫描仪本身配置为正确的模式/设置等之前,我已经使用过所有这些。通常,这是通过执行手册中的配置序列来完成的,您将扫描编程设备的各种条形码。

如果没有别的,你可以排除硬件配置问题而不是你的代码。

explorer_DeviceAddedEvent有没有发射?

scanner在哪里  并且activeScanner已初始化?

[编辑]

检查扫描仪本身或随附的文档以获取硬件ID(HID),尝试在代码中添加以下行。

[HardwareId(@"this is where the HID goes")]

看看是否能让您更进一步......有关详细信息,请参阅here,您可以提供HID或在XML配置文件中添加该信息

答案 2 :(得分:0)

这是整个代码

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.PointOfService;
using System.Collections;

namespace MicrosoftPOSScannerSample
{
    public partial class Form1 : Form
    {
        private PosExplorer explorer;
        private Scanner scanner;

        public Form1()
        {
            InitializeComponent();
            explorer = new PosExplorer(this);
            explorer.DeviceAddedEvent += new DeviceChangedEventHandler(explorer_DeviceAddedEvent);
        }

        private void Form1_Load(object sender, EventArgs e)
        {
        }

        private void UpdateEventHistory(string newEvent)
        {
            txtbEventHistory.Text = newEvent + System.Environment.NewLine + txtbEventHistory.Text;
        }

        void explorer_DeviceAddedEvent(object sender, DeviceChangedEventArgs e)
        {
            if (e.Device.Type == "Scanner")
            {
                scanner = (Scanner)explorer.CreateInstance(e.Device);
                scanner.Open();
                scanner.Claim(1000);
                scanner.DeviceEnabled = true;
                scanner.DataEvent += new DataEventHandler(scanner_DataEvent);
                scanner.DataEventEnabled = true;
                scanner.DecodeData = true;
            }
        }

        void scanner_DataEvent(object sender, DataEventArgs e)
        {
            UpdateEventHistory("Data Event");
            ASCIIEncoding encoder = new ASCIIEncoding();
            try
            {
                // Display the ASCII encoded label text
                txtbScanDataLabel.Text = encoder.GetString(scanner.ScanDataLabel);
                // Display the encoding type
                txtbScanDataType.Text = scanner.ScanDataType.ToString();

                // re-enable the data event for subsequent scans
                scanner.DataEventEnabled = true;
            }
            catch (PosControlException)
            {
                // Log any errors
                UpdateEventHistory("DataEvent Operation Failed");
            }
        }

    }
}

答案 3 :(得分:-1)

我在这里找到了配置(Windows 7平台):

  

C:\ Documents and Settings \ All Users \ Application Data \ Microsoft \ Point of Service \ Configuration \ Configuration.xml