C# and scanner probs...

D

Dan =o\)

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.
 
J

Jon Skeet [C# MVP]

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?
 
J

Jon Skeet [C# MVP]

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.
 
D

Dan =o\)

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 said:
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?
 
S

Selvin

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
 
D

Dan =o\)

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?
 
J

Jon Skeet [C# MVP]

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.
 
D

Dan =o\)

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.
 
J

Jon Skeet [C# MVP]

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...
 
D

Dan =o\)

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();

}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top