/*******************************************************************************
OpenAirInterface
Copyright(c) 1999 - 2014 Eurecom
OpenAirInterface is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenAirInterface is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenAirInterface.The full GNU General Public License is
included in this distribution in the file called "COPYING". If not,
see .
Contact Information
OpenAirInterface Admin: openair_admin@eurecom.fr
OpenAirInterface Tech : openair_tech@eurecom.fr
OpenAirInterface Dev : openair4g-devel@eurecom.fr
Address : Eurecom, Campus SophiaTech, 450 Route des Chappes, CS 50193 - 06904 Biot Sophia Antipolis cedex, FRANCE
*******************************************************************************/
#include "PHY/types.h"
#include "PHY/defs.h"
#include "PHY/vars.h"
#ifdef CBMIMO1
#include "ARCH/CBMIMO1/DEVICE_DRIVER/cbmimo1_device.h"
#include "ARCH/CBMIMO1/DEVICE_DRIVER/defs.h"
#endif
#ifdef PLATON
#include "daq.h"
#endif
#include "PHY/CONFIG/vars.h"
#include "MAC_INTERFACE/vars.h"
#include
#include
#include
#include
#include
#include
#include
//#include
#include
//#include
//#include
#include
//#include
#include
//#include
//#include
void main(int argc, char** argv) {
int i;
FILE *rxsig_fd;
int openair_fd,rx_sig_fifo_fd,rf_cntl_fifo_fd,sched_cnt;
unsigned int params;
int result;
/* ############ variables declaration for sensing #######*/
s16 *samples;
int size_signal = 20480;
struct complex16 signal[size_signal];
printf("Allocating memory for PHY_VARS\n");
PHY_vars = (PHY_VARS *)malloc(sizeof(PHY_VARS));
PHY_config = (PHY_CONFIG *)malloc(sizeof(PHY_CONFIG));
mac_xface = (MAC_xface *)malloc(sizeof(MAC_xface));
if((config = fopen("./openair_config.cfg","r")) == NULL) // this can be configured
{
printf("[Main USER] The widens configuration file could not be found!");
exit(0);
}
if ((scenario= fopen("./openair_scenario.scn","r")) ==NULL)
{
printf("[Main USER] The widens scenario file could not be found!");
exit(0);
}
printf("Opened configuration files\n");
printf("[openair][INFO][START] Opening /dev/openair0\n");
if ((openair_fd = open("/dev/openair0", O_RDWR,0)) <0)
{
fprintf(stderr,"Error %d opening /dev/openair0\n",openair_fd);
exit(-1);
}
rx_sig_fifo_fd=open("/dev/rtf59",O_RDONLY);
if (rx_sig_fifo_fd==-1)
{
printf("Can not open rxsig FIFO (/dev/rtf59)!\n");
exit(0);
}
rf_cntl_fifo_fd=open("/dev/rtf60",O_RDONLY);
if (rf_cntl_fifo_fd==-1)
{
printf("Can not open rf_cntl FIFO (/dev/rtf60)!\n");
exit(0);
}
if ((rxsig_fd = fopen("rxsig0.dat","w")) == NULL) {
printf("Cannot open rxsig0 output file\n");
exit(0);
}
reconfigure_MACPHY(scenario);
mac_xface->is_cluster_head = 0;
phy_init(NB_ANTENNAS_TX);
printf("Initialized PHY variables\n");
//mac_init();
/*
PHY_config->PHY_framing.fc_khz = 1907600;
result=ioctl(openair_fd, openair_DUMP_CONFIG,(char *)PHY_config);
if (result == 0) {
printf ("[openair][CONFIG][INFO] loading openair configuration in kernel space\n");
} else {
printf ("[openair][START][INFO] loading openair configuration in kernel space failed \n");
}
*/
params = 1|(3<<1)|(3<<3);
result=ioctl(openair_fd,openair_GET_BUFFER,(void *)¶ms);
if (result == 0) {
printf ("[openair][CONFIG][INFO] getting rx buffer\n");
} else {
printf ("[openair][START][INFO] getting rx buffer failed \n");
}
read(rf_cntl_fifo_fd,(void *)&sched_cnt,4);
printf("Sched count %d\n",sched_cnt);
for (i=0;irx_vars[i].RX_DMA_BUFFER,
FRAME_LENGTH_BYTES);
}
printf("Got Frame for %d antennas, demodulating\n",NB_ANTENNAS);
fwrite(PHY_vars->rx_vars[0].RX_DMA_BUFFER,1,FRAME_LENGTH_BYTES,rxsig_fd);
/*############### sensing code################*/
samples = (s16 *)PHY_vars->rx_vars[0].RX_DMA_BUFFER;
for (i=0;i