When method calls fail... *** RESOLVED!
Sniper King
Posts: 221
In the software I am writing i am having trouble with method calls.· Everything is fine until a certain criteria is met then when I call the method I need to use the chip crashes.· if I move all the method's code to the loop I am running, it works.· Move it back and it fails. ·Anybody else have this problem
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·- Ouch, thats not suppose to be hot!··
Michael King
Application Engineer
R&D
Check out Project: PSAV Persistent Sailing Autonomous Vehicle
Post Edited (Sniper King) : 9/24/2008 4:22:44 PM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·- Ouch, thats not suppose to be hot!··
Michael King
Application Engineer
R&D
Check out Project: PSAV Persistent Sailing Autonomous Vehicle
Post Edited (Sniper King) : 9/24/2008 4:22:44 PM GMT
Comments
-Phil
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
'Still some PropSTICK Kit bare PCBs left!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·- Ouch, thats not suppose to be hot!··
Michael King
Application Engineer
R&D
Check out Project: PSAV Persistent Sailing Autonomous Vehicle
·
Personally I would create an array in the VAR section, to allocate some space. Something like
·
·
·
Then use that as you ‘string buffer’. It seems to me that your stomping on something because your buffer is not defined.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Mike
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·- Ouch, thats not suppose to be hot!··
Michael King
Application Engineer
R&D
Check out Project: PSAV Persistent Sailing Autonomous Vehicle
Also, don't forget that, when you allocate arrays as local variables, they're always allocated as longs and the space is allocated in the stack. If you don't allow for that space, the stack will eventually run out of space, particularly when you may have video buffers in the high end of memory.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·- Ouch, thats not suppose to be hot!··
Michael King
Application Engineer
R&D
Check out Project: PSAV Persistent Sailing Autonomous Vehicle
BUf1 is a long, set to 0 , byte[noparse][[/noparse]buf1+x] is writing to first 8 bytes of memory (i.e. byte at location 0+7) - really what you want?
Similar questio about buf3 in the other routine
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·- Ouch, thats not suppose to be hot!··
Michael King
Application Engineer
R&D
Check out Project: PSAV Persistent Sailing Autonomous Vehicle
-Phil
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
'Still some PropSTICK Kit bare PCBs left!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·- Ouch, thats not suppose to be hot!··
Michael King
Application Engineer
R&D
Check out Project: PSAV Persistent Sailing Autonomous Vehicle
bytefill(address, 0, size) - address is address of first byte of memory buffer, size is no of bytes
e.g.
byte buf[noparse][[/noparse]20]
bytefill(@buf,0,20)
2nd problem is that buf1 and buf4 are longs and not byte array so they are 4 bytes in size and writing 8 bytes will cause problems
you can't define byte locals, so
pub SendFix :Value· |buf[noparse][[/noparse]20],BUF1 , x· , j
buf1:=@buf
bytefill(buf1,0,80)
buf[noparse][[/noparse]20] defines array 20 longs - which is 80 bytes.
buf1:=@buf puts address of 1st byte of buf in buf1 which looks like it would work for the rest of your code.
Change the 20 to the size you need - take size in bytes round up to next 4 and divide by 4. Make sure you set array size and bytefill size to same.
You need to do something similar for the other routine.
Also this allocates the 20 longs on the stack for the cog, so if it isn't on the main cog make sure the stack size is large enough
A couple questions, if you don't mind:
1. is this mission-critical software that lives depend on?
2. Are you working against a tight deadline?
-Phil
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
'Still some PropSTICK Kit bare PCBs left!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·- Ouch, thats not suppose to be hot!··
Michael King
Application Engineer
R&D
Check out Project: PSAV Persistent Sailing Autonomous Vehicle
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·- Ouch, thats not suppose to be hot!··
Michael King
Application Engineer
R&D
Check out Project: PSAV Persistent Sailing Autonomous Vehicle
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·- Ouch, thats not suppose to be hot!··
Michael King
Application Engineer
R&D
Check out Project: PSAV Persistent Sailing Autonomous Vehicle
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·- Ouch, thats not suppose to be hot!··
Michael King
Application Engineer
R&D
Check out Project: PSAV Persistent Sailing Autonomous Vehicle
Which particular variables are being over-written ? That could give a better idea of where to look.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·- Ouch, thats not suppose to be hot!··
Michael King
Application Engineer
R&D
Check out Project: PSAV Persistent Sailing Autonomous Vehicle
Everything works except this....
·here is the atoi method.· This takes a string and makes in an integer
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·- Ouch, thats not suppose to be hot!··
Michael King
Application Engineer
R&D
Check out Project: PSAV Persistent Sailing Autonomous Vehicle
I am still stomping on memory I think.· The getcoords routine worked before and now it fails the math.· I have been all over this software and I can't find the problem.· Can running multiple FullDuplexSerial objects create memory stomping issues?· That and the cog I start with the GPS_IO_mini_PNAV object regarding the GPS_stack variable.· I just don't know and I am getting depressed and code tired (it all looks the same)!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·- Ouch, thats not suppose to be hot!··
Michael King
Application Engineer
R&D
Check out Project: PSAV Persistent Sailing Autonomous Vehicle
You need to take a short break, then go through the whole program line by line and use a highlighter for any line that uses a pointer or an array subscript that's not a constant, then go back and stop at each highlighted line and ask yourself whether that line can overstore something that it shouldn't. If so, either insert some kind of consistency check or rewrite that portion of the routine. Get a friend to help you. Sometimes they'll ask the "stupid question" that will identify a piece of broken code. This sounds tedious and it is, but may be the way to get this working.
As Mike says I would walk through this code with a specific example, writing down what you expect each buffer to be. If you still can't see the problem, then add print statements of each buffer comparing with what you expect.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·- Ouch, thats not suppose to be hot!··
Michael King
Application Engineer
R&D
Check out Project: PSAV Persistent Sailing Autonomous Vehicle
and add j to the list of local args. This 1: uses different variables from the code so debug doesn't change the· code behavour and 2: prints the buffer as separate chars in hex (use help->char char ("0" is $32, etc)) so you can see what is happening even if the buffer contains non-printable chars
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·- Ouch, thats not suppose to be hot!··
Michael King
Application Engineer
R&D
Check out Project: PSAV Persistent Sailing Autonomous Vehicle