Since I have not gotten any more suggestions for resolving the problem I will start from scratch and will blame the problem on a bad program design/implementation. I do not know of any other way of resolving this issue, I just hope that in my new design, I do not run into the same problem and find out that maybe it has something to do with program memory shortages that is not apparently showing itself, in whatever manner that may occur. So, back to design status...
Ray
Post a zip of your project so that I can reproduce your problems. I'll look at it later today. No time at the moment.
Thanks for the offer jazzed, but I think I have to learn how too muddle through these problems on my own. I was just giving a warning to who ever was looking at my program that there will not be any further code adjustments, on to a new design.
I was able to replicate the problem in a much smaller program. Basically when you type in 'testlog' command, senselog COG writes to the SD, as expected, when you go to type in another command, the program is locked. I guess the experts will have to explain to me why that is occurring.
Thanks jazzed, I just tried it with your suggestions, and of course it works as expected.
This stack business, as I increase the senslog COG with more code lines, will I also have too increase the stack size? And of course when I add code lines to the sht11 COG I presume I will have too increase the stack size of that COG also? As you increase the stack sizes, I did not see the Code Size reading increase at all, so how do I know how much memory I have left? And does the stack use hub or COG memory, or a combination of both? 'sensestack[40 + 150]' , why is the stack size allocated in two parts, previously it was just one number? Is the 150 of greater importance than the 40 value?
Ray, 40 ints (160 bytes) is the minimum cogstart stack size. Everything else is for the file operation functions in the senselog COG.
I suspect that the file-system code has the biggest stack requirement. Once you have enough stack "per cogstart function", you're probably Ok.
Code size will not increase with stack requirements. Stack required is almost nothing ... until you start using it. I'll do some experiments to find a way to determine what the stack usage is - give me some time on that.
BTW, I don't understand why your Simple Library code doesn't show up in your ZIP file. I had to remove all those project links before it would compile. What SimpleIDE version are you using?
I am using 0-9-45, I just recently went to the Learn site, and used their instructions to download it. Because my program size is quite large I have too keep a sharp eye on the stack sizes and how they are impacting my program, this is really cutting it close in terms of memory use. Thanks again jazzed.
I did a standard install, the only thing that I did do different is chose a Workspace Folder on an external drive. Now, I was looking at the Project Manager and I have two that are -I C:/Users ..., and two that are -L C:/Users... One of each for .../libfdserial, and one of each for libsimpletext. I do not see anything for .../libsimpletools.
If I am not mistaken, I had the same thing occur for 0-9-43, but it seems like everything is compiling correctly, I think?
I did a standard install, the only thing that I did do different is chose a Workspace Folder on an external drive. Now, I was looking at the Project Manager and I have two that are -I C:/Users ..., and two that are -L C:/Users... One of each for .../libfdserial, and one of each for libsimpletext. I do not see anything for .../libsimpletools.
If I am not mistaken, I had the same thing occur for 0-9-43, but it seems like everything is compiling correctly, I think?
Ray
Thanks Ray.
Can you please remove the -L and -I project entries and try the ZIP again?
I'm guessing that ZIP is ignoring the Library folder because of those entries.
Really would like to resolve this - it's hard to tell if it's a feature or a bug at the moment.
Can you Click "Clear Settings" on Properties -> General, then "Cancel", then restart SimpleIDE. You will need to use Project -> Open to get your project back. Then do ZIP again, and let me know if that changes anything.
Below is my latest program, I added two new commands: five24 - logs every five minutes for twenty four hours; five1 - logs every five minutes for one hour. I wanted to make sure the global variables are affecting the senselog COG in the expected manner. The next command should be a command that has a time start, time end, and a duration time, this should be a little more challenging, memory space permitting.
Because this program will be running 24/7, I need to have a method of exchanging the SD card without having too turn off the device. Since it is not set up with a "hot swapping" capability, I guess I need something like an 'unmount' and 'mount' commands. Is there something like that in the SD support code?
This is not a project yet, I still have to make sure I completely understand how the stack allocation works, and how many more COG sessions I can add with the current memory constraints.
Below is a code snippet that has a nested if loop, is that legal in C? The program compiles without errors, and does not give a warning as to the legality of the nested if loop, but it is not doing what I want it too do. If that is not legal what would be the correct coding for that block of code?
Ray
while(1)
{
/* Check for stop. */
int real_ms,real_mh;
int temp3,temp4,temp5;
real_mh = get_Hour(temp4);
real_ms = get_Minute(temp3);
if(stop_h == real_mh) // Check stop hour
{
if(stop_m == real_ms) //break; // Check stop minute
{
fclose(sp);
low(27);
logstat = 0;
break;
}
}
// Do data logging
time_SD(); // Get time.
fwrite(" ",1,2,sp);
sprint(outBuff,"%f",sht11_temp);
fwrite(outBuff,1,8,sp); // Write temp.
fwrite(" ",1,2,sp);
sprint(outBuff,"%f",sht11_humid);
fwrite(outBuff,1,8,sp); // Write humid.
fwrite("\r\n",1,2,sp); // CR
sleep(timer_d); // Sleep for xxx minutes. Sleep time
}
I finally resolved the issue, in the previous post, a couple of bugs, so obvious, but I could not see them, what a horrible experience. I still have to get a handle on the stack allocation experience, if you do not get it right, it shows up in the program in a very subtle way, you end up scratching your head as to what you think the problem is.
Is the Propeller Platform a dead issue? I noticed at the MGH Designs site that it is very quiet in terms of new shields being offered, so is this a platform that you should spend resources on? But, I do not see anybody else offering a product that has an on board RTC and flash ram. I think the Propeller is still looking for a good, workable platform to reside on. Decisions, decisions, what is my next move?
Since your outer if block (when true) doesn't do anything if the inner block is false, why use the break statement at all? I tried to simplify your code example, below. Also, although C or C++ compilers may optimize the declarations of your ints, for clarity I would move those declarations out of the while loop.
int real_ms,real_mh;
int temp3,temp4,temp5;
while(1)
{
/* Check for stop. */
real_mh = get_Hour(temp4);
real_ms = get_Minute(temp3);
if(stop_h == real_mh && stop_m == real_ms) // Check stop hour
{
fclose(sp);
low(27);
logstat = 0;
}
else
{
// Do data logging
time_SD(); // Get time.
fwrite(" ",1,2,sp);
sprint(outBuff,"%f",sht11_temp);
fwrite(outBuff,1,8,sp); // Write temp.
fwrite(" ",1,2,sp);
sprint(outBuff,"%f",sht11_humid);
fwrite(outBuff,1,8,sp); // Write humid.
fwrite("\r\n",1,2,sp); // CR
sleep(timer_d); // Sleep for xxx minutes. Sleep time
}
}
Thanks dgately, here is my version of how I solved the issue. There is a big while loop that is not shown here, so I figured this would be a good way to check for start and stop times based on hour and minute. Now I can just as easily add a month variable to this, I think the if statement(s) can handle another '&&' for the month.
Ray
while(1)
{
/* Check for start. */
int real_sm,real_sh;
int temp,temp1,temp2;
real_sh = get_Hour(temp1);
real_sm = get_Minute(temp);
if((start_h == real_sh) && (start_m == real_sm)) break;
}
while(1)
{
/* Check for stop. */
high(27);
int real_ms,real_mh;
int temp3,temp4,temp5;
real_mh = get_Hour(temp4);
real_ms = get_Minute(temp3);
if((stop_h == real_mh) && (stop_m == real_ms)) break; // Check stop hour
// Do data logging
time_SD(); // Get time.
fwrite(" ",1,2,sp);
sprint(outBuff,"%f",sht11_temp);
fwrite(outBuff,1,8,sp); // Write temp.
fwrite(" ",1,2,sp);
sprint(outBuff,"%f",sht11_humid);
fwrite(outBuff,1,8,sp); // Write humid.
fwrite("\r\n",1,2,sp); // CR
sleep(timer_d); // Sleep for xxx minutes. Sleep time
}
fclose(sp);
low(27);
logstat = 0;
}
Comments
Ray
Ray
I changed the stack to this: unsigned int sensestack[40 + 150]; // 40 + 25
Then added fclose(sd); after your green LED on line 55.
Stdio things are very expensive in stack and code terms. The 25 longs allocated for extra stack was just not sufficient.
This stack business, as I increase the senslog COG with more code lines, will I also have too increase the stack size? And of course when I add code lines to the sht11 COG I presume I will have too increase the stack size of that COG also? As you increase the stack sizes, I did not see the Code Size reading increase at all, so how do I know how much memory I have left? And does the stack use hub or COG memory, or a combination of both? 'sensestack[40 + 150]' , why is the stack size allocated in two parts, previously it was just one number? Is the 150 of greater importance than the 40 value?
Ray
I suspect that the file-system code has the biggest stack requirement. Once you have enough stack "per cogstart function", you're probably Ok.
Code size will not increase with stack requirements. Stack required is almost nothing ... until you start using it. I'll do some experiments to find a way to determine what the stack usage is - give me some time on that.
BTW, I don't understand why your Simple Library code doesn't show up in your ZIP file. I had to remove all those project links before it would compile. What SimpleIDE version are you using?
Ray
Can you please do a Zip on your project? Then post the Build Status for me here (right-click select-all, copy, then paste).
Thanks.
Ray
Did you press the Zip button?
Ray
Ray
Does your project always have -I ./library/* in it?
Does your library really live under your project folder?
Typically projects live in a workspace like SimpleIDE/My Projects and the library lives in the SimpleIDE/Learn/Simple Libraries folder.
If I am not mistaken, I had the same thing occur for 0-9-43, but it seems like everything is compiling correctly, I think?
Ray
Can you please remove the -L and -I project entries and try the ZIP again?
I'm guessing that ZIP is ignoring the Library folder because of those entries.
Really would like to resolve this - it's hard to tell if it's a feature or a bug at the moment.
Ray
Can you Click "Clear Settings" on Properties -> General, then "Cancel", then restart SimpleIDE. You will need to use Project -> Open to get your project back. Then do ZIP again, and let me know if that changes anything.
Thanks.
Ray
Because this program will be running 24/7, I need to have a method of exchanging the SD card without having too turn off the device. Since it is not set up with a "hot swapping" capability, I guess I need something like an 'unmount' and 'mount' commands. Is there something like that in the SD support code?
This is not a project yet, I still have to make sure I completely understand how the stack allocation works, and how many more COG sessions I can add with the current memory constraints.
Ray
Ray
Is the Propeller Platform a dead issue? I noticed at the MGH Designs site that it is very quiet in terms of new shields being offered, so is this a platform that you should spend resources on? But, I do not see anybody else offering a product that has an on board RTC and flash ram. I think the Propeller is still looking for a good, workable platform to reside on. Decisions, decisions, what is my next move?
Ray
Well, if's aren't loops themselves. Your 'while' block is the only loop here. Nested loops and if statements can be nested in C...
I find that 'break' statements can be confusing and have caused even large corporations (see: http://stackoverflow.com/questions/2565659/i-want-to-know-the-behaviour-of-break-statement-in-c-does-it-work-only-for-fo) consternation in the past, so I try to avoid them unless I can't see a better way to code around them. (I know this will cause forum upheaval, but that's just me!)...
Since your outer if block (when true) doesn't do anything if the inner block is false, why use the break statement at all? I tried to simplify your code example, below. Also, although C or C++ compilers may optimize the declarations of your ints, for clarity I would move those declarations out of the while loop.
Take my changes with a grain of salt, of course.
dgately
Ray
LOL