POS for .NET - Scanner - What could cause some QR code to not trigger DataEvent while other does?

699 views Asked by At

We successfully run an App using POS for .NET for about a year now. This App basicaly read QRCode on network device to get MAC address. But recently we had a weird issue: some particular QRCode were not received by our App.

We did run our code using Step by Step Debugger and Breaking point. Most of QRcode are working properly but some others are not working at all.
I mean the Scanner.DataEvent is not fired for specific QRCode. We did also check with the OPOS tool provided by the scanner manufacturer (DualTest from Datalogic) and all data are well received.

2 sample of QRCode
F09FC2F09402-q2zZ2n is working in all case
18E8299096EC-qHERPC does not work with POS for .Net but is working fine with other OPOS tool.

QRCode Samples

To give more context here below a simplified version of our source code using POS for .Net 1.4.1:

public class CodeScanner 
{
    public event Action<String> DataReceived;
    private Microsoft.PointOfService.Scanner _scanner;

    public Boolean Connect() 
    {
       Microsoft.PointOfService.PosExplorer posExplorer = new Microsoft.PointOfService.PosExplorer(); //null reference if POS .net is not installed
       Microsoft.PointOfService.DeviceInfo device = null;
       foreach (Microsoft.PointOfService.DeviceInfo d in posExplorer.GetDevices(DeviceType.Scanner))
       {
           if (d.ServiceObjectName == "RS232Imager")
           {
                device = d;
           }
       }

       _scanner = (Microsoft.PointOfService.Scanner)posExplorer.CreateInstance(device);
       _scanner.Open();
       _scanner.Claim(1000);
       _scanner.DataEvent += Scanner_DataEvent;
       _scanner.DeviceEnabled = true;
       _scanner.DataEventEnabled = true;
       _scanner.DecodeData = true;

       return true;
    }

    private void Scanner_DataEvent(Object sender, DataEventArgs e)
    {
        String data = System.Text.Encoding.UTF8.GetString(_scanner.ScanData);
        Task.Run(() => DataReceived?.Invoke(data));
        _scanner.DataEventEnabled = true;
        _scanner.ClearInput();
    }
}
1

There are 1 answers

0
Guillaume Raymond On

Finally I ditched Pos for .Net by using the scanner as keyboard input and refactor my code accordingly.