完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
我正在移植一个旧的应用程序(2.06)。最近,我发现了一种模拟HTLA和HTTP网络服务器的MLLA库(HhttpPrimtPythiCixVar())的CurHTHTP.CalbPoS机制。服务器和两个调用HTTP网络服务器的TCPIpHIPHtpNETHelnCalutalCalpRouthPoGet和TCPPIpHhttpNETSnEngulalCalkRouthSet。在我的项目中,我使用HTTP网络服务器使用HTTPS连接。但是,TCPIPHHTPNETNEnnLognCalnCouthPosiGET始终返回零。下面看我的测试代码,我猜它是正确的,我可能错了。可能主要的问题是在调用用户函数之前总是将No.HtpHyDyvCARLACKEDHONPHTPCON & & CalbPoPs设置为零。它是错误的和谐还是我做错了什么?
以上来自于百度翻译 以下为原文 I am porting an old application in HARMony (2.06). Recently I discovered a legacy mechanism to emulate the curHTTP.callbackPos of MLA libraries (HTTPPrint_dynamic_var()) in Harmony for both HTTP and HTTP NET servers. I found that there are two calls TCPIP_HTTP_CurrentConnectionCallbackPosGet and TCPIP_HTTP_CurrentConnectionCallbackPosSet for the HTTP server and two calls TCPIP_HTTP_NET_ConnectionCallbackPosGet and TCPIP_HTTP_NET_ConnectionCallbackPosSet for the HTTP NET server. In my project, I am using HTTP NET server to use HTTPS connections. However, TCPIP_HTTP_NET_ConnectionCallbackPosGet always returns zero. See below my test code, I guess that it is correct, I may wrong. TCPIP_HTTP_DYN_PRINT_RES TCPIP_HTTP_Print_net(TCPIP_HTTP_NET_CONN_HANDLE connHandle, const TCPIP_HTTP_DYN_VAR_DCPT *vDcpt) { #define DATA_SIZE 1024// 1 kBytes TCPIP_HTTP_DYN_PRINT_RES rtn; HTTP_APP_CALLBACK_POS *pos; uint32_t len; if ((pos = (HTTP_APP_CALLBACK_POS *) TCPIP_HTTP_NET_ConnectionCallbackPosGet(connHandle)) == NULL) { pos = (HTTP_APP_CALLBACK_POS*) x_malloc(sizeof (HTTP_APP_CALLBACK_POS)); pos->size = pos->sm = 0; } switch (pos->sm) { case 0: pos->data = x_malloc(sizeof (char*) * DATA_SIZE); len = SettingsToXML_GetNet(pos->data, sizeof (char*) * DATA_SIZE); TCPIP_HTTP_NET_DynamicWrite(vDcpt, pos->data, len, false); pos->sm++; rtn = TCPIP_HTTP_DYN_PRINT_RES_DONE; // This must be RES_DONE because I am using TCPIP_HTTP_NET_ConnectionCallbackPosSet break; case 1: // If here the buffer may be released x_free(pos->data); x_free(pos); pos = NULL; TCPIP_HTTP_NET_ConnectionCallbackPosSet(connHandle, NULL); rtn = TCPIP_HTTP_DYN_PRINT_RES_DONE; break; } TCPIP_HTTP_NET_ConnectionCallbackPosSet(connHandle, (uint32_t) pos); return rtn; } Probably the main problem is in _HTTP_DynVarCallback where pHttpCon->callbackPos is always set to zero before calling user functions. Is it a bug in Harmony or am I doing something wrong? static TCPIP_HTTP_CHUNK_RES _HTTP_DynVarCallback(TCPIP_HTTP_NET_CONN* pHttpCon, TCPIP_HTTP_CHUNK_DCPT* pChDcpt) { TCPIP_HTTP_DYN_PRINT_RES printRes; const TCPIP_HTTP_DYN_VAR_KEYWORD_ENTRY* pKEntry; TCPIP_HTTP_DYNVAR_CHUNK_DCPT* pDynChunkDcpt; TCPIP_HTTP_DYN_VAR_DCPT* pDynDcpt; pDynChunkDcpt = &pChDcpt->dynChDcpt; pDynDcpt = &pDynChunkDcpt->pDynAllocDcpt->dynDcpt; printRes = TCPIP_HTTP_DYN_PRINT_RES_DONE; pHttpCon->callbackPos = 0; if((pChDcpt->flags & TCPIP_HTTP_CHUNK_FLAG_DYNVAR_DEFAULT_PROCESS) == 0) { // call the user processing if(!_HTTP_DbgKillUserDynVar()) { printRes = (*httpUserCback->dynamicPrint)(pHttpCon, pDynDcpt, httpUserCback); _HTTP_DynDbgCallback(pDynDcpt->dynName, printRes, pHttpCon->connIx); if(printRes == TCPIP_HTTP_DYN_PRINT_RES_DEFAULT) { pChDcpt->flags |= TCPIP_HTTP_CHUNK_FLAG_DYNVAR_DEFAULT_PROCESS; } else if(printRes == TCPIP_HTTP_DYN_PRINT_RES_AGAIN || printRes == TCPIP_HTTP_DYN_PRINT_RES_PROCESS_AGAIN) { if(++pDynChunkDcpt->dynRetries > httpDynVarRetries) { printRes = TCPIP_HTTP_DYN_PRINT_RES_DONE; _HTTP_Report_ConnectionEvent(pHttpCon, TCPIP_HTTP_NET_EVENT_DYNVAR_RETRIES_EXCEEDED, pDynDcpt->dynName); } } } } if((pChDcpt->flags & TCPIP_HTTP_CHUNK_FLAG_DYNVAR_DEFAULT_PROCESS) != 0) { // call the default implementation! if((pKEntry = pDynChunkDcpt->pKEntry) != 0) { printRes = (*pKEntry->dynamicPrint)(pHttpCon, pDynDcpt, httpUserCback); _HTTP_DynDbgCallback(pDynDcpt->dynName, printRes, pHttpCon->connIx); } } if(pHttpCon->callbackPos != 0) { // user messing with the callbackPos; ignore the printRes printRes = TCPIP_HTTP_DYN_PRINT_RES_PROCESS_AGAIN; } pChDcpt->flags &= ~TCPIP_HTTP_CHUNK_FLAG_DYNVAR_AGAIN; if(printRes == TCPIP_HTTP_DYN_PRINT_RES_AGAIN || printRes == TCPIP_HTTP_DYN_PRINT_RES_PROCESS_AGAIN) { pChDcpt->flags |= TCPIP_HTTP_CHUNK_FLAG_DYNVAR_AGAIN; return printRes == TCPIP_HTTP_DYN_PRINT_RES_AGAIN ? TCPIP_HTTP_CHUNK_RES_WAIT : TCPIP_HTTP_CHUNK_RES_OK; } // don't need calling again return TCPIP_HTTP_CHUNK_RES_DONE; } |
|
相关推荐
1个回答
|
|
我将每次查看CaleBoPs设置为0,看看它是否是一个bug,我会让你知道我发现了什么。但是,对于你的使用示例,如果这是你在你的应用程序中真正使用的,我认为使用DyPosiNe函数将更容易。T(…){OLC;CaltTCPIpHutpHypNETRealDead(,,true);//您需要返回完成;}确认函数释放缓冲区。请参阅它,看看逻辑中是否有一些bug。显然,另一种方法是依靠本地维护的数据来决定分配/释放和使用回调位置,以便将意图传达给HTTPNET。
以上来自于百度翻译 以下为原文 I'll be looking into the setting of the callbackPos to 0 each time, to see if it's a bug and I'll let you know what I find. However, for your usage example, if this is what you really use in your app, I think it would be much easier to use the DynPrint function as it was intended: TCPIP_HTTP_Print_net(...) { alloc; call TCPIP_HTTP_NET_DynamicWrite(,,, true); // you need ack return done; } And the acknowledge function just frees the buffer. A simple example of how to use the acknowledge function to manipulate statically allocated buffers is in the supplied custom_http_net.c. Anyway, as mentioned, I'll look into it to see if there's some bug in the logic. P.S. Obviously another approach would be to rely on the data maintained locally for taking the decision to allocate/free and use the callback position only to communicate the intention to the HTTP_NET. |
|
|
|
只有小组成员才能发言,加入小组>>
5171 浏览 9 评论
2001 浏览 8 评论
1931 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3176 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2228 浏览 5 评论
737浏览 1评论
622浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
509浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
635浏览 0评论
533浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-26 09:28 , Processed in 1.345069 second(s), Total 79, Slave 62 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号