PC Review


Reply
Thread Tools Rate Thread

C# and scanner probs...

 
 
Dan =o\)
Guest
Posts: n/a
 
      26th Oct 2004
Hey guys,

I wonder if you could please provide me with some ideas as to how to get
around this problem.

[Scenario]
Symbol MC9000-k, Pocket PC 2003... With a scanner application I've written,
data is loaded into ArrayList structures when the user performs some action.
This list contains a list of barcode numbers that are currently accepted.
Finally, there is a manual entry button in my application where the user can
(if the barcode is damaged for example), manually put in the barcode number.
This then passes the entered in data into the same function that is called
after a scan.

[Problem]
Some times the scanner gets into a mode where it returns an error saying
that any barcode scanned is not found in the list of data when we know it
is. This is proved by manually entering in the barcode number which
correctly registers the barcode as you'd expect.
If the application is restarted, suddenly scanning works with all barcode
data you'd expect.

As I mentioned, the manual entry, and scanning, call the same procedure...
When the scanner error message appears, the barcode that was scanned is
displayed and this appears correct!?!?


This is thoroughly doing my head in and any help would really be
appreciated.

Thanks.

Dan.





 
Reply With Quote
 
 
 
 
Jon Skeet [C# MVP]
Guest
Posts: n/a
 
      26th Oct 2004
<"Dan =o\)" <danielbass [at] postmaster [dot] co [dot] uk>> wrote:
> I wonder if you could please provide me with some ideas as to how to get
> around this problem.
>
> [Scenario]
> Symbol MC9000-k, Pocket PC 2003... With a scanner application I've written,
> data is loaded into ArrayList structures when the user performs some action.
> This list contains a list of barcode numbers that are currently accepted.
> Finally, there is a manual entry button in my application where the user can
> (if the barcode is damaged for example), manually put in the barcode number.
> This then passes the entered in data into the same function that is called
> after a scan.
>
> [Problem]
> Some times the scanner gets into a mode where it returns an error saying
> that any barcode scanned is not found in the list of data when we know it
> is. This is proved by manually entering in the barcode number which
> correctly registers the barcode as you'd expect.
> If the application is restarted, suddenly scanning works with all barcode
> data you'd expect.
>
> As I mentioned, the manual entry, and scanning, call the same procedure...
> When the scanner error message appears, the barcode that was scanned is
> displayed and this appears correct!?!?


What format does the scanner return the data is? Could you have some
trailing spaces, or something like that?

--
Jon Skeet - <(E-Mail Removed)>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
 
Reply With Quote
 
 
 
 
Jon Skeet [C# MVP]
Guest
Posts: n/a
 
      26th Oct 2004
<"Dan =o\)" <danielbass [at] postmaster [dot] co [dot] uk>> wrote:
> By the time the symbol library passes by the data it's just in a string, and
> I confirmed it earlier that the string is identical to what you'd expect. No
> spaces pre/appending the barcode...


How did you confirm that? There may be things other than spaces - nul
characters, for example.

I don't believe a method will know where a string comes from, so if
"the same" string works in manual entry mode, I don't believe it's
actually the same string.

> How can it not work one minute, then work fine the next after a app
> restart?!?! **8-&


Well, that's a different matter - if the scanner *has* started
including some bogus data, then resetting things could well make a
difference.

--
Jon Skeet - <(E-Mail Removed)>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
 
Reply With Quote
 
Dan =o\)
Guest
Posts: n/a
 
      26th Oct 2004
Jon,

By the time the symbol library passes by the data it's just in a string, and
I confirmed it earlier that the string is identical to what you'd expect. No
spaces pre/appending the barcode...

How can it not work one minute, then work fine the next after a app
restart?!?! **8-&

And symbol dev support is well, non-existent.

Dan.


"Jon Skeet [C# MVP]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> <"Dan =o\)" <danielbass [at] postmaster [dot] co [dot] uk>> wrote:
>> I wonder if you could please provide me with some ideas as to how to get
>> around this problem.
>>
>> [Scenario]
>> Symbol MC9000-k, Pocket PC 2003... With a scanner application I've
>> written,
>> data is loaded into ArrayList structures when the user performs some
>> action.
>> This list contains a list of barcode numbers that are currently accepted.
>> Finally, there is a manual entry button in my application where the user
>> can
>> (if the barcode is damaged for example), manually put in the barcode
>> number.
>> This then passes the entered in data into the same function that is
>> called
>> after a scan.
>>
>> [Problem]
>> Some times the scanner gets into a mode where it returns an error saying
>> that any barcode scanned is not found in the list of data when we know it
>> is. This is proved by manually entering in the barcode number which
>> correctly registers the barcode as you'd expect.
>> If the application is restarted, suddenly scanning works with all barcode
>> data you'd expect.
>>
>> As I mentioned, the manual entry, and scanning, call the same
>> procedure...
>> When the scanner error message appears, the barcode that was scanned is
>> displayed and this appears correct!?!?

