资深版主
 
- 积分
- 1702
- 金钱
- 1702
- 注册时间
- 2012-5-10
- 在线时间
- 439 小时
|
发表于 2018-9-26 11:53:35
|
显示全部楼层
[mw_shl_code=c,true]MyRes CommunicateWithNcdServerInGPRS(HttpBuf * httpBuf)
{
//??????
xQueueReset(GetUsart5TXQueue());
//????
httpBuf->tempInt = httpBuf->sendDataLen;
while(httpBuf->tempInt > 800)
{
if(My_Pass == SendDataToQueue(GetUsart5TXQueue(), NULL, httpBuf->sendBuf + (httpBuf->sendDataLen - httpBuf->tempInt),
800, 1, 1000 / portTICK_RATE_MS, 10 / portTICK_RATE_MS, EnableUsart5TXInterrupt))
{
httpBuf->tempInt -= 800;
vTaskDelay(100 / portTICK_RATE_MS);
}
else
goto END;
}
if(httpBuf->tempInt > 0)
{
if(My_Pass != SendDataToQueue(GetUsart5TXQueue(), NULL, httpBuf->sendBuf + (httpBuf->sendDataLen - httpBuf->tempInt),
httpBuf->tempInt, 1, 1000 / portTICK_RATE_MS, 10 / portTICK_RATE_MS, EnableUsart5TXInterrupt))
goto END;
}
//????,????1s
httpBuf->tempShort = 0;
httpBuf->recvDataLen = 0;
httpBuf->j = 0;
memset(httpBuf->recvBuf, 0, HttpRecvBufSize);
while(pdPASS == ReceiveDataFromQueue(GetUsart5RXQueue(), NULL, httpBuf->recvBuf, HttpRecvBufSize,
&httpBuf->tempShort, 1, 20000 / portTICK_RATE_MS, 1000 / portTICK_RATE_MS, 2000 / portTICK_RATE_MS))
{
if(httpBuf->isPost)
{
httpBuf->recvDataLen += httpBuf->tempShort;
break;
}
//??????GET??,????????,????
else
{
//????????
if(httpBuf->j < 2)
{
httpBuf->tempP = strstr(httpBuf->recvBuf, fileLengthParmString);
if(httpBuf->tempP)
{
httpBuf->fileLength = strtol(httpBuf->tempP+fileLengthParmStringLen, NULL, 10);
httpBuf->fileLength -= fileStartStrLen;
httpBuf->j++;
}
//?????
httpBuf->tempP = strstr(httpBuf->recvBuf, fileStartStr);
if(httpBuf->tempP)
{
httpBuf->tempInt = httpBuf->tempP - httpBuf->recvBuf + fileStartStrLen;
httpBuf->tempShort -= httpBuf->tempInt;
WriteAppFile(httpBuf->recvBuf + httpBuf->tempInt, httpBuf->tempShort, true);
httpBuf->recvDataLen += httpBuf->tempShort;
httpBuf->j++;
}
}
else
{
WriteAppFile(httpBuf->recvBuf, httpBuf->tempShort, false);
httpBuf->recvDataLen += httpBuf->tempShort;
if(httpBuf->recvDataLen >= httpBuf->fileLength)
break;
}
}
}
END:
if(httpBuf->isPost)
{
httpBuf->tempP = strstr(httpBuf->recvBuf, "success");
if(httpBuf->tempP)
return My_Pass;
}
return My_Fail;
}[/mw_shl_code] |
|