dev continue

This commit is contained in:
laurent
2019-06-18 08:57:08 +02:00
parent 7653b79f31
commit 17d5bcd396
7 changed files with 225 additions and 188 deletions
+1 -32
View File
@@ -1,21 +1,5 @@
#define MTU 65536
#define UDP_TIMEOUT 100000L // in nano second
#include <split_headers.h>
receiveSubFrame(int sock) {
//read all subframe data from the control unit
char * buf[MTU];
int ret=recv(sock, buf, sizeof(buf), 0);
if ( ret==-1) {
if ( errno == EWOULDBLOCK || errno== EINTR ) {
finishSubframeRecv();
} else {
LOG_E(HW,"Critical issue in socket: %s\n", strerror(errno));
return;
}
} else {
}
}
void pdsch_procedures(PHY_VARS_eNB *eNB,
L1_rxtx_proc_t *proc,
@@ -206,21 +190,6 @@ DL_thread_fs6() {
ru->fh_south_out(ru);
}
int createListner (port) {
int sock;
AssertFatal((sock=socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) >= 0, "");
struct sockaddr_in addr = {
sin_family:
AF_INET,
sin_port:
htons(port),
sin_addr:
{ s_addr: INADDR_ANY }
};
AssertFatal(bind(sock, const struct sockaddr *addr, socklen_t addrlen)==0,"");
struct timeval tv={0,UDP_TIMEOUT};
AssertFatal(setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO,&tv,sizeof(tv)) ==0,"");
}
DL_thread_frequency() {
+18 -3
View File
@@ -1,13 +1,28 @@
#ifndef __SPLIT_HEADERS_H
#define __SPLIT_HEADERS_H
struct frequency_s {
#define MTU 65536
#define UDP_TIMEOUT 100000L // in nano second
#define MAX_BLOCKS 16
#define blockAlign 32 //bytes
typedef struct commonUDP_s {
uint64_t timestamp; // id of the group (subframe for LTE)
uint16_t nbBlocks; // total number of blocks for this timestamp
uint16_t blockID; // id: 0..nbBocks-1
uint16_t contentType; // defines the content format
uint16_t contentBytes; // will be sent in a UDP packet, so must be < 2^16 bytes
} commonUDP_t;
typedef struct frequency_s {
int frame;
int subframe;
int timestamp;
int sampleSize;
int nbAnt
int nbSamples;
} frequency_t;
int createListner (port);
int receiveSubFrame(int sock, uint64_t expectedTS, void* bufferZone, int bufferSize);
int sendSubFrame(int sock, void* bufferZone, int nbBlocks);}
#endif
+65
View File
@@ -0,0 +1,65 @@
#include <split_headers.h>
int createListner (port) {
int sock;
AssertFatal((sock=socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) >= 0, "");
struct sockaddr_in addr = {
sin_family:
AF_INET,
sin_port:
htons(port),
sin_addr:
{ s_addr: INADDR_ANY }
};
int enable=1;
AssertFatal(setsockopt(eth->sockfdc, SOL_SOCKET, SO_REUSEADDR, &enable, sizeof(enable))==0,"");
AssertFatal(bind(sock, const struct sockaddr *addr, socklen_t addrlen)==0,"");
struct timeval tv={0,UDP_TIMEOUT};
AssertFatal(setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO,&tv,sizeof(tv)) ==0,"");
// Make a send/recv buffer larger than a a couple of subframe
// so the kernel will store for us in and out paquets
int buff=1000*1000*10;
AssertFatal ( setsockopt(sock, SOL_SOCKET, SO_SNDBUF, &buff, sizeof(buff)) == 0, "");
AssertFatal ( setsockopt(sock, SOL_SOCKET, SO_RCVBUF, &buff, sizeof(buff)) == 0, "");
}
// sock: udp socket
// expectedTS: the expected timestamp, 0 if unknown
// bufferZone: a reception area of bufferSize
int receiveSubFrame(int sock, uint64_t expectedTS, void* bufferZone, int bufferSize) {
int rcved=0;
do {
//read all subframe data from the control unit
int ret=recv(sock, bufferZone, bufferSize, 0);
if ( ret==-1) {
if ( errno == EWOULDBLOCK || errno== EINTR ) {
return rcved; // Timeout, subframe incomplete
} else {
LOG_E(HW,"Critical issue in socket: %s\n", strerror(errno));
return -1;
}
} else {
commonUDP_t * tmp=(commonUDP_t *)bufferZone;
if ( expectedTS && tmp->timestamp != expectedTS) {
LOG_W(HW,"Received a paquet in mixed subframes, dropping it\n");
} else {
rcved++;
bufferZone+=ret;
}
}
} while ( !recved || recved < tmp->nbBlocks);
return recv;
}
int sendSubFrame(int sock, void* bufferZone, int nbBlocks) {
do {
int sz=alignedSize(bufferZone);
int ret=send(sock, bufferZone, sz, 0);
if ( ret != sz )
LOG_W(HW,"Wrote socket doesn't return size %d (val: %d, errno:%d)\n",
sz, ret, errno);
bufferZone+=sz;
nbBlocks--;
} while (nbBlocks);
return 0;
}