Basic4ppc - Windows Mobile Development  

Go Back   Basic4ppc - Windows Mobile Development > Main Category > Questions & Help Needed
Home Register FAQ Members List Search Today's Posts Mark Forums Read

Questions & Help Needed Post any question regarding Basic4ppc.


Read NMEA from Server


Reply
 
LinkBack Thread Tools Display Modes
  #21 (permalink)  
Old 02-09-2008, 11:27 AM
schimanski's Avatar
Knows the basics
 
Join Date: Oct 2007
Location: Germany
Posts: 63
Default same problem

"Does your app make the assumption that a full message always arrives as a single read?"

Hello agraham!

Thanks for answer. But I know, that even can arrive small messages. In my application, the GPSStream collects the parts of the NMEA, so that I have every 4 seconds a new protocol, when the server sends every 2 seconds. That operates very fine (the image is only 15x15 pixels, so I think, it doesn’t matter):

Sub Timer2_Tick
ErrorLabel(connectionbreak)
If ComboBox2.SelectedIndex = 1 Then
If client.DataAvailable=true Then
Image4.LoadPicture("IconDaten1.bmp")
GPS_Server.GPSStream(filestream.ReadString)
Else
Image4.LoadPicture("IconDaten2.bmp")
End If
Else If client.DataAvailable Then
fileStream.ReadString
End If
Return

connectionbreak:
..
client.close
End Sub

When the timer is bigger than 500, I will take in backlog. So I only can get older data. I can see that, when I take a look at the UTC-Time. The different between the UTC-Time from the protocol which the server sends and the UTC-Time in the GPS_Server_GPSDecoded-sub runs up.
The connectionbreak is only called, when the GPRS-connection breaks down.

When the timer2 is 1000 and smaller and the server sends no data, the app stops, before there is a reaction on client.dataAvailable<>true.

Reply With Quote
  #22 (permalink)  
Old 02-16-2008, 11:07 AM
schimanski's Avatar
Knows the basics
 
Join Date: Oct 2007
Location: Germany
Posts: 63
Default delete the filestream

Hello again!

I haven't found an answer on my problem, so i have one new idea:

With the following sub, i take the data from the server. When the timer2_tick is 2000, the application runs fine, but I will take in backlog. So I only can get older data. I can see that, when I take a look at the UTC-Time. The different between the UTC-Time from the protocol which the server sends and the UTC-Time in the GPS_Server_GPSDecoded-sub runs up.
But I think, that it is not possible to read from the filestream every half or one second, because the server sends only every two seconds. Now my idea:

Is it possible to reset the filestream every read, so that i will not take in backlog and only take the new data?


Sub Timer2_Tick
ErrorLabel(connectionbreak)
If ComboBox2.SelectedIndex = 1 Then
If client.DataAvailable=true Then
Image4.LoadPicture("IconDaten1.bmp")
GPS_Server.GPSStream(filestream.ReadString)
Else
Image4.LoadPicture("IconDaten2.bmp")
End If
Else If client.DataAvailable Then
fileStream.ReadString
End If
Return

connectionbreak:
..
client.close
End Sub

Reply With Quote
  #23 (permalink)  
Old 02-16-2008, 11:35 AM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 1,770
Awards Showcase
Beta Tester Forum Contributer 
Total Awards: 2
Default

If a backlog is building up then multiple messages must be available. Instead of just doing a single read try clearing the backlog with a Do While .. Loop.

Code:
Sub Timer2_Tick
  ErrorLabel(connectionbreak)
  If ComboBox2.SelectedIndex = 1 Then
    If client.DataAvailable Then
      Do While eclient.DataAvailable 
        GPS_Server.GPSStream(filestream.ReadString)
      Loop
      Image4.LoadPicture("IconDaten1.bmp")
    Else
      Image4.LoadPicture("IconDaten2.bmp")
    End If
  Else 
    Do While client.DataAvailable 
      fileStream.ReadString
    Loop
  End If
  Return
  connectionbreak:
  ..
  client.close
End Sub
Reply With Quote
  #24 (permalink)  
Old 03-18-2008, 10:58 AM
schimanski's Avatar
Knows the basics
 
Join Date: Oct 2007
Location: Germany
Posts: 63
Default where is the mistake?

This is my code, the same problem as my last posts. A simple code but it doesn' work:

