NMEA parsing, serial interrupt?

Discussion about the ZBasic language including the System Library. If you're not sure where to post your message, do it here. However, do not make test posts here; that's the purpose of the Sandbox.
sturgessb
Posts: 287
Joined: 25 April 2008, 6:34 AM
Location: Norwich, UK

Post by sturgessb »

Quick question...

Is there any possibility that after writing to the zx many many times (i have probably flashed it thousands of times), that this would cause issues with its performance and continuity?

Only I'm getting some weird results with previously proven code.

Ben
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Post by dkinzer »

sturgessb wrote:Is there any possibility that after writing to the zx many many times (i have probably flashed it thousands of times), that this would cause issues with its performance and continuity?
The Flash memory (which contains your program's code) has a 10,000 write cycle specification. That doesn't mean that it quits working after 10,000 cycles; it means that problems may arise after that many cycles.
- Don Kinzer
GTBecker
Posts: 616
Joined: 17 January 2006, 19:59 PM
Location: Cape Coral

NMEA parsing, serial interrupt?

Post by GTBecker »

> ...10,000 write cycle...

When I attended an Atmel seminar a few years ago, we were told by design
engineers present that the specification is very conservative. In fact,
they said, 100,000 cycles is common and 1e6 cycles possible.

Tom
Tom
Don_Kirby
Posts: 341
Joined: 15 October 2006, 3:48 AM
Location: Long Island, New York

Post by Don_Kirby »

spamiam wrote:Since each GPS sentence stats with a "$", in your receive task you could pull data off the incoming queue until you hit a "$" at that point the previously recorded data must be a whole sentence, and you can transfer that string somewhere else and set a flag indicating the data is ready.
-Tony
This is the method I would pursue. Typically, I would discard all incoming data until I received the delimiting character (in this case the '$'). Then, buffer the data until another '$' is received. The buffer now contains a complete sentence (ignoring lost or incorrect data). At this point, you can either begin receiving data into the same or a different buffer until another '$' is received.

-Don
sturgessb
Posts: 287
Joined: 25 April 2008, 6:34 AM
Location: Norwich, UK

Post by sturgessb »

I'm trying the byte at a time version suggested but I cant seem to convert the Byte to a Char for the string. I have the following.

Code: Select all

Do
  Call GetQueue(com2RXQueue, GPS_byte, 1)
  GPS_string = GPS_string & Cstr(GPS_byte)
  If GPS_byte = Asc("$") then
    'Process the string here, and then clear
    GPS_string = ""
  End If
Loop
And if I write GPS_string to screen i get....

71
7180
718071
71807171
7180717165
718071716544
71807171654450
7180717165445050
718071716544505050
71807171654450505057
7180717165445050505748

etc etc. no Chars?

Then after a few seconds it goes to this....


...7180717165445050514852524654484844535051564653515557447844484849495546565148564469444944524452464952
718071716544505051485252465448484453505156465351555744784448484949554656514856446944494452445246495236
71
7136
71
7136
71
7136
71
7136
71
7136
71
7136
71
7136
71
7136
717136
71
7136
71

and on and on like that.

This Com Port stuff is doing my head in, I can't remember having any problems with this kindof last time I dealt with it. I'm really beginning to think this zx is dying.

Or am I just being a dunce?

[/code]
twesthoff
Posts: 247
Joined: 17 March 2006, 6:45 AM
Location: Fredericksburg, VA

NMEA parsing, serial interrupt?

Post by twesthoff »

ZBasic wrote:
I'm trying the byte at a time version suggested but I cant seem to convert the Byte to a Char for the string. I have the following.
Change this line to:
GPS_string = GPS_string & Chr(GPS_byte)

See if that works...

Code:
Do
  Call GetQueue(com2RXQueue, GPS_byte, 1)
  GPS_string = GPS_string & Cstr(GPS_byte)
  If GPS_byte = Asc("$") then
    'Process the string here, and then clear
    GPS_string = ""
  End If
Loop

dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Post by dkinzer »

sturgessb wrote:I cant seem to convert the Byte to a Char for the string. I have the following.
The CStr() function converts a value to the string equivalent. For example, if a byte has the value 105, the string returned by CStr() when passed that byte is "105". It sounds as if that is not what you intended here.

The function that you likely intended to use is Chr(). If passed the same 105 value described above, Chr() returns the single-character string "I". Note that Asc() and Chr() are inverse functions with respect to one another. The closest function that could be considered an inverse of CStr() is ValueS().
- Don Kinzer
sturgessb
Posts: 287
Joined: 25 April 2008, 6:34 AM
Location: Norwich, UK

Post by sturgessb »

Thanks!

ok so in this instance its probably me thats dying not the zx!
Post Reply