Hello Erel!
Here the code, which i take the data from the server:
If I don't take the data for perhaps two minutes, because i have selected another index in combobox2, i only can get the old data.
Sub Globals
Dim Type (Lat,Lon,HemLat,HemLon) Ziel
Dim Type (Lat,HemLat,Lon,HemLon,Geschwindigkeit,Kurs) Array_NMEA
..
end sub
Sub App_Start
GPS_Server.New1
..
end sub
'Create the server-connection, when button is clicked'
Sub Button4_Click
ErrorLabel(noconnection)
WaitCursor(true)
client.New1 'init Client-Objekt'
IP_Adresse=textbox18.Text
Port_Nummer=textbox19.Text
Client.Connect (IP_Adresse,Port_Nummer)
If timer2.Enabled=false Then timer2.Enabled = true
'I have tested the Timer with 2000, 1000 and 500 ms'
WaitCursor(false)
Return
noconnection:
..
End Sub
'Takes the data from the server'
Sub Timer2_Tick
ErrorLabel(connectionbreak)
if ComboBox2.SelectedIndex = 1 then
If client.DataAvailable=true Then
Image4.LoadPicture("IconDaten1.bmp")
filestream.New1(client.GetStream,false)
GPS_Server.GPSStream(filestream.ReadString)
Else
Image4.LoadPicture("IconDaten2.bmp")
End If
End If
Return
connectionbreak:
..
client.close
End Sub
'Read the GPS_Server-bufferstring'
Sub GPS_Server_GPSDecoded
ErrorLabel(GPS_Server_Fehler)
If GPS_Server.status="A" Then
Image3.LoadPicture("IconSat1.bmp")
Else
Image3.LoadPicture("IconSat2.bmp")
End If
Ziel.Lat=GPS_Server.DecimalLatitude
Ziel.HemLat=GPS_Server.LatitudeHemisphere
Ziel.Lon=GPS_Server.DecimalLongitude
Ziel.HemLon=GPS.LongitudeHemisphere
'Save the GPS-data from Server to create a NMEA-protocoll'
Array_NMEA.Lat=GPS_Server.Latitude
Array_NMEA.HemLat=GPS_Server.LatitudeHemisphere
Array_NMEA.Lon=GPS_Server.Longitude
Array_NMEA.HemLon=GPS_Server.LongitudeHemisphere
Array_NMEA.Geschwindigkeit=GPS_Server.SpeedOverGro und
Array_NMEA.Kurs=GPS_Server.CourseOverGround
Label11.Text=Round(GPS_Server.SpeedOverGround * 1.852)
Label20.Text=Round(GPS_Server.Altitude) & "(" & (Round(GPS_Server.Altitude)-Round(GPS.Altitude)) & ")"
Return
GPS_Server_Fehler:
End Sub
'Close server-connection'
Sub Button3_Click
client.Close
If timer2.Enabled=true Then timer2.Enabled=false
Image3.LoadPicture("IconSat2.bmp")
Image4.LoadPicture("IconDaten2.bmp")
End Sub
'Generate a NMEA-protokoll (GPRMC) an send it to a serial COM.port'
Sub Timer3_Tick
NMEA="$GPRMC," & Time(Now) & ",A," & Array_NMEA.Lat & "," & Array_NMEA.HemLat & "," & Array_NMEA.Lon & "," & Array_NMEA.HemLon & "," & Array_NMEA.Geschwindigkeit & "," & Array_NMEA.Kurs & "," & Date(Now) & ",0.4,E,A*"
'Berechnung der Prüfsumme'
buffer() = bit.StringToBytes(NMEA,1,StrLength(NMEA)-2)
laenge=ArrayLen(buffer())
Summe=buffer(0)
For i=1 To laenge-1
Summe=bit.XOR(summe,buffer(i))
Next
Pruefsumme=bit.DecToHex(Summe)
'Pruefsumme am NMEA-Protokoll anhängen'
NMEA=NMEA & Pruefsumme & crlf
serial_output.Output(NMEA)
End Sub


