Shop OBEX P1 Docs P2 Docs Learn Events
variable workspace in object and cog causes crash — Parallax Forums

variable workspace in object and cog causes crash

glentechglentech Posts: 35
edited 2006-09-26 12:46 in Propeller 1
Can someone give me some idea why this program causes the video driver to crash?· Something I am doing is not right within the object.· I am trying to comunicate variables between cogs within the same object.· There doesn't seem to be much documentation in the manual on this.· I am building a trip computer and want to save the last odometer and fuel reading in the eeprom when the voltage is turned off.·(using a capacitor as the voltage drops)· I am posting my code here.· I am quite sure this is a variable workspace problem.

Comments

  • ALIBEALIBE Posts: 299
    edited 2006-09-25 14:23
    there was a thread last week around similar topic that Beau Schwabe went into some good detail. I can't seem to find that thread now.

    Beau, ?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ALIBE - Artificial LIfe BEing. In search of building autonoumous land robot

    http://fstop.crosscity.com/
    http://icar.crosscity.com/
    ·
  • Mike GreenMike Green Posts: 23,101
    edited 2006-09-25 14:50
    For a start, I would increase your stack sizes maybe 25% and see if that helps.

    In your main routine, you do a ReadLong(eeprom_addr, position, 16, 8). Are you reading from different locations in EEPROM set by the rotaryef cog? In any event, position doesn't seem to be initialized.

    These things are very hard to track down. Sometimes you have to eliminate parts of your program or substitute "fake" or random values for a cog that you've not started just to simplify things. Once you pare it down to a point where it runs again, you start adding back features or cogs until it breaks. Often it's an uninitialized variable or stack overflow or array index overflow.

    Good luck
  • David BDavid B Posts: 592
    edited 2006-09-25 14:56
    I've had occasional problems in my Propeller code when I got too casual with indentation in the code body, since indentation is used to designate code blocks.

    In Tripcomp, I see that "re.start" is indented 2, but the following "repeat" is indented three, then most of the "text" is indented 6, which should be fine, but the "if" following the "text" is only indented 5, which could be a problem.

    You might try following an exact indentation policy; it will be more readable, even if it isn't the problem.

    David
  • Paul BakerPaul Baker Posts: 6,351
    edited 2006-09-25 16:26
    Use Ctrl-I to visually show how the compiler is interpreting your indentation. For quick changes of indentation for multiple lines, highlight the lines (but dont include the CR-LF of the last line, IOW end your highlight to the end of the last line, not the begining of the next line), Tab will indent all selected lines, <shift>-Tab will outdent the selected lines (take away a Tab).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.
  • glentechglentech Posts: 35
    edited 2006-09-25 19:39
    I know what you are saying with stack and variable overflows but I have tried huge stack spaces. This program works until my last fuelmeasure cog tries to work. Its like the variables in the cog try to hold on to the original value of the variable. The voltage variable from the voltage cog is crossing over into my VSS cog and changing a complete different variable. The tripcomp obj is a testbed only to get the value returns. The screen will blank out but the leds on my board light up like the cogs are working somewhat. anyway what is the proper way to move variables in and out of methods running in their own cog within the same object. Or is it better to make diferent objects and move everything with pointers. I think i have the indentation thing right as i have been using the CTRL I but i will double check.
  • Jim FouchJim Fouch Posts: 395
    edited 2006-09-25 20:49
    The way I Update Vars in another cog is to first pass the location of a set of vars to the ned cog when it starts. Then I make a local copy of the same vars. When I want to change the vars in the first cog with the second cog I do a LongMove to the location I was passed in the second cog. I'm at work and can't show an example.

    It sounds like we're working on the same type of project....· ;-)

    Jim
  • glentechglentech Posts: 35
    edited 2006-09-26 12:46
    Thanks Jim. I finally figured it out. I was trying to do a long[noparse][[/noparse]xx] on a local variable along with not doing long[noparse][[/noparse]xx] on an outside of object variable with a pointer. I would like to see another chapter in the programming instructions dealing with variables as I had to sort of read between the lines in the manual to get much information on it. Aparently variables in a cog have to be dealt with like they are in their own object.
Sign In or Register to comment.