Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. .NET (Core and Framework)
  4. TCPIP SOCKET DATA RECEIVE FROM INSTRUMENT

TCPIP SOCKET DATA RECEIVE FROM INSTRUMENT

Scheduled Pinned Locked Moved .NET (Core and Framework)
csharpdata-structureshelptutorial
1 Posts 1 Posters 3 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    cws_ap
    wrote on last edited by
    #1

    Dear All I am sanding string to my instrument through tcpip socket protocol. String received at instrument correctly. I received string back from instrument also. but when i convert string in to hex value i get multiple Zero after my ETX (03)hex value.. can some one help me. code for your ref. is Dim PORT As Int32 = Txtport.Text Dim client As New TcpClient(Txtip.Text, PORT) Dim stream As NetworkStream = client.GetStream() ' Translate the passed message into ASCII and store it as a Byte array. Dim data As [Byte]() = System.Text.Encoding.ASCII.GetBytes(sndstr) stream.Write(data, 0, data.Length) ' Txtrt.Text = sndstr ' data rec. Timer1.Enabled = True Dim Bytes As Integer = -1 Dim Buffer(1024) As Byte Dim Message As String = "" Dim ClientStream As System.Net.Sockets.NetworkStream = client.GetStream Do While Bytes <> 0 Bytes = ClientStream.Read(Buffer, 0, Buffer.Length) Message = System.Text.Encoding.ASCII.GetString(Buffer) If Message.IndexOf("QE") <> -1 Then ' Found the end of the message... Exit Do End If Loop ' Message = Message.Trim(Message.Trim(Chr(0))) Txtrt.Text = Message Dim ba() As Byte Dim hexval As System.Text.StringBuilder = New System.Text.StringBuilder ba = System.Text.ASCIIEncoding.ASCII.GetBytes(Message) For i As Integer = 0 To ba.Length - 1 hexval.Append(ba(i).ToString("x2") & " ") Next RECEIVEDDATA.Text = (hexval.ToString()) I Rec. data 02 61 61 10 31 03 00 00 00 00 00 00 00 00 till the size of buffer my end of msg. is 03 how to remove all 00 after value 03

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups