Accessing the Line Scanner in IBM Anyplace Kiosk

29.12.2006 at 16:06

The last week i was busy searching a way to access the integrated Line Scanner as found in the IBM Anyplace Kiosks. The biggest hurdle was actually to get the damn thing to work, after reading through various documentation (JavaPOS,OPOS,UnifiedPOS), installing different devices drivers, i finally succeeded with a OPOS based Windows solution. I still try to convince Management to deploy a Linuxbased solution, but do not yet know if there are the needed device drivers available, IBM seems to support it with IRES, we will see.

So the next step was to actually program the scanner in order to receive data. Since our "application" runs whitin a browser i had to use ActiveX and JScript to access the scanner. During coding this i learned that in order to capture ActiveX Events one has to use a slightly different event handling technique. I eventually got it to work with the code below.

<html>
<head>
<title>Scanner</title>
</head>
<body>
<object classid="clsid:CCB90182-B81E-11D2-AB74-0040054C3719" id="Scanner" width="39" 

height="38">
</object>
<script type="text/jscript" language="JScript">

onload = function(){
	MyScanner = function(){

		var scanner = Scanner;
		var dc = ec = function(){};

		/* see the following msdn-link for further 
		 * information on why this strange syntax actually works.
                 *
		 * http://msdn2.microsoft.com/en-us/library/ms974564.aspx
		 */

		function Scanner::DataEvent(){
			dc(scanner.ScanDataLabel);
			scanner.DataEventEnabled = true;
		}

		function Scanner::ErrorEvent(ResultCode, ResultCodeExtended, 

ErrorLocus, ErrorResponse){
			ec(ResultCode, ResultCodeExtended, ErrorLocus, 

ErrorResponse);
		}

		var open = function(devname){
			if(scanner.Open(devname))
				return false;
			return true;
		}

		var enable = function(devname){
			if(!open(devname))
				return false;
			if(scanner.Claim(1000))
				return false;
		
			scanner.DeviceEnabled = true;
			scanner.DataEventEnabled = true;
			scanner.DecodeData = true;
			return true;
		}

		return {
			init : function(devname,datacb,errorcb){
				if(!enable(devname))
					return false;
				if(typeof datacb == "function")
					dc = datacb;
				if(typeof errorcb == "function")
					ec = datacb;
				return true;
			},
	
			close : function(){
				return !scanner.Close();
			}
		};

	}();


	var status = MyScanner.init("LineScanner",function(v){ 
			alert("scanner " + v) 
		},
		
		function(){
			alert("error");
		}
	);

	if(!status)
		MyScanner.close();
	else
		alert("could init");
}

onunload = function(){
	MyScanner.close();
}

</script>
</body>
</html>

An important point i would like to note is that only one application can access the scanner at the same time. Which means we must _always_ call close to release the internal handle.

Hope this is useful for somebody.

Marc

Comments (2)

Scanner under Linux

18.06.2007 by Dave

Did you ever get the scanner working under linux? This link helped me to get the touch screen working: http://www-1.ibm.com/support/docview.wss?rs=0&q1=Scanner+MSR+Driver&uid=pos1R1003463&loc=en_GB&cs=utf-8&cc=uk&lang=en

Drivers for MSR

09.10.2011 by Melissa True (meltrue7[at]gmail[dot]com)

I am hitting a brick wall and want to know what your OPOS Solution was. That is my problem. Please let me know what you did to actually get the darned thing working. Thanks, True

1