>
> What format does the scanner return the data is? Could you have some
> trailing spaces, or something like that?
>
> --
> Jon Skeet - <(E-Mail Removed)>
> http://www.pobox.com/~skeet
> If replying to the group, please do not mail me too



 
Reply With Quote
 
Selvin
Guest
Posts: n/a
 
      26th Oct 2004

why u dont use scanner as keyboard
there is an application in SDK named "ScanWedge"
this application works at background and emulate keyboard
u can input char which must to be send before and after scanning
fx.: \r before and \t after now u can add code after
validate TextBox with code

class Form1: Form
{
TextBox txtEAN = new TextBox();
Button btAdd = new Button();
ArrayList alCodes = new ArrayList();
Form1()
{
txtEAN.TabIndex = 0;
btAdd.TabIndex = 1;
txtEAN.Validated += new System.EventHandler(txtEAN_Validated);
btAdd.Click += new System.EventHandler(btAdd_Click);
}
private void txtEAN_Validated(object sender, System.EventArgs e)
{
alCodes.Add(txtEAN.Text);
}

private void btAdd_Click(object sender, System.EventArgs e)
{
txtEAN.Text = "";
txtEAN.Focus();
}
}

pozdrawiam

Przemek Sulikowski


 
Reply With Quote
 
Dan =o\)
Guest
Posts: n/a
 
      26th Oct 2004

Unfortunately I'm working off site, and the scanners are on site...

I've got a function called remove non-number, checks every char in a string
for whether it is a valid number and adds it to the result if so. I suppose
I could extend that from here, to include the set of characters I'd expect
in a barcode, and then perform this filter before using the data?




"Jon Skeet [C# MVP]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> <"Dan =o\)" <danielbass [at] postmaster [dot] co [dot] uk>> wrote:
>> By the time the symbol library passes by the data it's just in a string,
>> and
>> I confirmed it earlier that the string is identical to what you'd expect.
>> No
>> spaces pre/appending the barcode...

>
> How did you confirm that? There may be things other than spaces - nul
> characters, for example.
>
> I don't believe a method will know where a string comes from, so if
> "the same" string works in manual entry mode, I don't believe it's
> actually the same string.
>
>> How can it not work one minute, then work fine the next after a app
>> restart?!?! **8-&

>
> Well, that's a different matter - if the scanner *has* started
> including some bogus data, then resetting things could well make a
> difference.
>
> --
> Jon Skeet - <(E-Mail Removed)>
> http://www.pobox.com/~skeet
> If replying to the group, please do not mail me too



 
Reply With Quote
 
Jon Skeet [C# MVP]
Guest
Posts: n/a
 
      26th Oct 2004
<"Dan =o\)" <danielbass [at] postmaster [dot] co [dot] uk>> wrote:
> Unfortunately I'm working off site, and the scanners are on site...
>
> I've got a function called remove non-number, checks every char in a string
> for whether it is a valid number and adds it to the result if so. I suppose
> I could extend that from here, to include the set of characters I'd expect
> in a barcode, and then perform this filter before using the data?


Hard to say without knowing a bit more about it, but that's a
possibility.

I suggest you keep a log of the exact string which the barcode is
returning, so that you can get that information back from site.

--
Jon Skeet - <(E-Mail Removed)>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
 
Reply With Quote
 
Dan =o\)
Guest
Posts: n/a
 
      29th Oct 2004
Jon,

Guess what, put in a debug log, and got it when the scanning wasn't working
as expected. Just happened half way into the day when it has been working
fine for the last week...

The data that was scanned looks identical to what i'd expect. No escape
characters etc... That really doesn't make sense. The work-around I have so
far is to have a little green cross (for medic) button on the main form, and
when the scanner isn't working, it calls another process then closes the
application down. The "other process" is another app that simply waits for a
few seconds, then opens up the original application... this seems to destroy
the scanner handler objects (from the Symbol SDK) which should be clean up
by the garbage collector when exiting from a dialog where you scan, back to
the main screen anyway?

Who knows...
Any ideas?

Thanks.

Dan.

"Jon Skeet [C# MVP]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> <"Dan =o\)" <danielbass [at] postmaster [dot] co [dot] uk>> wrote:
>> Unfortunately I'm working off site, and the scanners are on site...
>>
>> I've got a function called remove non-number, checks every char in a
>> string
>> for whether it is a valid number and adds it to the result if so. I
>> suppose
>> I could extend that from here, to include the set of characters I'd
>> expect
>> in a barcode, and then perform this filter before using the data?