Sub App_Start
Form1.show
client.New1
client.Connect("217.91.33.???,55355)
filestream.New1(client.getstream,false)
timer1.Enabled=true
End Sub

Sub timer1_Tick
if client.DataAvailable=true then
Label1.Text=filestream.readstring
else
Label1.Text="no data"
end if
End Sub


The server sends only string as NMEA (RMC and GGA) every two seconds. When i block the gate from the server, so that there is no data sending, the application blocks in this line: Label1.Text=filestream.readstring. Than, there is no chance to end the application or even push a button. I have tested it with different timer from client and server, but it always stops in filestream.readstring. When I open the gate, the application will continue without problems.
I have spoken with the author from the server-code. He says, that there is shure no data, when the gate is blocked. He says, that the filestream.readstring is a blocked function. It waits until there is any data. But i can't catch the mistake with client.dataavailable. Is it possible, that there is a different between reading the filestream until it is emty and read from a filetream, that is emty from the beginning? Because, if i read a full filestream until it is emty, then Label1.text shows "no data".
When I connect to a port, where is no data from the beginning, the application stops an locks up until I gi´ve data to the stream.



I think, that i will fall into despair....
Reply With Quote
  #25 (permalink)  
Old 03-18-2008, 11:10 AM
schimanski's Avatar
Knows the basics
 
Join Date: Oct 2007
Location: Germany
Posts: 63
Default

Quote:
Originally Posted by schimanski View Post
This is my code, the same problem as my last posts. A simple code but it doesn' work:

Sub App_Start
Form1.show
client.New1
client.Connect("217.91.33.???,55355)
filestream.New1(client.getstream,false)
timer1.Enabled=true
End Sub

Sub timer1_Tick
if client.DataAvailable=true then
Label1.Text=filestream.readstring
else
Label1.Text="no data"
end if
End Sub


The server sends only string as NMEA (RMC and GGA) every two seconds. When i block the gate from the server, so that there is no data sending, the application blocks in this line: Label1.Text=filestream.readstring. Than, there is no chance to end the application or even push a button. I have tested it with different timer from client and server, but it always stops in filestream.readstring. When I open the gate, the application will continue without problems.
I have spoken with the author from the server-code. He says, that there is shure no data, when the gate is blocked. He says, that the filestream.readstring is a blocked function. It waits until there is any data. But i can't catch the mistake with client.dataavailable. Is it possible, that there is a different between reading the filestream until it is emty and read from a filetream, that is emty from the beginning? Because, if i read a full filestream until it is emty, then Label1.text shows "no data".
When I connect to a port, where is no data from the beginning, the application stops an locks up until I gi´ve data to the stream.



I think, that i will fall into despair....


I have tested more: when i open and close then gate from the server a lot of times, sometimes the application blocks and sometimes the label1.text shows "no data". I think, the is a different between the amount of data...
Reply With Quote
  #26 (permalink)  
Old 03-18-2008, 11:54 AM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 1,770
Awards Showcase
Beta Tester Forum Contributer 
Total Awards: 2
Default

I don't understand your problems. I have used the Network library here Network "library" and on another app and it does not experience any blocking when no data is available.

It seems that your client.DataAvailable is returning true when there is no data to read, but I have not seen this behaviour myself

What I do notice is "filestream.New1(client.getstream,false)" is specifying that the stream encoding is UTF8. Is this in fact true? I would have thought it more likely that the server data was ASCII encoded. Could this be why filestream is blocking? It might be that there is data available but it is expecting more data than is actually available dueto the encoding difference.

EDIT :- Re-reading the thread you have said before that the app works OK when there is data so my encoding suggestion is probably wrong.

Last edited by agraham : 03-18-2008 at 11:56 AM.
Reply With Quote
  #27 (permalink)  
Old 03-18-2008, 12:34 PM
schimanski's Avatar
Knows the basics
 
Join Date: Oct 2007
Location: Germany
Posts: 63
Default The same problem with Network Demo

Hello agraham!

First I have tested it with filestream.new1(client.Getstream,true and false), but no different. I also have tested your Network Demo-Application. But This app only shows, that it ist connected with the server, but than, the application locks also up. This application doesn't work when there is data and also when there is no data. I have set the filestream.new1 on true and false, but no different. Is it possible to send you the original IP and port-no. to an email-adress? I can send data on this port for perhaps the next three hours.
Reply With Quote
  #28 (permalink)  
Old 03-18-2008, 12:50 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 1,770
Awards Showcase
Beta Tester Forum Contributer 
Total Awards: 2
Default

You can certainly PM it to me but unless the problem is with your server there probably isn't much point. I have tested my Network demo in all the combinations possible of a Dell Axim X30 running WM2003SE, a Compaq latptop running Windows XP and my dekstop running Vista Home Premium. If my Network demo locks up I think there must be some sort of bug or problem with whatever you are running your app on. Have you tried it on both a device and a desktop?
Reply With Quote
  #29 (permalink)  
Old 03-18-2008, 12:59 PM
schimanski's Avatar
Knows the basics
 
Join Date: Oct 2007
Location: Germany
Posts: 63
Default Private message to you

i have send a private message with the IP and port to you. I have tested the application on three different devices, not on the desktop. I don't think, that there is a problem with basic4ppc or your application Network Demo. I think, that i have overlook something by the data format from the server.

Reply With Quote
  #30 (permalink)  
Old 03-18-2008, 01:10 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 1,770
Awards Showcase
Beta Tester Forum Contributer 
Total Awards: 2
Default

Hmmm! I'm connecting to your server and I'm getting the same effects as you have desribed and I don't understand it I'll play a bit more.
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
One server adn more clients Byak@ Questions & Help Needed 2 08-12-2008 11:59 AM
Comunicating with a Telnet Server lu_ozzie Questions & Help Needed 16 05-05-2008 06:25 PM
Simple NMEA logger Bruno Share Your Creations 0 05-02-2008 08:43 PM
Checksum in nmea wolfgang Code Samples & Tips 0 02-15-2008 02:42 PM
New server Erel Forum Discussion 12 11-06-2007 05:21 PM


All times are GMT. The time now is 04:33 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.1.0