I have slight problem I can not seem to get any inforamtion from my serial scanner (outputs data in ascii)
This is the code I use to establish a connection to the scanner
Code: Select all
Public Sub EstablishScannerConnection
BarcodeReader = 3
Dim ComSettings_Scanner As String = "COM " & ScannerPort & ",cs0,ds0,cd0,rs"
If DebugMode = 1 Then
Open Cons For Output As #DebugConsole
Print #DebugConsole, "Serial Settingas for Scanner"
Print #DebugConsole, ComSettings_Scanner
Close #DebugConsole
End If
Dim r1 As Integer = Open(ComSettings_Scanner For Random As #BarcodeReader)
If r1 <> 0 Then
If DebugMode = 1 Then
Open Cons For Output As #DebugConsole
Print #DebugConsole, "Serial Setting for Scanner"
Print #DebugConsole, "Error opening serial link "; r1
Close #DebugConsole
End If
Else
If DebugMode = 1 Then
Open Cons For Output As #DebugConsole
Print #DebugConsole, "Serial Setting for Scanner"
Print #DebugConsole, "Serial Scanner opened with no problems"
Close #DebugConsole
End If
End If
End Sub
and this is the code I have come up with to get the data from the Serial scannerCOM COM3:9600,N,8,1,cs0,ds0,cd0,rs
Serial Setting for Scanner
Serial Scanner opened with no problems
Code: Select all
Private Sub SelectSerialScanner
If LOC(BarcodeReader) = 0 Then
Open Cons For Output As #DebugConsole
Print #DebugConsole, "Data From Scanner"
Print #DebugConsole, "barcode Port number : "; BarcodeReader
Print #DebugConsole, "No Data Coming in from scanner"
Close #DebugConsole
Else
Open Cons For Output As #DebugConsole
Print #DebugConsole, "Data From Scanner"
Print #DebugConsole, "barcode Port number : "; BarcodeReader
Print #DebugConsole, "Receving data from scanner"
Close #DebugConsole
End If
Do While LOC(BarcodeReader) > 0
Buffer = ""
buffer = Input(1,BarcodeReader)
If buffer <> Chr(Val(ScannerPrefix)) Then
dim a as string = buffer
dim result as string
For x as integer = 0 to len(a) -1
If instr(chr(a[x]),any "0123456789" & Chr(Val(ScannerPrefix))) then
result += chr(a[x])
End If
Next x
datareceived += result
End If
'If DebugMode = 1 Then
Open Cons For Output As #DebugConsole
Print #DebugConsole, "Data From Scanner"
Print #DebugConsole, datareceived
Close #DebugConsole
'End If
If buffer = Chr(Val(ScannerPrefix)) Then 'tells NPoS the scanner is done
If RemoveNumber > 0 then
Dim Temp as string = mid$(datareceived, RemoveNumber, len(datareceived))
datareceived = ""
datareceived = Temp
End If
ScannerFucntionSub(datareceived)
datareceived = ""
End If
Loop
End Sub
Private Sub ScannerFucntionSub(ByVal BarcodeNumber As String)
datareceived = ""
Buffer = ""
Select Case ScannerFucntion
Case "SaleScreen"
SubTotalPressed = 0
FindProduct(BarcodeNumber)
Case "Salescreen_PriceCheck"
FindProduct_PriceCheck(BarcodeNumber, "SaleScreen")
Case "SignedOff_PriceCheck"
FindProduct_PriceCheck(BarcodeNumber, "SignedOff_PriceCheck")
Case "GiftCard"
End Select
end Sub