Question text file parse to xml questions

dstylesunf

Member
Joined
Jan 4, 2010
Messages
6
Programming Experience
10+
Here is my problem I'm trying to solve:

I have a robot which via a serial connection passes the following data which I log in hyperterminal into a txt file:

+++ASP:273,THH:0,RLL:0,PCH:0,***
+++ASP:37,THH:0,RLL:60,PCH:2,***
+++ASP:27,THH:0,RLL:60,PCH:0,***
+++ASP:19,THH:0,RLL:60,PCH:0,***
!!!LAT:32259464,LON:-110823520,SPD:0.00,CRT:0.00,ALT:0,ALH:65535,CRS:0.00,BER:0,WPN:0,DST:0,BTV:4.39,RSP:0,***


I want to grab the line starting with !!! and I only need the lat and lon data. I then need to pass this information into a string and add a . after the first two numbers so the format can be accepted by any mapping software such as google earth. Once I have the lat and lon in the proper format I want to make a simple kml file to import into google earth. The above data is repeated every second from the gps module in the robot so I'll need to loop this process every second. I use vb.net framework 3.5

Thanks for any help.
 

newguy

Well-known member
Joined
Jun 30, 2008
Messages
611
Location
Denver Co, USA
Programming Experience
1-3
This is a start for ya:
VB.NET:
Dim str() As String
Using sr As New StreamReader("myFilepath")
   While Not sr.EndOfStream
      If sr.Readline.StartsWith("!") Then
         str = sr.Readline.Split(",")
      End If
   End While
End Using

Dim lat As String = str(0).Substring(7)
Dim lon As String = str(1).Substring(4)
You can use the Insert method to add the "."
 
Last edited:

dstylesunf

Member
Joined
Jan 4, 2010
Messages
6
Programming Experience
10+
Alright thanks for the post NEWGUY this got me started on the right track. Here is some problems I am having. The method of which I get the text file is via hyperterminal capturing the data and producing an ever updating text file. When I run the above code an exception is thrown stating the file is in use by hyperterminal. Well this is not good since I have to be able to open the file whilst it is still being updated. So some help here would be greatly appreciated. Secondly, the data coming through hyperterminal constantly repeats the above lines so i'm going to need the code to read the last line of the text file to look for the !!!.

My thought for opening the text file is to use a timer and open the file on a tick say every second and then close it. Is this advisible? Thanks for any help.
 

newguy

Well-known member
Joined
Jun 30, 2008
Messages
611
Location
Denver Co, USA
Programming Experience
1-3
Can you teach the robot to overwrite the text instead of appending it?
 

dstylesunf

Member
Joined
Jan 4, 2010
Messages
6
Programming Experience
10+
Well the current setup up is a virtual serial port via tcp rfc 2217 protocal. The robot has a hp mini 1000 on it that uses com 7 to recieve the serial data and via a cellular modem sends it tcp to the clients machine which then via the 2217 protocal uses a virtual serial port to receive the data stream. The only way I know to capture the stream is through a terminal program like hyperterminal but if there is an easier way I'm all ears.
 
Top Bottom