473,769 Members | 7,923 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C# and scanner probs...

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.

Nov 16 '05 #1
9 4553
<"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 - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #2
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]" <sk***@pobox.co m> wrote in message
news:MP******** *************** *@msnews.micros oft.com...
<"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 - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 16 '05 #3
<"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 - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #4

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.Validate d += new System.EventHan dler(txtEAN_Val idated);
btAdd.Click += new System.EventHan dler(btAdd_Clic k);
}
private void txtEAN_Validate d(object sender, System.EventArg s e)
{
alCodes.Add(txt EAN.Text);
}

private void btAdd_Click(obj ect sender, System.EventArg s e)
{
txtEAN.Text = "";
txtEAN.Focus();
}
}

pozdrawiam

Przemek Sulikowski
Nov 16 '05 #5

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]" <sk***@pobox.co m> wrote in message
news:MP******** *************** *@msnews.micros oft.com...
<"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 - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 16 '05 #6
<"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 - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #7
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]" <sk***@pobox.co m> wrote in message
news:MP******** *************** *@msnews.micros oft.com...
<"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 - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 16 '05 #8
<"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 - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #9
> 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(<m ethod>)" 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(Symb ol.Barcode.Read erData TheReaderData)
{
try
{
string readdata = TheReaderData.T ext.ToUpper();

}

AppData.DebugLo g ( "Scanned: '" + readdata + "'", "Scan
Action" );
BarcodeDataStri ng = readdata;

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

private string BarcodeDataStri ng;= "";
public event System.EventHan dler Scanned;
protected virtual void OnScanned(Event Args e)
{
if (Scanned != null)
Scanned(this, e);
}

public string BarcodeData
{
get
{
return BarcodeDataStri ng;
}
}
/*
*
* Form snippet that activates scan trigger
*
*/
private void FormPick_Load(o bject sender, System.EventArg s e)
{
LoadPickList();
GetNextItem();

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

}

private void FormPick_Closin g(object sender,
System.Componen tModel.CancelEv entArgs e)
{
if ( scanner != null )
{
AppData.DebugLo g ( "[" + this.ToString() + "] - Scanner
engine shutdown", "Message" );

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

scanner.Shutdow n();
scanner = null;
}

StorePickList() ;

}
Nov 16 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
3736
by: karimt | last post by:
I have a scanner connected to my server running Apache. I would like to have a script that allows me to get a pdf file directly from the scanner. Is this do-able?
0
1898
by: cricket | last post by:
i need help with Python lexical scanner for this assignment, i have create a scanner using the Flex scanner generating tool. The requirements of the scanner are as follows: 1) Accept input via stdin (standard input). 2) Return output via stdout (standard output) 3) Recognize tokens of the Python programming language 3.1) Tokens are grouped into the following categories: Newline Indent
0
1701
by: Daniel Bass | last post by:
Symbol MC9000k scanner running Windows Mobile 2003. C# .Net (.Net CF) with OpenNetCf 1.2 installed. Latest Symbol SDK driving the scan engine stuff. I've extracted the barcode scanner handling stuff from one of the Symbol SDK examples, and using their .Net classes, drive the scanning engine in my application. Basically the program has a main screen which allows you to perform differing actions, all of which involved the scanner....
4
4530
by: teddysnips | last post by:
I posted yesterday about a project I'm involved in to build a login application using a barcode scanner. I've solved most of the problems, but one remains. The client want to disable keyboard input (except at some remote sites where there won't be a scanner). The session "knows" whether that site should be keyboard enabled, but unfortunately the output from the scanner is in the form of keypresses! So any attempt to capture and...
7
25947
by: DemonWasp | last post by:
I've been having some trouble getting the Scanner class to operate the way I'd like. I'm doing some fairly basic file IO and I can't seem to get the class to load the last line/token any way I try. First, I tried using the following: File InFile=new File("input.txt"); Scanner In=new Scanner(InFile);
2
4922
by: chris_gpf1 | last post by:
Hi, I'm working on a website where the user will have to scan a barcode with a serial barcode scanner. I get the scanner working and reading the barcode, but when I want to write the string in a Textbox, it's not working. The Textbox remain blank. Here's the code:
4
20233
by: Gerry19 | last post by:
Hi All, I'm trying to monitor data passed from a USB Barcode scanner but I can't find any decent code examples of what I need to do, including any references I need to include. I know I need to use RegisterRawInputDevices & WM_INPUT but have no idea where to start. Any help greatly appreciated.
3
2955
by: thename1000 | last post by:
Hi, I'm trying to create this output: Input team 1's name: Team 1 Input team 1's ranking: 90.4 etc.
6
3730
by: rotaryfreak | last post by:
Hi everyone, ive had this problem for a while and i cant seem to figure out why. I am using eclipse to create my java code. When import the Scanner class, create a new object and so on... eclipse compiles the code without problem, BUT, when i try to run the same code from command line, i get this error: Greeting.java:24: cannot resolve symbol symbol : class Scanner location : package util import java.util.Scanner; ...
0
9589
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9423
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10216
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10049
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9997
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9865
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7413
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5310
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.