Jump to content

Find text of TCP Recieved


Recommended Posts

Well Right now I want to find channel 1 and go right far enough to grab the first value, and same with channel 2. Right now What I got is obtain through counting, but I don't want to do that in the future. So is there a way I can use the StringinStr function to do it, all my attempts have failed. Here are the example codes of what I want it to look like in the future.

The Server is the thing we need to work on right now I just got it to barely work but this isn't the method i wish to use:

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

Global $hGUI, $TCPAccept = 10, $TCPListen, $TCPPrevious = 255, $TCPRecv
TCPStartup()
$port = 5000
$TCPListen = TCPListen(@IPAddress1, $port)

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Server", 148, @DesktopHeight, 0, 0)
$Label1 = GUICtrlCreateLabel("Server IP: ", 8, 8, 54, 17)
$Label2 = GUICtrlCreateLabel("Connected Port:", 8, 40, 81, 17)
$Label3 = GUICtrlCreateLabel("Recieved Data: ", 8, 72, 82, 17)
$Label4 = GUICtrlCreateLabel("Label4", 8, 24, 132, 17)
$Label5 = GUICtrlCreateLabel("Label5", 8, 56, 132, 17)
$Label6 = GUICtrlCreateLabel("Waiting For Connections...", 8, 88, 132, @DesktopHeight)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
GUICtrlSetData($Label4, @IPAddress1)
GUICtrlSetData($Label5, $port)

Do
    $TCPAccept = TCPAccept($TCPListen)
Until $TCPAccept <> -1

GUICtrlSetData($Label6, "Connection Open")

While 1
    $TCPRecv = TCPRecv($TCPAccept, 1000000)
    If $TCPRecv <> "" And $TCPRecv <> $TCPPrevious Then
        $TCPPrevious = $TCPRecv
        If $TCPPrevious > $TCPPrevious +1 Then
            Do
                $TCPPrevious = $TCPPrevious + 1
            Until $TCPPrevious = $TCPRecv
        EndIf
        If $TCPPrevious < $TCPPrevious -1 Then
            Do
                $TCPPrevious = $TCPPrevious - 1
            Until $TCPPrevious = $TCPRecv
        EndIf
        Local $freq1 = StringMid($TCPRecv, 18, 13)
        Local $freq2 = StringMid($TCPRecv, 95, 13)
        GUICtrlSetData($Label6, Number($freq1) & @CRLF & Number($freq2))
    EndIf
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

This is just an emulation of the actual values I'm going to get all the values are the same StringLen so you can use that if you like.

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

TCPStartup()
$TCPConnect = TCPConnect(@IPAddress1, 5000)

$Form1 = GUICreate("Test", 105, 37, 192, 114)
$Button1 = GUICtrlCreateButton("Click Me!", 8, 8, 83, 17)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            TCPSend($TCPConnect, "channel1"&@crlf&"freq="&@crlf&"9.426686e+010"&@crlf&"1.923659e+010"&@crlf&"1.190006e+010"&@crlf&"1.557381e+010"&@crlf&"channel2"&@crlf&"freq="&@crlf&"1.300763e+011"&@crlf&"2.108867e+009")
    EndSwitch
WEnd
Edited by Klovis
Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...