This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] CC3220SF-LAUNCHXL:从服务器(CC3220SF)到客户端(任何其他设备)的 HTTP 消息传输中的碎片

Guru**** 2519260 points
Other Parts Discussed in Thread: CC3220SF

请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/wireless-connectivity/wi-fi-group/wifi/f/wi-fi-forum/1123532/cc3220sf-launchxl-fragmentation-in-http-message-transfer-from-server-cc3220sf-to-client-any-other-device

器件型号:CC3220SF-LAUNCHXL
主题中讨论的其他器件:CC3220SF

您好!

我正在尝试将 http 消息从 CC3220SF HTTP 服务器发送到基于笔记本电脑的 http 客户端、其中 CC3220SF 也用作接入点。 我必须发送大量数据(大约10KB)来响应每个 http 请求。 我尝试发送2kB、每个大小为500B (总共为2kB)的4个片段、这种情况很好、代码如下所示:  

int32_t dataGetCallback(uint8_t requestIdx, uint8_t *argcCallback, uint8_t **argvCallback, SlNetAppRequest_t *netAppRequest)
{
    uint8_t *pPayload;
    uint16_t metadataLen, sendDatalen;



    char sendDataStr1[500] = "1Machine learning (ML) is a field of inquiry devoted to understanding and building methods that 'learn', that is, methods that leverage data to improve performance on some set of tasks. It is seen as a part of artificial intelligence. Machine learning algorithms build a model based on sample data, known as training data, in order to make predictions or decisions without being explicitly programmed to do so1.";
    char sendDataStr2[500] = "2Machine learning (ML) is a field of inquiry devoted to understanding and building methods that 'learn', that is, methods that leverage data to improve performance on some set of tasks. It is seen as a part of artificial intelligence. Machine learning algorithms build a model based on sample data, known as training data, in order to make predictions or decisions without being explicitly programmed to do so2.";
    char sendDataStr3[500] = "3Machine learning (ML) is a field of inquiry devoted to understanding and building methods that 'learn', that is, methods that leverage data to improve performance on some set of tasks. It is seen as a part of artificial intelligence. Machine learning algorithms build a model based on sample data, known as training data, in order to make predictions or decisions without being explicitly programmed to do so3.";
    char sendDataStr4[500] = "4Machine learning (ML) is a field of inquiry devoted to understanding and building methods that 'learn', that is, methods that leverage data to improve performance on some set of tasks. It is seen as a part of artificial intelligence. Machine learning algorithms build a model based on sample data, known as training data, in order to make predictions or decisions without being explicitly programmed to do so4.";
    char sendDataStr5[500] = "4Machine learning (ML) is a field of inquiry devoted to understanding and building methods that 'learn', that is, methods that leverage data to improve performance on some set of tasks. It is seen as a part of artificial intelligence. Machine learning algorithms build a model based on sample data, known as training data, in order to make predictions or decisions without being explicitly programmed to do so5.";

    pPayload = gPayloadBuffer;



    sl_Memcpy (pPayload, sendDataStr1, sizeof(sendDataStr1));
    pPayload += sizeof(sendDataStr1);

    /* NULL terminate the payload */
    *(pPayload) = '\0';

    sendDatalen = sizeof(sendDataStr1) + sizeof(sendDataStr2) + sizeof(sendDataStr3)+ sizeof(sendDataStr4); //+sizeof(sendDataStr5);

    metadataLen = prepareGetMetadata(0, sendDatalen, HttpContentTypeList_TextPlain);

    pthread_mutex_lock(&spiMutex);

    sl_NetAppSend (netAppRequest->Handle, metadataLen, gMetadataBuffer, (SL_NETAPP_REQUEST_RESPONSE_FLAGS_CONTINUATION | SL_NETAPP_REQUEST_RESPONSE_FLAGS_METADATA));
    sl_NetAppSend (netAppRequest->Handle,sizeof(sendDataStr1), gPayloadBuffer, SL_NETAPP_REQUEST_RESPONSE_FLAGS_CONTINUATION); /* mark as last segment */


    pPayload = gPayloadBuffer;
    sl_Memcpy (pPayload, sendDataStr2, sizeof(sendDataStr2));
    pPayload += sizeof(sendDataStr2);

    /* NULL terminate the payload */
    *(pPayload) = '\0';

    sl_NetAppSend (netAppRequest->Handle,sizeof(sendDataStr3), gPayloadBuffer, SL_NETAPP_REQUEST_RESPONSE_FLAGS_CONTINUATION); /* mark as last segment */

    pPayload = gPayloadBuffer;
    sl_Memcpy (pPayload, sendDataStr3, sizeof(sendDataStr3));
    pPayload += sizeof(sendDataStr3);

    /* NULL terminate the payload */
    *(pPayload) = '\0';

   sl_NetAppSend (netAppRequest->Handle,sizeof(sendDataStr3), gPayloadBuffer, SL_NETAPP_REQUEST_RESPONSE_FLAGS_CONTINUATION); /* mark as last segment */

    pPayload = gPayloadBuffer;
    sl_Memcpy (pPayload, sendDataStr4, sizeof(sendDataStr4));
    pPayload += sizeof(sendDataStr4);

    /* NULL terminate the payload */
    *(pPayload) = '\0';

    sl_NetAppSend (netAppRequest->Handle,sizeof(sendDataStr4), gPayloadBuffer, 0); /* mark as last segment */

    pthread_mutex_unlock(&spiMutex);

    return 0;
}

