Microsoft POS 无法识别扫描仪

发布于 2024-08-02 22:27:14 字数 1201 浏览 15 评论 0原文

我有 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");
}
}

I have a barcode scanner from Metro Technologies and I am using Microsoft POS
to detect the input from the scanner. It is connected to my system using USB
port. But the scanner is not getting identified by the 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");
}
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

信仰 2024-08-09 22:27:14

来自一些论坛以及 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&PID_0100&REV_0001" To="HID\VID_04B4&PID_0100&REV_0001" />
 </ServiceObject>
</PointOfServiceConfig>

您必须检查设备的硬件 ID 并将其替换为 标签

这是即插即用配置。

From some forums and also in POS SDK documentation:

You have to add this in an xml file in the directory:

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&PID_0100&REV_0001" To="HID\VID_04B4&PID_0100&REV_0001" />
 </ServiceObject>
</PointOfServiceConfig>

You have to check the Hardware Id of your device and replace it inside the <HardwareId> tag

This is plug and play configuration.

碍人泪离人颜 2024-08-09 22:27:14

这是完整的代码

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");
            }
        }

    }
}

Here is the entire code

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");
            }
        }

    }
}
还在原地等你 2024-08-09 22:27:14

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

如果没有其他问题,您可以排除硬件配置问题而不是代码问题。

explorer_DeviceAddedEvent 是否会触发?

扫描仪在哪里
activeScanner 已初始化?

[编辑]

检查扫描仪本身或附带的文档中的硬件 ID (HID),尝试将以下行添加到您的代码中。

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

看看这是否能让您进一步...请参阅此处< /a> 有关详细信息,您可以提供 HID 或将该信息添加到 XML 配置文件中

I'm not familiar with the scanner you are using, but with all that I've worked with before you generally want to make sure that the scanner itself is configured for the correct mode/settings/etc. Usually this is done by going through a configuration sequence that's in the manual where you'll scan various barcodes that program the device.

If nothing else you can rule out an issue with the hardware config as opposed to your code.

Does the explorer_DeviceAddedEvent ever fire?

Where are scanner
and activeScanner initialized?

[EDIT]

Check the scanner itself or the docs that came with it for a Hardware ID (HID), try adding the following line to your code.

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

See if that gets you any further...see here for more info, you can provide the HID or add that info in an XML config file

り繁华旳梦境 2024-08-09 22:27:14

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

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

I found the configuration here (Windows 7 platform):

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文