Disable and then re-enable Symbol Barcode Scanner

4.9k views Asked by At

Ok...so this seems like it should be a super simple - I need to disable a symbol barcode scanner, do some work and then re-enable the scanner.

I have a scanner class which works fine so I tried the below code in my item look-up class

 private Symbol.Barcode.Reader MyReader = Scanner.GetMyReader;//gets the reader
.....
......
private method()
{
  MyReader.Actions.Disable();

 ...do some work here

 MyReader.Actions.Enable()

}

The problem with the above code is the reader never seems to re-enable, esp. the laser light never comes back on and the read notify event never fires again.

I also tried MyReader.ReadNotify -= MyReader_ReadNotify; and then adding it back but this doesn't work either as the scanner still builds scan events when the scan button is hit.

I did try MyReader.Actions.Read(MyReaderData), this fired the read event again and still did not enable the scanner.

Is there something I need to add after MyReader.Actions.Enable() ?

I have searched for hours with no luck on this problem.

Thanks

1

There are 1 answers

2
josef On

According to the Motorola EMDK guide you just need three methods and the event handlers in place:

QUOTE

Enable the reader

Enables the scanner hardware. This method does not make the scanner scan or turn on the laser.

// Enable the Reader

MyReader.Actions.Enable();

Submit a read request

Starts a pending read. The method will not turn on the laser. It will, however, put the scanner in a state in which the laser can be turned on either by pressing a hardware trigger or by performing assoftware trigger.

// Submit a read

MyReader.Actions.Read(this.MyReaderData);

Even though a read request is submit and a successful read is complete, obtaining data needs an event handler. Please refer Registering to to scanner notifications sections for creating event handlers.

Disable the reader

Disables the scanner hardware. Reverses the Enable process. The scanner must be re-enabled before its use if it has been disabled.

// Disable the reader

this.MyReader.Actions.Disable();

NOTE: When disabling the reader, the following must be considered regarding notification handlers. For information on notifications, refer to the section "Registering to scanner notifications".

Status notification handler: A previously attached StatusNotify event handler will be automatically 
detached. When the reader is re-enabled, the event handler must be re-attached to get further status 
notifications.

Read notification handler: A previously attached ReadNotify event handler will not be detached. It
gets detached only when the reader is disposed.

/QUOTE

That means you have to use:

this.MyReader.Actions.Disable();

and

MyReader.Actions.Enable();

and re-attach notification handlers. The scanner will then lit when you issue

MyReader.Actions.Read(this.MyReaderData);

Possibly you have to press the scan button to trigger the scanner to light up.