Jump to content

Recommended Posts

Posted

Boa noite a todos

Estou com um teste para um projecto, onde pretendo comunicar com um plc, onde tem um servidor de tcp. Pretendo ler e enviar dados com esse servidor.

A escrita penso que está controlada, no entanto a leitura só funciona a primeira vez, logo a seguir a ter feito a ligação, depois não volta a actualizar os valores.

Obrigado

Sérgio

Posted

O código que estou a usar para ler é o seguinte:

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

        Dim sendBytes2(10) As Byte

   

        network.Flush()

        Dim bytes(Client.ReceiveBufferSize) As Byte

        network.Read(bytes, 0, 10)

        network.Flush()

        ListBox1.Items.Clear()

        For i = 0 To 19

            Application.DoEvents()

            ListBox1.Items.Add(bytes(i))

        Next

    End Sub

Obrigado

Sérgio

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.