Visualizzazione dei risultati da 1 a 2 su 2
  1. #1

    extract data from equipment connected in TCP IP ethernet

    Hello, I need to get data from a datamatrix code reader connected to a PC through the ethernet port and a TCP IP address.

    I set everything up and tried to see if the device works with the Hercules program, and in fact I see the data read,

    But I should build an application in that uses this data, so when a code passes under the laser I should intercept it in my application.

    I tried with various sockets but I can't, as long as it is chat it works but capturing the data from the device nothing.

    Below is the code of the client which, however, sends what is in the textbox. Instead I would like it to send what I read from the 2D code reader which is always active.

    codice HTML:
    Imports System.Net, System.Net.Sockets
    Imports System.Text.ASCIIEncoding
    Public Class frm_Client
        Dim client As Socket
        Dim host As String = "" '"" 
        'Dim port As Integer = "6969" '"51236"
        Dim port As Integer = "51236"
        Private Sub frm_Client_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        End Sub
        Private Sub btnConnect_Click(sender As Object, e As EventArgs) Handles btnConnect.Click
            client = New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
            Dim IP As IPAddress = IPAddress.Parse(host)
            Dim xIpEndPoint As IPEndPoint = New IPEndPoint(IP, port)
            client.BeginConnect(xIpEndPoint, New AsyncCallback(AddressOf OnConnect), Nothing)
            btnConnect.Enabled = False
        End Sub
        Private Sub btnSend_Click(sender As Object, e As EventArgs) Handles btnSend.Click
            Dim bytes As Byte() = ASCII.GetBytes(txtMessage.Text)
            client.BeginSend(bytes, 0, bytes.Length, SocketFlags.None, New AsyncCallback(AddressOf OnSend), client)
        End Sub
        Private Sub OnConnect(ByVal ar As IAsyncResult)
        End Sub
        Private Sub OnSend(ByVal ar As IAsyncResult)
        End Sub
    End Class

  2. #2
    Moderatore di Programmazione L'avatar di alka
    Registrato dal
    Oct 2001
    Reggio Emilia
    Questo è un forum in lingua italiana: per favore, se apri una discussione, descrivi il problema in italiano affinché possa essere accessibile a qualsiasi utente iscritto.
    Software and Web Developer, Teacher and Consultant

    Home | Blog | Delphi Podcast | Twitch | Altro...

Tag per questa discussione

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
Powered by vBulletin® Version 4.2.1
Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.