>
> Hard to say without knowing a bit more about it, but that's a
> possibility.
>
> I suggest you keep a log of the exact string which the barcode is
> returning, so that you can get that information back from site.
>
> --
> Jon Skeet - <(E-Mail Removed)>
> http://www.pobox.com/~skeet
> If replying to the group, please do not mail me too



 
Reply With Quote
 
Jon Skeet [C# MVP]
Guest
Posts: n/a
 
      30th Oct 2004
<"Dan =o\)" <danielbass [at] postmaster [dot] co [dot] uk>> wrote:
> Guess what, put in a debug log, and got it when the scanning wasn't working
> as expected. Just happened half way into the day when it has been working
> fine for the last week...
>
> The data that was scanned looks identical to what i'd expect. No escape
> characters etc... That really doesn't make sense. The work-around I have so
> far is to have a little green cross (for medic) button on the main form, and
> when the scanner isn't working, it calls another process then closes the
> application down. The "other process" is another app that simply waits for a
> few seconds, then opens up the original application... this seems to destroy
> the scanner handler objects (from the Symbol SDK) which should be clean up
> by the garbage collector when exiting from a dialog where you scan, back to
> the main screen anyway?


It would really depend on the rest of your code, to be honest. If
you're getting all the right data though, it doesn't sound like it's a
problem with the scanner. You really need to get to the bottom of why
calling your search (or whatever) method with the identical data
supposedly sometimes works and sometimes doesn't...

--
Jon Skeet - <(E-Mail Removed)>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
 
Reply With Quote
 
Dan =o\)
Guest
Posts: n/a
 
      2nd Nov 2004
> It would really depend on the rest of your code, to be honest. If
> you're getting all the right data though, it doesn't sound like it's a
> problem with the scanner. You really need to get to the bottom of why
> calling your search (or whatever) method with the identical data
> supposedly sometimes works and sometimes doesn't...



Jon,

I had a thought this morning... I've wrapped up all the SDK scanner events,
objects and methods into one class which I call from each screen where I
need the scanner.

When creating the object, I an eventhandler on that object a "+= new
EventHandler(<method>)" and then when I'm finished shut down the object, and
assign null to it.

I think what's happening is another screen then creates a scanner object,
but (because I'm naive) when the new event handler is assigned, the scanner
event still triggers the old eventhandler, and as a result it won't
necessarily work...

Would you mind casting your wise eye at what I'm doing here to see if it
makes any sense at all.





/*
*
* Scan object snippt that wraps the scanner...
*
*/

/// <summary>
/// Handle data from the reader
/// </summary>
private void HandleData(Symbol.Barcode.ReaderData TheReaderData)
{
try
{
string readdata = TheReaderData.Text.ToUpper();

}

AppData.DebugLog ( "Scanned: '" + readdata + "'", "Scan
Action" );
BarcodeDataString = readdata;

OnScanned ( EventArgs.Empty );
}
catch ( Exception ex )
{
AppData.DebugLog ( "Scanner error in ScanEngine! Error [" +
this.ToString() + ".HandleData()]: " + ex.Message, "Exception Error" );
}
}

private string BarcodeDataString;= "";
public event System.EventHandler Scanned;
protected virtual void OnScanned(EventArgs e)
{
if (Scanned != null)
Scanned(this, e);
}

public string BarcodeData
{
get
{
return BarcodeDataString;
}
}


/*
*
* Form snippet that activates scan trigger
*
*/


private void FormPick_Load(object sender, System.EventArgs e)
{
LoadPickList();
GetNextItem();

scanner = new ScanEngine();
if ( scanner != null )
{
AppData.DebugLog ( "[" + this.ToString() + "] - Scanner
initialised", "Message" );
scanner.Scanned += new EventHandler(BarcodeRead);
}

}

private void FormPick_Closing(object sender,
System.ComponentModel.CancelEventArgs e)
{
if ( scanner != null )
{
AppData.DebugLog ( "[" + this.ToString() + "] - Scanner
engine shutdown", "Message" );

// Should there be something here to -= the eventhandler?

scanner.Shutdown();
scanner = null;
}

StorePickList();

}


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Scanner is installed but Scanner Center says no scanner installed =?Utf-8?B?U2hlcmlkYW5DaGljbw==?= Windows Vista Print / Fax / Scan 0 22nd Nov 2006 09:34 PM
missing scanner/camera in scanner and camera wizard Pete Billante Windows XP Hardware 0 14th Feb 2004 01:46 PM
Windows XP Home: Scanner and Camera Control Panel defect: No installed scanner appears - and no scanner works! tah Windows XP Hardware 6 15th Dec 2003 09:42 PM
Windows XP Home: Scanner and Camera Control Panel defect: No installed scanner appears - and no scanner works! tah Windows XP General 8 15th Dec 2003 09:42 PM
Windows XP Home: Scanner and Camera Control Panel defect: No installed scanner appears - and no scanner works! tah Windows XP Help 6 15th Dec 2003 09:42 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:43 PM.