cancel
Showing results for 
Search instead for 
Did you mean: 

Error during scanning on MC70

Former Member
0 Kudos

During development of application which use scanner I use emulator scanner in NWDS.This application should scan barcode in loop and after each scan show scanned barcode. In NWDS with emulator works everything fine but

After deployment of applicaion on device. Scanner works only once and than throws following exception:

com.sap.ip.me.api.pios.scanner.ScannerException: A scanner API function failed with a non-scanner API error code. Call GetLastError to get extended error code.

at com.sap.ip.me.api.pios.impl.scanner.ScannerConnectionImpl.getScannerException()

at com.sap.ip.me.api.pios.impl.scanner.ScannerConnectionImpl.startRead()

.

.

.

I reload page with following script <script language="javascript">window.location.href="?event=scan_"</script>

Device is MC70 with wm5.0. Creme CrEme327d_AX_CE50_PPC_minimal and MI 2.5 SP 20 02.

Activating of scanner on JSP page

<%scanner1.initSet(request,response,out);%>

<%scanner1.Scan();%>

COde in java class Scanner:

public void initSet(HttpServletRequest request, HttpServletResponse response, JspWriter JspOut) throws PIOSException {

this.request = request;

this.response = response;

this.JspOut = JspOut;

}

public void close() {

try {

scannerConnection.endRead();

scannerConnection.close();

priznak=false;

// System.out.println("volanie metody close");

} catch (Exception ex) {

ex.printStackTrace();

}

}

public void Scan() throws Exception {

try

{

initScanner();

scanBarcode();

}

catch (Exception ex)

{

}

finally

{

close();

}

public void Scan() throws Exception {

try

{

initScanner();

scanBarcode();

}

catch (Exception ex)

{

}

finally

{

close();

}

}

private void scanBarcode() throws Exception {

barcodeScanned = false;

scannerConnection.startRead();

JspOut.flush();

while (barcodeScanned==false)

{

Thread.sleep(250);

}

scannerConnection.endRead();

}

public void onDataReceived(ScannerData scannerData) {

try

{

BarCode = new String(scannerData.toByteArray(), "ASCII");

}

catch (Exception ex)

{

//System.out.println("exception onDataReceived" );

lastException = ex;

}

barcodeScanned = true;

try {

JspOut.flush();

// //System.out.println(" try flush ");

} catch (IOException e) {

// //System.out.println(" catch flush ");

// TODO Auto-generated catch block

e.printStackTrace();

}

}

Any suggestion are higly appreciated! Urgently

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi ptako,

I have done the same application in Blackberry over Bluetooth. I shall try to give you clue.

1. Best approach is to fetch the Barcode into any contianer(say file) using a thread.

2. let the application(process) go to sleep for a few more msec before it can read the second barcode. It might happen that, before one module/process writes the barcode another process might read the next barcod hence, throwing an exception.

3. there is the diff between the app running on PC and device is because of the speeds of the processors. same code may not work here.

what exception you are getting? try to debug while running the application both on device and on PC.

Hope this helps.

Divya

Former Member
0 Kudos

Hi

Thanks for reply

I tried my application on MC50 with wm2003 and with MI sp17 and everything goes well and scanner scanned exactly same as on the desktop.

I hopeless where can be a problem, but I supposed it could be something in WM 5.0

Michal