-1

I use a GD4430 handheld scanner from the company Datalogic with the included OPOS driver. With the following code I manage to address the scanner. When I start the program, the scanner becomes active and you can scan. But I can not display the results in a TextBox.

Does anyone see where the error lies?

Visual Studio 2010 C#

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;

namespace TestRead
{
public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
    }

    private void Form1_Load(object sender, EventArgs e)
    {            
        axOPOSScanner1.BeginInit();
        axOPOSScanner1.Open("USBHHScanner"); 
        axOPOSScanner1.ClaimDevice(0);            
        axOPOSScanner1.DeviceEnabled = true;
        axOPOSScanner1.DataEventEnabled = true;
        axOPOSScanner1.PowerNotify = 1; //(OPOS_PN_ENABLED);
        axOPOSScanner1.DecodeData = true;
    }               

    void axOPOSScanner1_DataEvent(object sender, AxOposScanner_CCO._IOPOSScannerEvents_DataEventEvent e)        
    {                
        textBox1.Text = axOPOSScanner1.ScanDataLabel;
        textBox2.Text = axOPOSScanner1.ScanData.ToString();

        axOPOSScanner1.DataEventEnabled = true;                       
        axOPOSScanner1.DataEventEnabled = true;
    }

  }
}
JaDoLo
  • 111
  • 9
  • Have you debugged the code? What do you see in axOPOSScanner1 – Pieter Alberts Jul 24 '18 at 12:06
  • Thanks for the answer, yes I can not get any errors. The code will work fine. – JaDoLo Jul 24 '18 at 12:25
  • So exactly what is the problem - do you successfully read data? Have you put a breakpoint on the lines where you set the textbox text & checked what is in ScanDataLabel & ScanData? – PaulF Jul 24 '18 at 12:27
  • I have not set any breakpoints and I do not know if there is anything in it. I will test that. The scanner was tested in Datalogic's DualTest 1.14.159 tool and works without any errors. Simultaneously, data can be displayed in it. So at least the settings should be correct. The Example is similare with [this](http://nabadiganta.org/Downloads/Notices/Scanner_Tutorial.pdf) other here. Actually, I think it should work. – JaDoLo Jul 24 '18 at 13:05
  • If you haven't bothered to try debugging your code - so cannot answer the questions we are likely to ask - how can we help you. After two comments regarding debugging your code you could have at least tried doing that so you can answer our questions. – PaulF Jul 24 '18 at 13:13
  • `@PaulF`, Sorry, have only been working with C# for a few days :-) I have set the breakpoints and can not find any entries in `ScanDataLabel & ScanData` Can it be that the `Auto Data Event` still needs to be turned on? And if so, how? – JaDoLo Jul 24 '18 at 13:58
  • `@PaulF` thx for -, you deserve it. There are no stupid questions, only stupid answers!! The code runs smoothly now. – JaDoLo Jul 24 '18 at 16:08

1 Answers1

1

Was not the processing of AxOPOSScanner1.BeginInit() on the source originally in Form1.Designer.cs instead of here?
(I am assuming that the source file name is Form1.cs)

As below(in Form1.Designer.cs):

this.axOPOSScanner1 = new AxOposScanner_CCO.AxOPOSScanner();
((System.ComponentModel.ISupportInitialize)(this.axOPOSScanner1)).BeginInit();
this.SuspendLayout();

There is a possibility that the problem has occurred because you moved it to Form1.cs or calling BiginInit() on both Form1.Designer.cs and Form1.cs.

Or, the following processing does not exist in Form1.Designer.cs, or there is a possibility that the specified function name(axOPOSScanner1_DataEvent) is wrong.

this.axOPOSScanner1.DataEvent += new AxOposScanner_CCO._IOPOSScannerEvents_DataEventEventHandler(this.axOPOSScanner1_DataEvent);


In addition:

What you should do is to temporarily store the return value of all the methods, add a process to determine whether the method was executed normally, likewise It is to read the ResultCode property immediately after setting the property(possibly causing an error) and add processing to judge whether the property setting was done normally.

Also, although not related to DataEvent, PowerNotify setting must be done before DeviceEnabled = true.

kunif
  • 4,060
  • 2
  • 10
  • 30
  • The code runs smoothly, I have just tested it on another computer with Win7, there is suddenly everything runing !!! Anyways thanks for your help. – JaDoLo Jul 24 '18 at 16:02