zedboard 的FPGA的ROM弄个正弦波数据,用udp发送
1. 构架,UDP发送部分, FPGA和ARM数据交互部分,FPGA保存ROM正弦波数据
2. UDP发送部分。在电脑的ubuntu 虚拟机里面,安装xilinx的交叉编译环境。编译.c文件。 UDP操作函数没问题,但是怎么从FPGA取数据的函数是啥?
3. UDP的发送代码如下:
#include <stdio.h> // 标准输入输出 perror函数
#include <string.h> // 字符数组相关函数 bzero函数 strcmp
#include <stdlib.h> // 标准库
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <signal.h>
#define SERVER_PORT 8889
int main(int argc, char **argv)
{
int iSocketServer;
int iRet;
int i = 100;
unsigned char ucsSendBuf[1024];
struct sockaddr_in tSocketServerAddr;
struct sockaddr_in tSocketClientAddr;
//signal(SIGCHLD,SIG_IGN);//处理僵尸进程的,可以看我那篇关于僵尸进程的博客
//iSocketServer = socket(AF_INET, SOCK_STREAM, 0);
iSocketServer = socket(AF_INET, SOCK_DGRAM, 0);
if (-1 == iSocketServer)
{
printf("socket error!\n");
return -1;
}
tSocketClientAddr.sin_family = AF_INET;
tSocketClientAddr.sin_port = htons(8880); /* host to net, short */
tSocketClientAddr.sin_addr.s_addr = INADDR_ANY;
//memset(tSocketClientAddr.sin_zero, 0, 8);
iRet = bind(iSocketServer, (const struct sockaddr *)&tSocketClientAddr, sizeof(struct sockaddr));
if (-1 == iRet)
{
printf("bind error!\n");
return -1;
}
tSocketServerAddr.sin_family = AF_INET;
tSocketServerAddr.sin_port = htons(SERVER_PORT); /* host to net, short */
tSocketServerAddr.sin_addr.s_addr = inet_addr("192.168.1.11");
//memset(tSocketServerAddr.sin_zero, 0, 8);
while(i--)
{
/*一直向saddr的地址(接收端IP和端口号),发送udp包*/
sendto(iSocketServer,ucsSendBuf,1024,0,(struct sockaddr*)&tSocketServerAddr,sizeof(tSocketServerAddr));
sleep(30);
}
close(iSocketServer);
return 0;
}