CoreScanner(摩托罗拉)事件未触发C# [英] CoreScanner (Motorola) Events not being triggered C#

查看:1177
本文介绍了CoreScanner(摩托罗拉)事件未触发C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在尝试一个简单的Windows窗体应用程序,其中用户扫描条形码,那么应用程序解码条形码,然后插入一个一行到数据库中。一个基本的轨道的应用程序。我拿起摩托罗拉扫描仪和下载的Windows开发SDK。我看了,虽然附录A编写简单的应用程序中使用扫描仪SDK API似乎是一个很好的地方开发人员指南(的 http://support.symbol.com/support/search.do?cmd= displayKC&安培; DOCTYPE = KC&安培;外部ID = 14978402apdf&安培; sliceId =安培; dialogID = 311240750&安培; STATEID = 1%200%20311224446 )。我得到的5控制台实例工作正常,但我不能让Windows窗体应用程序工作,OnBarcode事件永远不会触发。我跟着这个视频( http://www.youtube.com/watch?v= GfIWWUw4YSc& T公司= 15m47s )摩托罗拉一步一步来。

I am attempting to a simple windows form application, where the users scans a barcode then the application decodes the barcode, then inserts an row into a database. A basic track application. I picked up a Motorola scanner and downloaded the SDK for windows development. I read though "APPENDIX A WRITE SIMPLE APPLICATIONS USING THE SCANNER SDK API" seemed like a good place to start in the Developers guide (http://support.symbol.com/support/search.do?cmd=displayKC&docType=kc&externalId=14978402apdf&sliceId=&dialogID=311240750&stateId=1%200%20311224446). I get the 5 console examples working fine but I can't get the windows form application to work, the OnBarcode Event is never triggered. I followed this video(http://www.youtube.com/watch?v=GfIWWUw4YSc&t=15m47s) by Motorola step by step.

我似乎有类似的问题,以这样的:的摩托罗拉条码扫描仪SDK事件C#但我使用USB连接。

I seem to be having a similar problem to this: Motorola barcode scanner SDK events C# but I am using a USB connection.

我意识到,示例代码是写好的原创在.NET 2.0,所以我试图重新编译项目,它仍然没有'的工作。然后我试图改变CCoreScannerClass到CCoreScanner使嵌入式系统互操作类型的工作,但认为没有帮助。下面是示例代码:

I realized that the sample code was original written in .net 2.0 so I tried recompiling the project and it still didn't' work. I then tried changing CCoreScannerClass to CCoreScanner so that Embeded Interop Types would work but that didn't help either. Here is the sample code:

using CoreScanner;

namespace Scanner_WindowsFormsApplication
{
public partial class Form1 : Form
{
    CCoreScanner cCoreScanner;
    public Form1()
    {
        InitializeComponent();
    }

    private void Form1_Load(object sender, EventArgs e)
    {

    }
    void OnBarcodeEvent(short eventType, ref string pscanData)
    {
        string barcode = pscanData;
        this.Invoke((MethodInvoker)delegate { textBox1.Text = barcode; });


    }
    private void button1_Click(object sender, EventArgs e)
    {
        try
        {
            //Instantiate CoreScanner Class
            cCoreScanner = new CCoreScanner();
            //Call Open API
            short[] scannerTypes = new short[1];//Scanner Types you are interested in
            scannerTypes[0] = 1; // 1 for all scanner types
            short numberOfScannerTypes = 1; // Size of the scannerTypes array
            int status; // Extended API return code
            cCoreScanner.Open(0, scannerTypes, numberOfScannerTypes, out status);
            // Subscribe for barcode events in cCoreScannerClass
            cCoreScanner.BarcodeEvent += new _ICoreScannerEvents_BarcodeEventEventHandler(OnBarcodeEvent);
            // Let's subscribe for events
            int opcode = 1001; // Method for Subscribe events
            string outXML; // XML Output
            string inXML = "<inArgs>" +
            "<cmdArgs>" +
            "<arg-int>1</arg-int>" + // Number of events you want to subscribe
            "<arg-int>1</arg-int>" + // Comma separated event IDs
            "</cmdArgs>" +
            "</inArgs>";
            cCoreScanner.ExecCommand(opcode, ref inXML, out outXML, out status);
            Console.WriteLine(outXML);
        }
        catch (Exception exp)
        {
            Console.WriteLine("Something wrong please check... " + exp.Message);
        }
    }
}



}

}

我通过开发人员指南阅读并发现这一点:BarcodeEvent
触发时,扫描仪捕获的条形码要接收BarcodeEvents,应用程序需要与SUBSCRIBE_BARCODE事件执行REGISTER_FOR_EVENTS方法类型。我是新的C#,所以我真的不知道这意味着什么,以及它如何适用于例如

I read through the Developer guide and found this: "BarcodeEvent Triggered when a scanner captures bar codes. To receive BarcodeEvents, an application needs to execute the REGISTER_FOR_EVENTS method with the SUBSCRIBE_BARCODE event type." I am new to c# so I don't really know what this means and how it applies to the example.

如果的 http://stackoverflow.com/users/68043/scott 读这个线程我很想知道你是怎么得到onBarcodeEvent在你的线程功能:的Dialog挂起从事件调用

If http://stackoverflow.com/users/68043/scott reads this thread I would love to know how you got the onBarcodeEvent to function in your thread: Dialog hangs when called from event

推荐答案

要获得摩托罗拉扫描仪SDK条码事件扫描仪应该是IBM手持USB或SNAPI。如果连接到串行端口应该在NIXDORF模式b。如果您的扫描仪连接HIDKB模式下,你无法通过SDK有条形码的事件,因为扫描仪的工作原理的键盘。我的建议是首先尝试示例应用程序的可执行文件自带的SDK,并检查您是否可以看到从提供的应用程序的事件。

To get a barcode event from Motorola Scanner SDK your scanner should be in IBM handheld USB or SNAPI. If it is connected to the serial port it should be in NIXDORF MODE B.If your scanner connected in HIDKB mode you can not have barcode events through SDK since scanner works as a keyboard. My advice is to first try the executable of the sample application comes with the SDK and check whether you can see the event from the provided application.

这篇关于CoreScanner(摩托罗拉)事件未触发C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