Part Number:TMS320C6678
1、请问有6678 有udp 组播客户端的案例可供参考吗?或者参考资料;
2、已经udp单播正常接收数据,修改为udp组播(client)时,无法接收到数据。查阅手册SPRU524H中3.6节第77页中提到NDK不支持server mode,但是支持client operation(The NDK does not currently support IP multicast routing, so there is no need to use IGMP in server mode.However, the software does support IGMP client operation.)。
3、自己修改的接收端函数见recive.c(参考https://www.ti2k.com/wp-content/uploads/ti2k/DeyiSupport_DSP_7.1
recive.c
static void UDP_Recv_GDJ_Tsk(void) {SOCKETsudp = INVALID_SOCKET;char*pBufPing = NULL,*pBufPong = NULL;HANDLEhBuffer;int32_tbytes;uint32_ttsMsec, ts1Msec, startMsec, endMsec;uint32_tts, ts1, tn;uint32_ttotalBytes = 0;int32_tcounter = 0;floatlost_rate =0;struct timevaltimeout;struct sockaddr_in sin1,sin2;struct ip_mreq group;uint32_t FrameNum0 = 0;char flag_Firt= 1;int *pData;pData = GDJDATA_PING;Task_sleep(150); //Semaphore_pend(sem5_START_RECV_GDJ, BIOS_WAIT_FOREVER);printf( "3 UDP_Recv_GDJ_Tsk started\n");/* Allocate the file environment for this task */fdOpenSession(TaskSelf());/* 1 Create the main UDP listen socket */sudp = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);if(sudp == INVALID_SOCKET) {printf( "Failed to create the receive socket \n");goto leave;}/* 2 Set Port = 65000, leaving IP address = Any */bzero(&sin1, sizeof(struct sockaddr_in));sin1.sin_family = AF_INET;sin1.sin_len= sizeof(sin1);//sin1.sin_addr.s_addr= inet_addr("224.0.0.88");sin1.sin_addr.s_addr= inet_addr(INADDR_ANY);sin1.sin_port= htons(65000);/* 3 Bind the socket */if(bind( sudp, (PSA) &sin1, sizeof(sin1)) < 0) {printf("Failed to bind the receive socket \n");goto leave;}/* Set a time out for the receive in case there is data loss.. time out is in seconds */timeout.tv_sec= 5;/* wait up to 5 seconds per packet */timeout.tv_usec = 0;if(setsockopt(sudp, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(timeout)) < 0) {printf( "Failed to set the sockopt for receive socket \n");goto leave;}//4 join multicastbzero(&group, sizeof(struct ip_mreq));group.imr_multiaddr.s_addr = inet_addr("224.0.0.88");//组播IPgroup.imr_interface.s_addr = inet_addr("192.168.172.110");//本机IPif(setsockopt(sudp, IPPROTO_IP, IP_ADD_MEMBERSHIP, &group, sizeof(group)) < 0) {printf("Failed to adding multicast group, %d\n", fdError());goto leave;}bzero(&sin2, sizeof(struct sockaddr_in));/* Allocate a working buffer */if(!(pBufPing = (char *)malloc(2048))) {printf("UDP_Send_ZT_Tsk Failed pBufPing buffer allocation\n");goto leave;}totalBytes = 0;int tmp;tmp=sizeof(sin2);for(;;){bytes = (int)recvncfrom(sudp, (void **)&pBufPing, 0, (PSA)&sin2, &tmp, &hBuffer);}leave:if(pBufPing) {free(pBufPing);}if(pBufPong) {free(pBufPong);}if(sudp != INVALID_SOCKET)fdClose(sudp);UARTprintf(&uart0cfg,"leave : %d \n", fdError());TaskSleep(2000);fdCloseSession(TaskSelf());TaskDestroy(TaskSelf());return; }这是recive.c文件
,
Shine:
请看一下下面的文档是否有帮助?https://www.ti.com/lit/an/spraai3/spraai3.pdf