Based on httpsrv project, I am try to create my own cgi function.
But when I try to open a file in this cgi function, it cause
"httpsrv callback handler overflow."
Any ideas about this? I am use MQX4.0.2 and TWR-K60F120M.
perhaps you don't have enough stack. When you call the function HTTPSRV_init() you give as parameter the structure HTTPSRV_PARAM_STRUCT. In this structure you have the "script_stack" variable. This variable is the size of a stack of the script handler task in bytes. Try to set the value of this variable according to the memory requirements of your CGI callbacks. The default value is 750 bytes.
Hope this helps.
Thank you. It solves the problem.
The question is that when I set script_stack, this is the stack size for each cgi call back function, is it correct?
No, this is for the http server. That means it should be for all the CGI calls. The stack is taken from here for each one of them.
Then if I want to add more CGI calls, I need keep extending this stack size, otherwise it will cause stack overflow, is it right?
If it is the case, is there a better way to set this stack dynamically?
Well, the memory is finite. So, you shall use the Task Aware Debugging to see how much memory is left in the HTTP server stack. This is not a dynamic memory allocation so you need to calculate well and assign what you think it is going to be enough. A try and test method could work. It is not the best approach but at least will give a good result.
Retrieving data ...