已检测到JPos扫描程序但未从中接收数据

时间:2018-05-07 08:57:30

标签: java barcode-scanner javapos

我一直试图让JPos与我的客户的USB手持扫描仪一起运行。它可以很好地检测到扫描仪,但是当它们用它来读取卡时没有任何东西弹出。我一直在使用该库的示例源代码,以确保我可以在将其应用到我的主软件之前使用该设备。这是应该测试它的代码(实现jpos接口的javafx fxml控制器):

import javafx.application.Platform;
import javafx.fxml.FXML;
import javafx.scene.control.TextArea;
import jpos.JposException;
import jpos.events.DataEvent;
import jpos.events.DataListener;

public class UI_Controller implements DataListener{

private jpos.Scanner scanner = new jpos.Scanner();
private jpos.Scanner scanner2 = new jpos.Scanner();

@FXML
TextArea textbox;

@FXML
TextArea textbox2;

@FXML
public void buttonClick() {
        updateBox(textbox, "Initialising JavaPOS...\n");
        // Create scanner instance and register for data events.
        scanner = new jpos.Scanner();

        // Initialize the scanner.  Exception thrown if a method fails.
        try {
            updateBox(textbox, "Adding DataListener...\n");
            scanner.addDataListener(this);
            updateBox(textbox, "Opening the device DLS-QW2120-USB-OEM...\n");
            scanner.open("DLS-QW2120-USB-OEM");
            updateBox(textbox, "Claiming the device...\n");
            scanner.claim(1000);
            updateBox(textbox, "Enabling the device...\n");
            scanner.setDeviceEnabled(true);
            updateBox(textbox, "Setting 'DataEventEnabled' property...\n");
            scanner.setDataEventEnabled(true);
            updateBox(textbox, "---SUCCESS!---\n");
            updateBox(textbox, "[ LISTENING MODE ]");
        } catch (JposException ex) {
            updateBox(textbox, "=== JPOS EXCEPTION TRACE[1] ===: \n" + ex.toString());
            updateBox(textbox, "\n=== END OF EXCEPTION ===\n");
            updateBox(textbox, "\nClosing DLS-QW2120-USB-OEM\n");
            try {
                scanner.close();
            } catch (JposException e) {
                updateBox(textbox, "=== JPOS EXCEPTION TRACE[1] ===: \n" + e.toString());
                updateBox(textbox, "\n=== END OF EXCEPTION ===\n");
            }
            updateBox(textbox, "\nTrying DLS-QW2100-USB-OEM\n");
             try {
                updateBox(textbox, "Opening the device...\n");
                scanner.open("DLS-QW2100-USB-OEM");
                updateBox(textbox, "Claiming the device...\n");
                scanner.claim(1000);
                updateBox(textbox, "Adding DataListener...\n");
                scanner.addDataListener(this);
                updateBox(textbox, "Enabling the device...\n");
                scanner.setDeviceEnabled(true);
                updateBox(textbox, "Setting 'DataEventEnabled' property...\n");
                scanner.setDataEventEnabled(true);
                updateBox(textbox, "---SUCCESS!---\n");
                updateBox(textbox, "[ LISTENING MODE ]");
            } catch (JposException ex2) {
                updateBox(textbox, "=== JPOS EXCEPTION TRACE[1] ===: \n" + ex2.toString());
                updateBox(textbox, "\n=== END OF EXCEPTION ===\n");

            }
        }
        //...Success! Continue doing work...
}

@FXML
public void button2Click() {
    updateBox(textbox, "Initialising JavaPOS...\n");
    // Create scanner instance and register for data events.
    scanner2 = new jpos.Scanner();

    // Initialize the scanner.  Exception thrown if a method fails.
    try {
        scanner.close();
    } catch (JposException e) {
        updateBox(textbox, "=== JPOS EXCEPTION TRACE[1] ===: \n" + e.toString());
        updateBox(textbox, "\n=== END OF EXCEPTION ===\n");
    }
    updateBox(textbox, "\nTrying DLS-QW2100-USB-OEM\n");
    updateBox(textbox, "Adding DataListener...\n");
    scanner2.addDataListener(this);
     try {
        updateBox(textbox, "Opening the device...\n");
        scanner2.open("DLS-QW2100-USB-OEM");
        updateBox(textbox, "Claiming the device...\n");
        scanner2.claim(1000);
        updateBox(textbox, "Enabling the device...\n");
        scanner2.setDeviceEnabled(true);
        updateBox(textbox, "Setting 'DataEventEnabled' property...\n");
        scanner2.setDataEventEnabled(true);
        updateBox(textbox, "---SUCCESS!---\n");
        updateBox(textbox, "[ LISTENING MODE ]");
    } catch (JposException ex2) {
        updateBox(textbox, "=== JPOS EXCEPTION TRACE[1] ===: \n" + ex2.toString());
        updateBox(textbox, "\n=== END OF EXCEPTION ===\n");

    }
    //...Success! Continue doing work...

}


@Override
public void dataOccurred(DataEvent e) {
    jpos.Scanner sc = (jpos.Scanner) e.getSource();
    try {
        updateBox(textbox2, "[" + e.getStatus() + "] " + scanner.getScanData().toString() + "\n");
        sc.setDataEventEnabled(true);
    } catch (JposException ex){
        updateBox(textbox2, "=== JPOS EXCEPTION TRACE[2] ===: \n" + ex.toString());
        updateBox(textbox2, "\n=== END OF EXCEPTION ===\n");
    }

}

我跳过了updateBox()方法,因为它只更新特定的文本框并同时打印到stdout。

几点说明:

