I have a Metrologic MS9520 scanner which i am trying to configure for use with POS.NET 1.12. I have the hardware ID in C:\Program Files\Common Files\microsoft shared\Point Of Service\Control Configurations\Control configurations.xml as follows: -
XML
<PointOfServiceConfig Version="1.0">
<ServiceObject Type="Scanner" Name="MetroRS232Scanner">
<HardwareID From="HID\VID_0C2E&PID_0200&REV_0100" 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>
and my code to open, claim, and enable my scanner is as follows: -
Private WithEvents _explorer As PosExplorer
Private _scannerList As DeviceCollection
Public WithEvents _activeScanner As Scanner
Public Event DataEvent As DataEventHandler
Public Sub New()
InitializeComponent()
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs)
'Method(One)
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 ' And (count = 5 Or count = 3 Or count = 4) Then
'If item.DeviceName = "MetroRS232Scanner" And (count = 3 Or count = 4) 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)
_activeScanner.DeviceEnabled = True
_activeScanner.AutoDisable = False
_activeScanner.DecodeData = True
_activeScanner.DataEventEnabled = True
RaiseEvent DataEvent(sender, e)
_activeScanner.DeviceEnabled = True
'Dim dataEvent As DataEventHandler = PosCommon.GetType().GetEvent("DataEvent")
MessageBox.Show(_activeScanner.DeviceEnabled)
End If
'End If
Next
Catch ex As PosControlException
MessageBox.Show(ex.ToString)
Finally
_explorer = Nothing
End Try
End Sub
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(_activeScanner.ScanDataLabel)
End Sub
Private Sub activeScanner_ErrorEvent(ByVal sender As Object, ByVal e As DeviceErrorEventArgs)
Try
're-enable the data event for subsequent scans
_activeScanner.DataEventEnabled = True
Catch ex As PosControlException
End Try
End Sub
The code seems run without errors however after the DeviceEnabled is set to true, It seems to ignore this command and leave the property set to false. And when something is scanned the Dataevent will NOT fire. Do i need to reconfigure the scanner into USB or HID mode? Any one any ideas any help would be greatly appreciated...
Thanks