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.

[参考译文] TMS570LS3137:带 lwIP 的客户端 TCP

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

https://e2e.ti.com/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/987565/tms570ls3137-client-tcp-with-lwip

器件型号:TMS570LS3137

你好。 我需要在电路板中创建一个客户端 TCP 来连接我的计算机。 我对n´t 进行了编程、我希望在 Wireshark 中看到 TCP 数据包、但情况确实如此。

我不知道为什么看不到任何 TCP 数据包。 我只能从电路板上看到我所期望的 ARP 数据包。  
如果您能给我提供任何帮助、我将不胜感激。

 

代码:

 

/*用户代码开始(0)*/
#include "freertos.h"
#include "os_task.h"

/*用户代码结束*/

/*包含文件*/

#include "sys_common.h"
#include "system.h"
#include "lwip/ip_addr.h"
#include "lwip/tcp.h"
#include
#include "cJSON.h"
#include
#include
#include "stdio.h"

/ /

extern void EMAC_LwIP_Main (uint8_t * emacAddress);
/*定义全局变量*/


uint8 emacAddress[6U]={0x00U、0x08U、0xEEU、0x03U、0xA6U、 0x6CU};
uint32 emacPhyAddress = 1U;
ip_addr_t src、dst、netmask、gw;

struct tcp_pcb * pcb;

ERR_t errorb、errorc、errorw、erroro、errorr、 错误;

uint16_t length = 275;

struct pbuf *Tx;

char *字符串="TCP lwIP 示例";

char MyData[400];//传入数据

int i = 0;

// /

uint32_t tcp_send_packet (void);
void tcpErrorHandler (void *arg、err_t err);
ERR_t tcpSendCallback (void *arg、struct tcp_pcb、u16_t len);

ERR_t connectCallback (void *arg、struct tcp_pcb、err_t err);

struct tcp_pcb *testpcb;

// /
/*Callback fucions */

void tcpErrorHandler (void *arg、err_t err){


ERR_t tcpSendCallback (void *arg、struct tcp_pcb、u16_t len)


ERR_t connectCallback (void *arg、struct tcp_pcb、err_t err)

tcp_send_packet();
返回0;

// /
// Funcion delay en segundos
空延迟(浮点时间)

int long c、x_time =(int long)(1.36e7 *时间);
对于(c=0;c <= 2 * x_time;c++){

// /
/*页眉*/

uint32_t tcp_send_packet (void)

char *字符串="SetR=01\r";
uint32_t len = strlen (string);

/*压入缓冲器*/
errorw = tcp_write (testpcb、string、strlen (string)、tcp_write_flag_copy);
/*现在发送*/
tcp_output (testpcb);
返回0;

void lwip_init();


// /
/*主要功能*/

int main (空)

EMAC_LwIP_Main (emacAddress);
/*初始化系统*/
//SystemInit();
lwip_init();//初始化 lwIP 堆栈及其所有子系统。

while (1)

// tcp_setup();
uint32_t data = 0xdeadf牛肉;
/*创建 IP */
struct ip_addr ip、src;

IP4_ADDR (&IP、20、0、168、192);

IP4_ADDR (&src、1、0、168、192);

testpcb = tcp_new();//testpcb 是一个全局结构 tcp_pcb
//由 lwIP 定义

/*要传递给回调的虚拟数据*/
errorb = tcp_bind (PCB、&src、5001);


tcp_arg (testpcb、&data);


/*使用 PCB 进行寄存器回调*/
// tcp_recv (testpcb、tcpRecvCallback);

tcp_sent (testpcb、NULL);// tcpSendCallback
// tcp_err (testpcb、tcpErrorHandler);
/*现在连接*/
errorc = tcp_connect (testpcb、&IP、139、connectCallback);


  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
    [n´t userid="481323" URL"~/support/microcontrollers/other/f/other-microcontrollers-forum/987565/tms570ls3137-client-tcp-with-lwip。我希望在 Wireshark 中看到 TCP 数据包,但这种情况确实发生了。

    ARP 数据包使用广播目的地址,但 TCP 将使用单播目的地址。

    Wireshark 是否在 TCP 服务器 IP 地址为192.168.0.20的 PC 上运行?

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

    你好。 是的! Wireshark 在以太网接口中运行。  

    我可以解决我的问题! 当我在'EMAC_LwIP_Main (emacAddress);'中输入代码时、程序被放入不会返回的循环中。 我在 EMAC_LwIP_Main 中写入以下行:

    testpcb = tcp_new();  
    tcp_bind (testpcb、&local、5001);
    tcp_connect (testpcb、&dest、5001、NULL);

    现在、我可以看到 TCP 数据包。

    (笑声)

    另一个查询:是否有人知道其他软件包(LLMNR、SSDP、UDP 等)出现的原因?  

    谢谢!!  

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

    TCP SYN 数据包的图像: