Question Problems with receiving data from a 2D barcode reader

EM82

New member
Joined
Sep 27, 2014
Messages
1
Programming Experience
1-3
Good afternoon,
I am relatively new to VB.NET programming, and right now, I am in a bit of a pinch regarding a problem I am having.

I am trying to create a VB application to take the data read by an Ethernet-integrated 2D Barcode Reader and show them onscreen. The scanner in question is a Datalogic Matrix 210.

However, in spite of the fact that I can connect with the reader itself via IP address, I find myself not getting anything from the readings. I'll include the code I've written for your convenience:


OOOOOOOOOO
Imports System.Net
Imports System.Net.Sockets
Imports System.Text.UTF7Encoding


Public Class Form1


    Dim server As TcpListener
    Dim client As TcpClient
    Dim NetStream As NetworkStream


    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        


    End Sub


    Private Sub ButtonConnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonConnect.Click
   client = New TcpClient

   Try
      Application.DoEvents()
      client.Connect(TextBoxIP.Text, 51235)
   Catch ex As Exception
   MsgBox("Connection failed.", MsgBoxStyle.Critical, "Error")
   End Try
        
   If client.Connected Then
      MsgBox("Connection achieved.", MsgBoxStyle.Information, "Info")
      NetStream = client.GetStream
      DataTimer.Enabled = True
      DataTimer.Interval = 2000
      DataTimer.Start()
      ButtonConnect.Enabled = False
        
   End If
    End Sub




    Private Sub ButtonSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonSend.Click
   Dim t() As Byte = UTF7.GetBytes(TextBoxInput.Text)
   NetStream.Write(t, 0, t.Length)
    End Sub




    Private Sub DataTimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DataTimer.Tick
   If client.Available > 0 Then
      Dim d(client.Available - 1) As Byte
      NetStream.Read(d, 0, d.Length)
      Dim strings As String = UTF7.GetString(d)
      TextBoxOutput.Text += vbCrLf & strings & "..."
   End If
    End Sub

End Class


OOOOOOOOOO

I never get anything to show onscreen because client.Available is always 0, even when I place a barcode in front of the reader - and when using the scanner operative program on my PC, I always get the right results instead. Can you tell me what am I doing wrong with this particular application? How should I modify the code to print what the scanner reads in my TextBoxOutput? If possible, could you suggest me a different solution for getting a data stream from the barcode reader?

Thank you very much for your help.
 
Last edited by a moderator:
Back
Top