473,320 Members | 1,948 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Scanner Problem in POS , VB.NET. Cannot fire DataEvent event or enable scanner

1
I have a Metro RS232 Scanner which I seem to be able to connect to in the below VB.NET code but I cannot enable the device through the DeviceEnabled = True line. The code will not error, it just refuses to set this Boolean to True. I suspect this is the reason the DataEvent event will not fire.
My environment is Windows 7, VB 2010, Microsoft POS 1.12

Private WithEvents _explorer As PosExplorer
Private _scannerList As DeviceCollection
Public WithEvents _activeScanner As Scanner

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim count As Integer = Nothing
Try
count = 0
'Open Explorer and Get list of scanner
_explorer = New PosExplorer()
'_explorer = New PosDevice()
_scannerList = _explorer.GetDevices(DeviceType.Scanner)
'Activate the metrologic scanner
For Each item As DeviceInfo In _scannerList
'For Each item As Scanner In _scannerList
count += 1
If item.ServiceObjectName = "MetroRS232Scanner" Then
'If active scanner is set close it
If Not _activeScanner Is Nothing Then
_activeScanner.Close()
_activeScanner = Nothing
End If

_activeScanner = DirectCast(_explorer.CreateInstance(item), Scanner)
_activeScanner.Open()
_activeScanner.Claim(1000)
' this line will not enable the device
_activeScanner.DeviceEnabled = True
_activeScanner.AutoDisable = False
_activeScanner.DecodeData = True
_activeScanner.DataEventEnabled = True
End If

Next


Catch ex As PosControlException
MessageBox.Show(ex.ToString)
Finally
_explorer = Nothing
End Try
End Sub

The below event will NOT FIRE!
Private Sub activeScanner_DataEvent(ByVal sender As Object, ByVal e As DataEventArgs) Handles _activeScanner.DataEvent
Dim encoder As ASCIIEncoding = New ASCIIEncoding()
Try
' Display the ASCII encoded label text
Label1.Text = encoder.GetString(_activeScanner.ScanDataLabel)
' Display the encoding type
Label1.Text = _activeScanner.ScanDataType.ToString()
' re-enable the data event for subsequent scans
_activeScanner.DataEventEnabled = True
Catch ex As PosControlException
MessageBox.Show(ex.ToString)
Finally
encoder = Nothing
End Try

Dim sCode As String = System.Text.Encoding.ASCII.GetString(_activeScanne r.ScanDataLabel)

End Sub



I have a configuration XML file as below where I have tried all the Hardware ID’s for my scanner, you can see them commented out below. What I have noticed is that the only Hardware ID it will pick ip is "HID_DEVICE_UP:0001_U:0006". It will not pickup the device ID’s
“HID\VID_0C2E&PID_0200&REV_0100" or "HID_DEVICE_UP:0001_U:0006" For these, it will not set the DeviceID property, just blank so then the active scanner cannot be opened.

- <PointOfServiceConfig Version="1.0">
- <ServiceObject Type="Scanner" Name="MetroRS232Scanner">
- <!--
<HardwareID From="HID\VID_0C2E&amp;PID_0200" To="HID\VID_0C2E&amp;PID_0200" />
-->
<HardwareID From="HID\VID_0C2E&PID_0200&REV_0100" To="HID_DEVICE_UP:0001_U:0006" />
- <!--
<HardwareId From="HID_DEVICE_UP:0001_U:0006" To="HID_DEVICE_UP:0001_U:0006" />
-->
- <!--
<HardwareId From="HID_DEVICE_SYSTEM_KEYBOARD" To="HID_DEVICE_SYSTEM_KEYBOARD" />
<HardwareId From="HID_DEVICE" To="HID_DEVICE" />
-->
</ServiceObject>
</PointOfServiceConfig>

So, in a nutshell, my problem is, my code cannot enable the scanner or fire the DataEvent. Any ideas????

Thanks in advance
Feb 24 '11 #1
0 1562

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Wilfried Mestdagh | last post by:
Hi, I create a class whitch creates a thread. When thread finish it has to fire event. But I want to fire this event in the context of the thread that created the class (usually main thread)....
5
by: Carlo Marchesoni | last post by:
From an aspx page (A.aspx) I open another one (B.aspx - for table lookup). When the user selects an entry in B.aspx I would like to force a button's event in A.aspx to be fired. I guess the only...
2
by: Umut Tezduyar | last post by:
public class WebForm1 : System.Web.UI.Page { private void Page_Load(object sender, System.EventArgs e) { }
2
by: Daniel | last post by:
I have a user control, a dropdownlist in it. I set autopostback="True" and OnSelectedIndexChanged="onSelect". In the code i have onSelect event, but just cannot fire it up? Need help, I...
7
by: Daniel | last post by:
Is there any other way can override this event, like javascript onchange added to the attribute of this dropdownlist? Thanks
5
by: Verde | last post by:
This is admittedly an apparently odd request... but please indulge me if you don't mind: Suppose I have two <asp:Button.../> on a page (Button1 and Button2). User clicks Button1 and triggers a...
2
by: Hardy Wang | last post by:
Hi all, We have DataGrid control in Web Form, our client requires to be able to click anywhere of a row to fire the event same as LinkBotton column is clicked. We we did in ASP.NET 1.1 is in...
19
by: Daniela Roman | last post by:
Hello, I try to fire an event under a button click event and maybe anybody can give a clue please. I have let's say a WEB grid with PageIndexChanged event: private void...
2
by: =?Utf-8?B?c29uaWNt?= | last post by:
Can anyone tell me how an MDI parent can fire an event that the child window can pick up? We have a MDI parent window containing 2 child windows (named 1 and 2). Child window 2 updates and fires...
3
by: nelsonbrodyk | last post by:
Hey All, I can't see to find a nice solution to this. I have a textbox, and a button. When the textbox text is set by the user, I want the button to enable. When the text is set through code (ie....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.