Shop OBEX P1 Docs P2 Docs Learn Events
An Easy One — Parallax Forums

An Easy One

SteveWoodroughSteveWoodrough Posts: 190
edited 2012-12-03 16:32 in Propeller 1
This one is easy, just hard for me.

I’m experimenting with Tim Moores PC Full Duplex Serial 4FC getting data from a GPS and sending to an LCD or PST, etc.

The sample original program had a line like this.
cog := cognew(BackGround,@stack) + 1                  'Start the background Cog  

pub BackGround
'Process gps and camera receive characters
'minimize processing in this cog, i.e. dont send to serial ports e.g. debug
'dont call waitcnt, etc. Dont call blocking receives from serial ports - use rxcheck
  repeat
    
    gps.GetNMEALine

As I looked through the GPS_IO “GPS.” object I saw a method that read
PUB readNEMA
' if start is called this processes reads from GPS on a COG
  repeat
    GetNMEALine
      
So I got the bright idea to change the cog start from above to:
cog := cognew(gps.readNEMA,@stack) + 1      
OF course that does not work, but I do not understand why. The functioning first version starts a local method in another cog and that method repeats a method from a referenced object, GetNMEALine.
The non-functioning second approach starts a referenced object method in another cog, and that referenced object method repeatedly references another method within the same referenced object.

In theory, both are going to the same place, but the first works and the second does not.

Hopefully this all makes sense. I’ve attached the basic code.

Thank You! Steve

Comments

  • kuronekokuroneko Posts: 3,623
    edited 2012-12-02 19:28
    cog := cognew(gps.readNEMA,@stack) + 1      
    
    This would start a PASM cog if gps.readNEMA were ever going to return a result. As this method is stuck in an endless loop the cognew is stuck as well. Starting a SPIN cog requires a single method without object notation.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-12-02 19:51
    I’m experimenting with Tim Moores PC Full Duplex Serial 4FC

    Tracy Allen cleaned up Tim's code and fixed a few bugs. Here's Tracy's improved object.

    Attempting to put what kuroneko stated in my more simplistic words. Don't use "cognew" across objects.
  • SRLMSRLM Posts: 5,045
    edited 2012-12-02 23:16
    Although you should be able to wrap the gps.readNEMA in a local function, and use that in the cognew.
  • SteveWoodroughSteveWoodrough Posts: 190
    edited 2012-12-03 16:32
    Thanks guys. I thought I was paying attention all these years, and repeatedly discover that what I don't know would fill a very large bucket.
Sign In or Register to comment.