  • 我正在测试QW2100和QW2120扫描仪,因为第一个是 最初在.xml驱动程序中的那个,但第二个是那个 我的客户已经并且它是我手动在文件中添加的记录。
  • 我非常确定buttonClick()方法工作正常,因为我们之前甚至连接到设备时遇到问题(缺少.dlls)但现在 客户说扫描仪似乎连接起来,它只是被扫描的 扫描卡时不会显示数字
  • 我宁愿准备一个尽可能多的解决方案的例子,因为我自己没有扫描仪,必须依靠 客户为我运行测试应用程序
  • Textbox2更新很好,我已经检查过了,并且它不是updateBox()代码的问题

这是我收到的屏幕截图(在我介绍button2Click之前它来自旧版本,但两者的行为方式相同):Screenshot 这一定是我试图接收数据的方式(扫描仪可以正常使用他们目前正在使用的其他软件),但查看文档等等。我不知道哪些可能是错的,因为我和#39;我试图做到最低限度。

XML记录的完整性(2120是我添加的):

 <JposEntry logicalName="DLS-QW2100-USB-OEM">
        <creation factoryClass="com.dls.jpos.service.DLSScannerInstanceFactory" serviceClass="com.dls.jpos.service.DLSScannerService"/>
        <vendor name="DLA" url="http://www.adc.datalogic.com"/>
        <jpos category="Scanner" version="1.13"/>
        <product description="ScannerService" name="ScannerService" url="http://www.adc.datalogic.com"/>
        <!--Other non JavaPOS required property (mostly vendor properties and bus specific properties i.e. RS232 )-->
        <prop name="beepDuration" type="String" value="1"/>
        <prop name="beepFrequency" type="String" value="2"/>
        <prop name="beepVolume" type="String" value="2"/>
        <prop name="canAcceptStatisticsCmd" type="String" value="True"/>
        <prop name="canCompareFirmwareVersion" type="String" value="True"/>
        <prop name="canNotifyPowerChange" type="String" value="True"/>
        <prop name="canUpdateFirmware" type="String" value="True"/>
        <prop name="deviceBus" type="String" value="USB"/>
        <prop name="deviceClass" type="String" value="USBHHScanner"/>
        <prop name="deviceDescription" type="String" value="DLS QW2130 USB OEM Scanner"/>
        <prop name="deviceName" type="String" value="DLS QW2130 USB OEM Scanner"/>
        <prop name="doubleReadTimeout" type="String" value="2"/>
        <prop name="enable2DigitSups" type="String" value="False"/>
        <prop name="enable4DigitPriceCheckDigit" type="String" value="False"/>
        <prop name="enable5DigitPriceCheckDigit" type="String" value="False"/>
        <prop name="enable5DigitSups" type="String" value="False"/>
        <prop name="enableBarCodeProgramming" type="String" value="True"/>
        <prop name="enableCodabar" type="String" value="True"/>
        <prop name="enableCode128" type="String" value="True"/>
        <prop name="enableCode128Sups" type="String" value="False"/>
        <prop name="enableCode39" type="String" value="True"/>
        <prop name="enableCode39CheckDigit" type="String" value="False"/>
        <prop name="enableCode93" type="String" value="True"/>
        <prop name="enableEANJAN2LabelDecode" type="String" value="False"/>
        <prop name="enableGoodReadBeep" type="String" value="True"/>
        <prop name="enableInterleaved" type="String" value="True"/>
        <prop name="enableITFCheckDigit" type="String" value="False"/>
        <prop name="enableLaserOnOffSwitch" type="String" value="True"/>
        <prop name="enableUCCEAN128" type="String" value="True"/>
        <prop name="enableUPCACheckDigit" type="String" value="False"/>
        <prop name="enableUPCAtoEAN13Expansion" type="String" value="False"/>
        <prop name="enableUPCD1D5" type="String" value="True"/>
        <prop name="enableUPCEAN" type="String" value="True"/>
        <prop name="enableUPCECheckDigit" type="String" value="False"/>
        <prop name="enableUPCEtoEAN13Expansion" type="String" value="False"/>
        <prop name="enableUPCEtoUPCAExpansion" type="String" value="False"/>
        <prop name="enableVolumeSwitch" type="String" value="True"/>
        <prop name="fullDisable" type="String" value="False"/>
        <prop name="itfLength1" type="String" value="0"/>
        <prop name="itfLength2" type="String" value="0"/>
        <prop name="itfRange" type="String" value="0"/>
        <prop name="laserTimeout" type="String" value="1"/>
        <prop name="ledGoodReadDuration" type="String" value="1"/>
        <prop name="MBeansEnabled" type="String" value="False"/>
        <prop name="motorTimeout" type="String" value="1"/>
        <prop name="productId" type="String" value="1213"/>
        <prop name="scanControl" type="String" value="False"/>
        <prop name="storeLabelSecurityLevel" type="String" value="0"/>
        <prop name="twoItfs" type="String" value="0"/>
        <prop name="usage" type="String" value="4B00"/>
        <prop name="vendorId" type="String" value="05F9"/>
        <prop name="WMIEnabled" type="String" value="False"/>
    </JposEntry>
    <JposEntry logicalName="DLS-QW2120-USB-OEM">
        <creation factoryClass="com.dls.jpos.service.DLSScannerInstanceFactory" serviceClass="com.dls.jpos.service.DLSScannerService"/>
        <vendor name="DLA" url="http://www.adc.datalogic.com"/>
        <jpos category="Scanner" version="1.13"/>
        <product description="ScannerService" name="ScannerService" url="http://www.adc.datalogic.com"/>
        <!--Other non JavaPOS required property (mostly vendor properties and bus specific properties i.e. RS232 )-->
        <prop name="beepDuration" type="String" value="1"/>
        <prop name="beepFrequency" type="String" value="2"/>
        <prop name="beepVolume" type="String" value="2"/>
        <prop name="canAcceptStatisticsCmd" type="String" value="True"/>
        <prop name="canCompareFirmwareVersion" type="String" value="True"/>
        <prop name="canNotifyPowerChange" type="String" value="True"/>
        <prop name="canUpdateFirmware" type="String" value="True"/>
        <prop name="deviceBus" type="String" value="USB"/>
        <prop name="deviceClass" type="String" value="USBHHScanner"/>
        <prop name="deviceDescription" type="String" value="DLS QW2130 USB OEM Scanner"/>
        <prop name="deviceName" type="String" value="DLS QW2130 USB OEM Scanner"/>
        <prop name="doubleReadTimeout" type="String" value="2"/>
        <prop name="enable2DigitSups" type="String" value="False"/>
        <prop name="enable4DigitPriceCheckDigit" type="String" value="False"/>
        <prop name="enable5DigitPriceCheckDigit" type="String" value="False"/>
        <prop name="enable5DigitSups" type="String" value="False"/>
        <prop name="enableBarCodeProgramming" type="String" value="True"/>
        <prop name="enableCodabar" type="String" value="True"/>
        <prop name="enableCode128" type="String" value="True"/>
        <prop name="enableCode128Sups" type="String" value="False"/>
        <prop name="enableCode39" type="String" value="True"/>
        <prop name="enableCode39CheckDigit" type="String" value="False"/>
        <prop name="enableCode93" type="String" value="True"/>
        <prop name="enableEANJAN2LabelDecode" type="String" value="False"/>
        <prop name="enableGoodReadBeep" type="String" value="True"/>
        <prop name="enableInterleaved" type="String" value="True"/>
        <prop name="enableITFCheckDigit" type="String" value="False"/>
        <prop name="enableLaserOnOffSwitch" type="String" value="True"/>
        <prop name="enableUCCEAN128" type="String" value="True"/>
        <prop name="enableUPCACheckDigit" type="String" value="False"/>
        <prop name="enableUPCAtoEAN13Expansion" type="String" value="False"/>
        <prop name="enableUPCD1D5" type="String" value="True"/>
        <prop name="enableUPCEAN" type="String" value="True"/>
        <prop name="enableUPCECheckDigit" type="String" value="False"/>
        <prop name="enableUPCEtoEAN13Expansion" type="String" value="False"/>
        <prop name="enableUPCEtoUPCAExpansion" type="String" value="False"/>
        <prop name="enableVolumeSwitch" type="String" value="True"/>
        <prop name="fullDisable" type="String" value="False"/>
        <prop name="itfLength1" type="String" value="0"/>
        <prop name="itfLength2" type="String" value="0"/>
        <prop name="itfRange" type="String" value="0"/>
        <prop name="laserTimeout" type="String" value="1"/>
        <prop name="ledGoodReadDuration" type="String" value="1"/>
        <prop name="MBeansEnabled" type="String" value="False"/>
        <prop name="motorTimeout" type="String" value="1"/>
        <prop name="productId" type="String" value="1213"/>
        <prop name="scanControl" type="String" value="False"/>
        <prop name="storeLabelSecurityLevel" type="String" value="0"/>
        <prop name="twoItfs" type="String" value="0"/>
        <prop name="usage" type="String" value="4B00"/>
        <prop name="vendorId" type="String" value="05F9"/>
        <prop name="WMIEnabled" type="String" value="False"/>
    </JposEntry>

谢谢。

0 个答案:

没有答案