|
@@ -7,10 +7,22 @@
|
|
|
#include <errno.h>
|
|
#include <errno.h>
|
|
|
#include <arpa/inet.h>
|
|
#include <arpa/inet.h>
|
|
|
#include <signal.h>
|
|
#include <signal.h>
|
|
|
|
|
+#include <sys/mman.h>
|
|
|
|
|
+#include <fcntl.h>
|
|
|
|
|
+
|
|
|
|
|
+#include "Devices//tmsgheaders.h"
|
|
|
|
|
+#include "Devices//lmx2594.h"
|
|
|
|
|
+#include "Devices//lmk04821.h"
|
|
|
|
|
+#include "Devices//ad9912.h"
|
|
|
|
|
|
|
|
#include "command.h"
|
|
#include "command.h"
|
|
|
|
|
|
|
|
|
|
+#define REQUESTED_MEMORY_SIZE 0x1000
|
|
|
|
|
+
|
|
|
volatile int sockfd = 0;
|
|
volatile int sockfd = 0;
|
|
|
|
|
+volatile int pci_fd = 0;
|
|
|
|
|
+
|
|
|
|
|
+void *bar1;
|
|
|
|
|
|
|
|
//Обработчик ошибок
|
|
//Обработчик ошибок
|
|
|
void error(const char *msg)
|
|
void error(const char *msg)
|
|
@@ -21,7 +33,11 @@ void error(const char *msg)
|
|
|
{
|
|
{
|
|
|
close(sockfd);
|
|
close(sockfd);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+ if (pci_fd != 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ close(pci_fd);
|
|
|
|
|
+ }
|
|
|
|
|
+ munmap(bar1, REQUESTED_MEMORY_SIZE);
|
|
|
exit(1);
|
|
exit(1);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -35,14 +51,45 @@ void handleCloseSignal(int signal)
|
|
|
{
|
|
{
|
|
|
close(sockfd);
|
|
close(sockfd);
|
|
|
}
|
|
}
|
|
|
|
|
+ if (pci_fd != 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ close(pci_fd);
|
|
|
|
|
+ }
|
|
|
|
|
+ munmap(bar1, REQUESTED_MEMORY_SIZE);
|
|
|
exit(0);
|
|
exit(0);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
int main(int argc, char *argv[])
|
|
|
{
|
|
{
|
|
|
|
|
+
|
|
|
|
|
+ char *filename = "/dev/MyDmaModule";
|
|
|
|
|
+
|
|
|
|
|
+ pci_fd = open(filename, O_RDWR | O_SYNC);
|
|
|
|
|
+ if (pci_fd == -1) {
|
|
|
|
|
+ int error = errno;
|
|
|
|
|
+ fprintf(stderr, "Cannot open file: %s\n", strerror(error));
|
|
|
|
|
+ return 1;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ bar1 = mmap(NULL, REQUESTED_MEMORY_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, pci_fd, 0);
|
|
|
|
|
+ printf("bar0 ptr %p\n", bar1);
|
|
|
|
|
+ if (bar1 == MAP_FAILED) {
|
|
|
|
|
+ perror("mmap");
|
|
|
|
|
+ close(pci_fd);
|
|
|
|
|
+ return 1;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ lmk04821_a_init(bar1);
|
|
|
|
|
+ usleep(500);
|
|
|
|
|
+ lmk04821_b_init(bar1);
|
|
|
|
|
+ rst_for_fpga(bar1);
|
|
|
|
|
+ shift_reg(bar1);
|
|
|
|
|
+ ad9912_init(bar1);
|
|
|
|
|
+ lmx2594_init(bar1);
|
|
|
|
|
+
|
|
|
//argv[1] = "127.0.0.1";
|
|
//argv[1] = "127.0.0.1";
|
|
|
- int n = 0;
|
|
|
|
|
|
|
+ ssize_t n;
|
|
|
char recvBuff[1024];
|
|
char recvBuff[1024];
|
|
|
struct sockaddr_in serv_addr;
|
|
struct sockaddr_in serv_addr;
|
|
|
|
|
|
|
@@ -53,15 +100,15 @@ int main(int argc, char *argv[])
|
|
|
{
|
|
{
|
|
|
printf("\n Usage: %s <ip of server> \n",argv[0]);
|
|
printf("\n Usage: %s <ip of server> \n",argv[0]);
|
|
|
return 1;
|
|
return 1;
|
|
|
- }
|
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- memset(recvBuff, '0',sizeof(recvBuff));
|
|
|
|
|
|
|
+ memset(recvBuff, 0,sizeof(recvBuff));
|
|
|
if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
|
|
if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
|
|
|
{
|
|
{
|
|
|
error("Error : Could not create socket!");
|
|
error("Error : Could not create socket!");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- memset(&serv_addr, '0', sizeof(serv_addr));
|
|
|
|
|
|
|
+ memset(&serv_addr, 0, sizeof(serv_addr));
|
|
|
|
|
|
|
|
serv_addr.sin_family = AF_INET;
|
|
serv_addr.sin_family = AF_INET;
|
|
|
serv_addr.sin_port = htons(5000);
|
|
serv_addr.sin_port = htons(5000);
|
|
@@ -99,5 +146,11 @@ int main(int argc, char *argv[])
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
close(sockfd);
|
|
close(sockfd);
|
|
|
|
|
+ munmap(bar1, REQUESTED_MEMORY_SIZE);
|
|
|
|
|
+ int fd_close = close(pci_fd);
|
|
|
|
|
+ if (fd_close == -1) {
|
|
|
|
|
+ perror("close");
|
|
|
|
|
+ return 1;
|
|
|
|
|
+ }
|
|
|
return 0;
|
|
return 0;
|
|
|
}
|
|
}
|