TI中文支持网
TI专业的中文技术问题搜集分享网站

关于6455 ndk例程helloworld

请问有没有人遇到过这种情况,板子是dsk6455开发板,直接import的example的helloworld(include nimu code),使用DHCPC时获取不到IP地址,就修改了localIpAddress,配置了静态地址,并在NetworkOpen中TSK_create( dtask_udp_sendhello, &tskAttrs);dtask_udp_sendhello用来发送UDP数据包,但sendto失败,返回-1,ping 也失败。请问有没有人知道可能的原因,已经查好几天了,谢谢

[C64XP_0]TCP/IP Stack 'Hello World!' Application

Using MAC Address: 00-01-22-33-44-55
EMAC should be up and runningEMAC has been started successfully
Registeration of the EMAC Successful
Link Status: 100Mb/s Full Duplex on PHY 1
Network Added: If-1:192.168.3.121

sendto failed, return num = -1

Shine:

请问发送的包长是多少?

qing zhang:

回复 Shine:

21个字节,pc与dsk6455直连或者通过交换机相连,都ping不通,发送UDP代码如下

int dtask_udp_sendhello()
{SOCKETs;structsockaddr_in sAddr;structsockaddr_in dAddr;charpBuf[] = "send data to test udp";intopVal = 0;intsendBytes = 0;
memset(&sAddr, 0, sizeof(struct sockaddr_in));memset(&dAddr, 0, sizeof(struct sockaddr_in));
s = socket(AF_INET, SOCK_DGRAM, 0);if(s < 0){printf("socket failed\n");return -1;}
opVal = 1;setsockopt(s, SOL_SOCKET, SO_BROADCAST, &opVal, sizeof(int) );
dAddr.sin_family = AF_INET;dAddr.sin_addr.s_addr = htonl(INADDR_BROADCAST);//INADDR_BROADCASTdAddr.sin_port = htons(12345);
while(1){
TSK_sleep(100);if((sendBytes = sendto(s, pBuf, strlen(pBuf), 0, (struct sockaddr *)&dAddr, sizeof(dAddr))) < 0){
printf("sendto failed, return num = %d\n", sendBytes);//return -1;}}

}

赞(0)
未经允许不得转载:TI中文支持网 » 关于6455 ndk例程helloworld
分享到: 更多 (0)