答案如下:  

但是、当我尝试发送更多的片段或/和四个较大尺寸的片段时、它只能作为请求、然后显示404错误、如下所示-  

int32_t dataGetCallback(uint8_t requestIdx, uint8_t *argcCallback, uint8_t **argvCallback, SlNetAppRequest_t *netAppRequest)
{
    uint8_t *pPayload;
    uint16_t metadataLen, sendDatalen;



    char sendDataStr1[500] = "1Machine learning (ML) is a field of inquiry devoted to understanding and building methods that 'learn', that is, methods that leverage data to improve performance on some set of tasks. It is seen as a part of artificial intelligence. Machine learning algorithms build a model based on sample data, known as training data, in order to make predictions or decisions without being explicitly programmed to do so1.";
    char sendDataStr2[500] = "2Machine learning (ML) is a field of inquiry devoted to understanding and building methods that 'learn', that is, methods that leverage data to improve performance on some set of tasks. It is seen as a part of artificial intelligence. Machine learning algorithms build a model based on sample data, known as training data, in order to make predictions or decisions without being explicitly programmed to do so2.";
    char sendDataStr3[500] = "3Machine learning (ML) is a field of inquiry devoted to understanding and building methods that 'learn', that is, methods that leverage data to improve performance on some set of tasks. It is seen as a part of artificial intelligence. Machine learning algorithms build a model based on sample data, known as training data, in order to make predictions or decisions without being explicitly programmed to do so3.";
    char sendDataStr4[500] = "4Machine learning (ML) is a field of inquiry devoted to understanding and building methods that 'learn', that is, methods that leverage data to improve performance on some set of tasks. It is seen as a part of artificial intelligence. Machine learning algorithms build a model based on sample data, known as training data, in order to make predictions or decisions without being explicitly programmed to do so4.";
    char sendDataStr5[500] = "4Machine learning (ML) is a field of inquiry devoted to understanding and building methods that 'learn', that is, methods that leverage data to improve performance on some set of tasks. It is seen as a part of artificial intelligence. Machine learning algorithms build a model based on sample data, known as training data, in order to make predictions or decisions without being explicitly programmed to do so5.";

    pPayload = gPayloadBuffer;



    sl_Memcpy (pPayload, sendDataStr1, sizeof(sendDataStr1));
    pPayload += sizeof(sendDataStr1);

//    /* NULL terminate the payload */
    *(pPayload) = '\0';

    sendDatalen = sizeof(sendDataStr1) + sizeof(sendDataStr2) + sizeof(sendDataStr3)+ sizeof(sendDataStr4)+sizeof(sendDataStr5);

    metadataLen = prepareGetMetadata(0, sendDatalen, HttpContentTypeList_TextPlain);

    pthread_mutex_lock(&spiMutex);

    sl_NetAppSend (netAppRequest->Handle, metadataLen, gMetadataBuffer, (SL_NETAPP_REQUEST_RESPONSE_FLAGS_CONTINUATION | SL_NETAPP_REQUEST_RESPONSE_FLAGS_METADATA));
    sl_NetAppSend (netAppRequest->Handle,sizeof(sendDataStr1), gPayloadBuffer, SL_NETAPP_REQUEST_RESPONSE_FLAGS_CONTINUATION); /* mark as last segment */


    pPayload = gPayloadBuffer;
    sl_Memcpy (pPayload, sendDataStr2, sizeof(sendDataStr2));
    pPayload += sizeof(sendDataStr2);

//    /* NULL terminate the payload */
    *(pPayload) = '\0';

    sl_NetAppSend (netAppRequest->Handle,sizeof(sendDataStr3), gPayloadBuffer, SL_NETAPP_REQUEST_RESPONSE_FLAGS_CONTINUATION); /* mark as last segment */

    pPayload = gPayloadBuffer;
    sl_Memcpy (pPayload, sendDataStr3, sizeof(sendDataStr3));
    pPayload += sizeof(sendDataStr3);

//    /* NULL terminate the payload */
    *(pPayload) = '\0';

   sl_NetAppSend (netAppRequest->Handle,sizeof(sendDataStr3), gPayloadBuffer, SL_NETAPP_REQUEST_RESPONSE_FLAGS_CONTINUATION); /* mark as last segment */

    pPayload = gPayloadBuffer;
    sl_Memcpy (pPayload, sendDataStr4, sizeof(sendDataStr4));
    pPayload += sizeof(sendDataStr4);

////    /* NULL terminate the payload */
    *(pPayload) = '\0';

    sl_NetAppSend (netAppRequest->Handle,sizeof(sendDataStr4), gPayloadBuffer, SL_NETAPP_REQUEST_RESPONSE_FLAGS_CONTINUATION); /* mark as last segment */

     pPayload = gPayloadBuffer;
     sl_Memcpy (pPayload, sendDataStr5, sizeof(sendDataStr5));
     pPayload += sizeof(sendDataStr5);

 ////    /* NULL terminate the payload */
     *(pPayload) = '\0';

    sl_NetAppSend (netAppRequest->Handle,sizeof(sendDataStr5), gPayloadBuffer, 0); /* mark as last segment */

    pthread_mutex_unlock(&spiMutex);

    return 0;
}

Postman 中客户机的响应如下所示(html 页面中出现相同的响应)--

下一个请求发出后、它会在30s 后显示404错误-  

有人能帮忙吗?来这里有什么问题?

谢谢、此致、

Kuldeep

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好!

    我们不知道这一问题。

    您能否快速执行一个测试、将其除以更多、即8个缓冲器、每个缓冲器250个。

    我想查看它在4个缓冲区后是否仍然失败、或者它是否与大小相关。

    此致、

    Shlomi

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好、Shlomi、

    感谢您的回答

    我尝试发送8个大小为250字节的缓冲区、并且它工作正常。 显然是一个大小问题、但大小问题的原因是即使最大片段大小也是1364。

    我认为这不是碎片大小,而是我所面临的问题的总大小。  

    此外、当我增加请求频率时、我也会面临这个问题。 如果大小较高且后续请求出现404 "找不到页面"问题、则客户端会发生第1个请求本身的超时。

    如果我做了一些错误、您能检查一下上述代码吗?

    谢谢、此致、

    Kuldeep

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好、Shlomi、

    我进一步尝试更改代码并调查此问题、CC3220SF 正陷入元数据 netappsend 本身、如下所示-

    这对我没有任何结论。 您能告诉我是否需要定义字符串及其用途?

    您也可以共享具有碎片和大数据(超过4096左右)的回调代码。

    这将会大有帮助。

    谢谢、此致、

    Kuldeep

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    嗯、我现在没有一个可以分享的示例。

    当您说它在发送元数据时崩溃时、您能否验证所有参数是否合理(例如元数据和 senddata 长度)。

    此外、它在该函数内部的哪个位置出现故障? 您能小心介入并告诉我吗? 我想验证命令是进入芯片还是保留在主机中。

    Shlomi

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好、Shlomi、

    感谢您的回答。

    我看到元数据(datalen 等)正确无误 、如下所示-  

    元数据与4个片段和8个片段没有区别、但 datalen 除外。

    1.有8个碎片-  

    2.使用4个片段

    我无法找到代码触发无限旋转的确切位置、但有时我可以看到 HW_INT 正在获取触发器、而我在 spiwrite 或 read 函数中具有调试点、如下所示。

    1。  

    2.

    如果可能、您可以创建具有大数据大小和共享的碎片代码、这将非常有帮助。

    谢谢、此致、

    Kuldeep

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好!

    我会尽力并告诉您。

    Shlomi

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好!

    我成功使用了 OOB 示例、该示例实现了您正在使用的类似 HTTP GET 请求(我相信您会将其用作参考、因为代码相似)、我没有发现任何问题。 实际上、为了确保我甚至将其增加到8个缓冲区、每个缓冲区500字节、我仍然能够在浏览器上连接所有缓冲区。

    我怀疑您可能会遇到软件问题、例如堆栈溢出可能导致系统卡住。

    就在测试中、是否可以将函数外部的大缓冲区作为全局变量放置、以便不会从堆栈存储器中消耗它?

    此致、

    Shlomi

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    尊敬的 Shlomi:

    感谢您的回答。 你是对的。 问题是由堆栈溢出本身引起的。 我可以使用全局缓冲区解决该问题。 经过一些迭代、我在那里做了错误的事情。

    感谢你的帮助。

    此致、

    Kuldeep