Scanner is not recognized by Microsoft POS

I have a barcode scanner from Metro Technologies, and I use Microsoft POS to detect input from the scanner. It is connected to my system using a USB port. But the scanner is not recognized by 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");
}
}
+3
source share
4 answers

On some forums, as well as in the POS SDK documentation:

You should add this to the 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&amp;PID_0100&amp;REV_0001" To="HID\VID_04B4&amp;PID_0100&amp;REV_0001" />
 </ServiceObject>
</PointOfServiceConfig>

You need to check the hardware identifier of your device and replace it in the tag <HardwareId>

This is a plug and play configuration.

+2
source

, , , , , , //etc. , , -, .

, .

explorer_DeviceAddedEvent?

scanner   activeScanner ?

[EDIT]

, (HID), .

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

, ... . , HID XML

0

Here is the whole 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");
            }
        }

    }
}
0
source

I found the configuration here (Windows 7 platform):

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

-1
source

Source: https://habr.com/ru/post/1716237/


All Articles