|
|
View previous topic :: View next topic |
Author |
Message |
Markdem
Joined: 24 Jun 2005 Posts: 206
|
Random CONST CHAR |
Posted: Thu Aug 20, 2020 8:55 pm |
|
|
I have got a problem I can't work out..
CCS = 5.025
I have the following:
Code: |
static char tokens_header[]=" ";
static char tokens_get[]="?";
static char http_get_str[]="GET";
static char http_post_str[]="POST";
static char http_len_str[]="Content-Length:";
|
Here is my issue.. (I am using a debugger to watch the values)
In the above code I will get "Content-Lengt+" saved in "http_len_str[]"
If I remove static, it works fine.
If I put "http_len_str[]" at the top of the list it will be fine, but then what is at the bottom will have 2 extra chars. Random first and + as second.
If I put "static char dummy[]="1";" at the start of the list, the last var will still be bad.
If I put the dummy at the end both "http_len_str[]" and "dummy[]" will have extra chars.
I have tried just the above lines in a new empty project, it works fine.
It is not a debugger issue as the HTTP server fails when it come time to check the content length.
Could this be a hardware issue with that part of the ROM? I don't have another pic to test with but I can't think of any other ideas why this would be going on. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Aug 20, 2020 11:08 pm |
|
|
Markdem wrote: | CCS = 5.025 |
You have an older compiler left over from April 2014.
You could download the CCS demo. It will be the latest version or close
to it. You could test your software with it. See if it's a version issue.
http://www.ccsinfo.com/ccsfreedemo.php
I would put it on a different computer, to be safe. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19506
|
|
Posted: Fri Aug 21, 2020 12:37 am |
|
|
Some comments:
You say in your post header 'random const char', but this is not a 'const'.
What happens is that:
"Content-Length:"
is a const, but declared as 'static', this is copied into the RAM string
http_len_str, _once_ before the main code actually runs. Never again.
So if anything else at all talks to the RAM area containing this string, any
changes will be retained.
Now when you remove 'static', this value is instead copied into the
http_len_str, every time the routine starts.
So I'd suspect that something is accidentally changing the 15th byte
of http_len_str. Result you see this changed byte when you stop and
look at the variable in the debugger.
Given that the 'non static' version is OK, look later in the routine(s) than
where you are stopping and looking at the value.
As PCM says, 5.025, is a rather old version, but I'd be most suspicious
that you actually have a code error resulting in the byte being changed. |
|
|
Markdem
Joined: 24 Jun 2005 Posts: 206
|
|
Posted: Tue Aug 25, 2020 12:08 am |
|
|
Sorry for the late reply,..
I tried the demo, still have the same issue.
Ttelmah - what you are saying makes sense, however I have no idea how I would ever debug this. Is there away of checking what memory location is given to "http_len_str[]" and using the debugger to watch for change? I know I can do this in visual studio but no idea how I would do it using MPLab\CCS.
And does it really matter anyway? I am guessing it takes a few extra ns to run the function but besides that, what else should I be thinking about?
Thanks |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19506
|
|
Posted: Tue Aug 25, 2020 12:34 am |
|
|
The ways to debug are first, to look at the .sym file.
Find where this variable is, and look what is immediately in front of this
in memory. The most likely culprit is always another variable 'nearby'.
Just after as well, but slightly less likely.
Then look in your code for every operation that does anything involving the
nearby variables. Particularly anything involving pointers (array operations,
string operations etc..).
When you are running the debugger, the 'watch' values do not update, till
you stop. So you have to split the code up, and run a small section, and
see if the watch has changed. You can do a sort of 'binary search', with
a pair of breakpoints gradually being moved closer and closer together, till
you isolate where the change occurs. |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|