Shop OBEX P1 Docs P2 Docs Learn Events
What am I doing wrong? — Parallax Forums

What am I doing wrong?

bboy8012bboy8012 Posts: 153
edited 2007-12-26 04:28 in Propeller 1
Frustrated beyond believe!
 
CON
  _clkmode = xtal1 + pll16x
  _xinfreq = 5_000_000
  gpsTx = 21
  gpsRx = 20
  gpsBaud = 4800

                'GPS Commands
  GetInfo = $00 
  GetValid = $01
  GetSats = $02
  GetTime = $03
  GetDate = $04
  GetLat = $05
  GetLong = $06
  GetAlt = $07
  GetSpeed = $08
  GetHead = $09
VAR
  byte info[noparse][[/noparse]2], valid[noparse][[/noparse]1], sats[noparse][[/noparse]1], time[noparse][[/noparse]3], date[noparse][[/noparse]3]
  word heading[noparse][[/noparse]2], speed[noparse][[/noparse]2], alt[noparse][[/noparse]2], lat[noparse][[/noparse]5], lon[noparse][[/noparse]5] 
OBJ
  uart  :       "Simple_Serial"
  debug :       "FullDuplexSerial"
PUB Delay(mS)
  waitcnt((clkfreq / 1000 * mS) + cnt)
PUB main
  debug.start(31, 30, 0, 19200)
  waitcnt (1_000_000 * 25 + cnt )
  
  uart.start(gpsRx, gpsTx, gpsBaud)
  waitcnt (1_000_000 * 25 + cnt )
  
  repeat
    uart.tx(String("!GPS"))
    uart.tx(GetInfo)
    
     info := uart.rx
    debug.str(@info)
    debug.str(13)
    debug.str(10)

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Hunger hurts, starvation works!

Comments

  • deSilvadeSilva Posts: 2,967
    edited 2007-12-25 09:25
    .rx receives just ONE BYTE, not a string.
    SimpleSerial does not buffer any bytes, so you will generally miss data when using speeds above - say - 300 baud.
    You generally use .rx in a tight loop (you have around 5 to 10 simple SPIN lines during the 9600 baud stop-bit time slot - no calling routines or such!)
    You can also use a separate COG for that loop.
    In that situation however you should use "FullDuplex", which does exactly that. FullDuplex can be instantiated multiple times.

    ---
    Edit: Are you really sure, the GPS commands are binary? Would be strange...

    Post Edited (deSilva) : 12/25/2007 9:31:20 AM GMT
  • bboy8012bboy8012 Posts: 153
    edited 2007-12-25 16:27
    I thought that was the Hex

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Hunger hurts, starvation works!
  • rjo_rjo_ Posts: 1,825
    edited 2007-12-25 18:45
    Your are in Smart mode... so raw is left floating. Correct?

    Rich
  • rjo_rjo_ Posts: 1,825
    edited 2007-12-25 19:32
    this code by Gary Boone works in smart mode... I have 660 ohm in line between sio and the pin...
    http://forums.parallax.com/forums/default.aspx?f=25&m=195562
  • deSilvadeSilva Posts: 2,967
    edited 2007-12-25 21:37
    o.k. good piece of software from Gary.

    @bboy: So most of my criticism was rather principally than to the point; what is left is:
    Change:
    debug.str(@info)
    


    by
    debug.hex(info)
    
  • bboy8012bboy8012 Posts: 153
    edited 2007-12-26 04:28
    Thanks for the help

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Hunger hurts, starvation works!
Sign In or Register to comment.