Reputation: 1822
Requirement: To support multiple scanners on the windows machine.
Tools:
Issue: The First scanner is claimed successfully. However, claim the second scanner leads to following exception "Device is already claimed by another control device".
Code Analysis:
SymScannerSvc112 as the service class being used for Handheld scanner.
SymScannerSvc112 extends SymScannerSvc. SymScannerSvc holds a static variable "_fClaimed".
When the first scanner is claimed, the static variable '_fClaimed' is set to true. Now, when you try to claim the second scanner, following code obstructs it as the '_fClaimed' is set as true.
Code: SymScannerSvc.java:
this._alreadyClaimed = false;
if(_fClaimed) {
this._alreadyClaimed = true;
this.release();
}
Note: 1. Scanners are attached to USB ports.
jpos.xml
<?xml version="1.0" encoding="UTF-8"?>
<JposEntries>
<JposEntry logicalName="ZebraScannerSerial">
<creation factoryClass="com.motorola.jpos.service.scanner.SymScannerSvc112Factory" serviceClass="com.motorola.jpos.service.scanner.SymScannerSvc112"/>
<vendor name="Zebra Technologies" url="https://www.zebra.com"/>
<jpos category="Scanner" version="1.12"/>
<product description="Zebra Serial" name="Zebra Serial Scanner on COM1" url="https://www.zebra.com"/>
<!--Other non JavaPOS required properties-->
<!--Scanner configuration-->
<!--Comm port device name-->
<prop name="port" value="COM1"/>
<!--Baud rate, default=9600, valid values are: 9600, 19200, 38400, 57600, 115200-->
<prop name="baud" value="9600"/>
<!--Data bits, default=7, valid values are: 5, 6, 7, 8-->
<prop name="databits" value="8"/>
<!--Stop bits, default=1, valid values are: 1=1 stop bit, 2=2 stop bits, 3=1.5 stop bits-->
<prop name="stopbits" value="1"/>
<!--Parity, default='O' (Odd), valid values are: 'N'one, 'O'dd, 'E'ven, 'M'ark, 'S'pace-->
<prop name="parity" value="O"/>
<!--Port mode, default='B', valid values are: 'B'=Nixdorf-B-->
<prop name="mode" value="B"/>
<!--UPC-A Length, default=13, indicates the number of digits generated by the scanner-->
<!--for UPC-A labels based on the scanner's preamble and check digit settings.-->
<!--The scanner service uses this value to determine when supplementals are present.-->
<!--The default value of 13 assumes preamble is set to system character-->
<!--and country code and that transmit check digit is enabled-->
<prop name="UPCALength" value="13"/>
<!--UPC-E Length, default=7, indicates the number of digits generated by the scanner-->
<!--for UPC-E labels based on the scanner's preamble and check digit settings.-->
<!--The scanner service uses this value to determine when supplementals are present.-->
<!--The default value of 7 assumes preamble is set to system character-->
<!--only and that transmit check digit is disabled-->
<prop name="UPCELength" value="7"/>
<!--Scanner type, default=0, valid values are: 7 - NixdofrUSB-->
<prop name="ScannerType" value="7"/>
<prop name="ExclusiveClaimLevel" value="0" />
</JposEntry>
<JposEntry logicalName="ZebraScannerUSB">
<creation factoryClass="com.motorola.jpos.service.scanner.SymScannerSvc112Factory" serviceClass="com.motorola.jpos.service.scanner.SymScannerSvc112"/>
<vendor name="Zebra Technologies" url="https://www.zebra.com"/>
<jpos category="Scanner" version="1.12"/>
<product description="Zebra USB" name="Zebra Scanner" url="https://www.zebra.com"/>
<!--Other non JavaPOS required properties-->
<!--Comm port device name, must be 'USB' for USB scanner-->
<prop name="port" value="USB"/>
<!--Scanner type, default=0, valid values are: 6 - IBM HID-->
<prop name="ScannerType" value="6"/>
<prop name="ExclusiveClaimLevel" value="1" />
</JposEntry>
<JposEntry logicalName="IBM HANDHELD">
<creation factoryClass="com.motorola.jpos.service.scanner.SymScannerSvc112Factory" serviceClass="com.motorola.jpos.service.scanner.SymScannerSvc112"/>
<vendor name="Zebra Technologies" url="https://www.zebra.com"/>
<jpos category="Scanner" version="1.12"/>
<product description="Zebra USB" name="Zebra Scanner" url="https://www.zebra.com" />
<!--Other non JavaPOS required properties-->
<!--Comm port device name, must be 'USB' for USB scanner-->
<prop name="port" value="USB"/>
<!--Scanner type, default=0, valid values are: 6 - IBM HID-->
<prop name="ScannerType" value="6"/>
<prop name="ExclusiveClaimLevel" value="1" />
</JposEntry>
<JposEntry logicalName="ZebraUSBTableTop">
<creation factoryClass="com.motorola.jpos.service.scanner.SymScannerSvc112Factory" serviceClass="com.motorola.jpos.service.scanner.SymScannerSvc112"/>
<vendor name="Zebra Technologies" url="https://www.zebra.com"/>
<jpos category="Scanner" version="1.12"/>
<product description="Zebra USB Scanner" name="Zebra Scanner" url="https://www.zebra.com"/>
<!--Other non JavaPOS required properties-->
<!--Comm port device name, must be 'USB' for USB scanner-->
<prop name="port" value="USBIBMTT"/>
<!--Scanner type, default=0, valid values are: 18944=TableTop(0x4A00)-->
<!--prop name="ScannerType" value="18944"-->
<prop name="ScannerType" value="9"/>
<prop name="ExclusiveClaimLevel" value="0" />
</JposEntry>
<JposEntry logicalName="ZebraUSBHandHeld">
<creation factoryClass="com.motorola.jpos.service.scanner.SymScannerSvc112Factory" serviceClass="com.motorola.jpos.service.scanner.SymScannerSvc112"/>
<vendor name="Zebra Technologies" url="https://www.zebra.com"/>
<jpos category="Scanner" version="1.12"/>
<product description="Zebra USB Scanner" name="Zebra Scanner" url="https://www.zebra.com"/>
<!--Other non JavaPOS required properties-->
<!--Comm port device name, must be 'USB' for USB scanner-->
<prop name="port" value="USBIBMHID"/>
<!--Scanner type, default=0, valid values are: 19200=HandHeld(0x4B00)-->
<prop name="ScannerType" value="19200"/>
<prop name="ExclusiveClaimLevel" value="0" />
</JposEntry>
<JposEntry logicalName="ZebraUSBOPOS">
<creation factoryClass="com.motorola.jpos.service.scanner.SymScannerSvc112Factory" serviceClass="com.motorola.jpos.service.scanner.SymScannerSvc112"/>
<vendor name="Zebra Technologies" url="https://www.zebra.com"/>
<jpos category="Scanner" version="1.12"/>
<product description="Zebra USB Scanner" name="Zebra Scanner" url="https://www.zebra.com"/>
<!--Other non JavaPOS required properties-->
<!--Comm port device name, must be 'USB' for USB scanner-->
<prop name="port" value="USBOPOS"/>
<!--Scanner type, default=0, valid values are: 13 -->
<prop name="ScannerType" value="13"/>
<prop name="ExclusiveClaimLevel" value="0" />
</JposEntry>
<JposEntry logicalName="ZebraScannerSNAPI">
<creation factoryClass="com.motorola.jpos.service.scanner.SymScannerSvc112Factory" serviceClass="com.motorola.jpos.service.scanner.SymScannerSvc112"/>
<vendor name="Zebra Technologies" url="https://www.zebra.com"/>
<jpos category="Scanner" version="1.12"/>
<product description="Zebra SNAPI Scanner" name="Zebra Scanner" url="https://www.zebra.com"/>
<!--Other non JavaPOS required properties-->
<!--Comm port device name, must be 'USB' for USB scanner-->
<prop name="port" value="SNAPI"/>
<!--Scanner type, default=0, valid values are: 2 - SNAPI-->
<prop name="ScannerType" value="2"/>
<prop name="ExclusiveClaimLevel" value="0" />
</JposEntry>
<JposEntry logicalName="ZebraAllScanners">
<creation factoryClass="com.motorola.jpos.service.scanner.SymScannerSvc112Factory" serviceClass="com.motorola.jpos.service.scanner.SymScannerSvc112"/>
<vendor name="Zebra Technologies" url="https://www.zebra.com"/>
<jpos category="Scanner" version="1.12"/>
<product description="Zebra Serial/USB Scanner" name="Zebra Scanner" url="https://www.zebra.com"/>
<!--Scanner type, default=0, valid values are: 1- ALL Scanners-->
<prop name="ScannerType" value="1"/>
<prop name="ExclusiveClaimLevel" value="0" />
</JposEntry>
<JposEntry logicalName="IBM HANDHELD">
<creation factoryClass="com.motorola.jpos.service.scanner.SymScannerSvc112Factory" serviceClass="com.motorola.jpos.service.scanner.SymScannerSvc112"/>
<vendor name="Zebra Technologies" url="https://www.zebra.com"/>
<jpos category="Scanner" version="1.12"/>
<product description="Zebra Serial/USB Scanner" name="Zebra Scanner" url="https://www.zebra.com"/>
<!--Scanner type, default=0, valid values are: 1- ALL Scanners-->
<prop name="ScannerType" value="1"/>
<prop name="ExclusiveClaimLevel" value="0" />
</JposEntry>
<JposEntry logicalName="ZebraScale">
<creation factoryClass="com.motorola.jpos.service.SvcServiceInstanceFactoryImpl" serviceClass="com.motorola.jpos.service.scale.ScaleService113Impl"/>
<vendor name="Zebra Technologies" url="https://www.zebra.com"/>
<jpos category="Scale" version="1.13"/>
<product description="Zebra Scale" name="Zebra Scale" url="https://www.zebra.com"/>
<prop name="ErrorOnSameWeight" value="1"/>
</JposEntry>
Upvotes: 1
Views: 1643
Reputation: 1822
The JPOS logical name ‘ZebraAllScanners’ allows scanners on different USB ports to transmit barcodes to a single instance of the spring boot app.
<JposEntry logicalName="ZebraAllScanners">
<creation factoryClass="com.motorola.jpos.service.scanner.SymScannerSvc112Factory" serviceClass="com.motorola.jpos.service.scanner.SymScannerSvc112"/>
<vendor name="Zebra Technologies" url="https://www.zebra.com"/>
<jpos category="Scanner" version="1.12"/>
<product description="Zebra Serial/USB Scanner" name="Zebra Scanner" url="https://www.zebra.com"/>
<!--Scanner type, default=0, valid values are: 1- ALL Scanners-->
<prop name="ScannerType" value="1"/>
<prop name="ExclusiveClaimLevel" value="0" />
</JposEntry>
Upvotes: 0
Reputation: 4350
I think it probably became clear. The additional explanation request written in the comment is unnecessary.
This is because the original design of the service object is incorrect. Service objects are not created so that one application can simultaneously use multiple scanners of the same vendor at the same time.
Perhaps due to the characteristics of the Java language, the vendor built the problem, trying to easily implement exclusion control which is difficult to realize.
If you want to use multiple scanners at the same time, consider the device configuration so that each scanner works with a different service object.
As far as jpos.xml is concerned, all Zebra scanners seem to use the same service object, so prepare another vendor's scanner.
"consider setting the device so that each scanner operates on a different service object" means, for example, when connecting a plurality of scanners to a single POS at the same time, as Zebra DS2208 as the first device, Honeywell Genesis 7580g as the second device and Denso-Wave QK30 as the third device, do not connect multiple scanners of one vendor.
The reason is that the following part of each device entry in jpos.xml specifies a service object to operate, but even if it is another scanner (eg "ZebraScannerSerial" and "ZebraScannerUSB"), this content If they are the same, the same service object will be considered to work.
<creation factoryClass="com.motorola.jpos.service.scanner.SymScannerSvc112Factory" serviceClass="com.motorola.jpos.service.scanner.SymScannerSvc112"/>
And if the same Zebra service object is considered to share the variable '_fClaimed', the question phenomenon will occur.
Upvotes: 1