Commit 25603521 authored by ghaddab's avatar ghaddab

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@4709 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent 222a5de1
......@@ -21,11 +21,11 @@ static bool any_bad_argument(const octave_value_list &args)
octave_value v,w;
int i;
if (args.length()!=16)
if (args.length()!=17)
{
error(FCNNAME);
error("Wrong number of parameters! Did you add the card number as first parameter?");
error("syntax: oarf_config_exmimo(card,freqrx,freq_tx,tdd_config,syncmode,rxgain,txgain,eNB_flag,rf_mode,rx_dc,rf_local,rf_vcolocal,rffe_rxg_low,rffe_rxg_final,autocal)");
error("syntax: oarf_config_exmimo(card,freqrx,freq_tx,tdd_config,syncmode,rxgain,txgain,eNB_flag,rf_mode,rx_dc,rf_local,rf_vcolocal,rffe_rxg_low,rffe_rxg_final,autocal,resampling_factor)");
return true;
}
......@@ -246,7 +246,24 @@ static bool any_bad_argument(const octave_value_list &args)
error("number of columns for autocal must be 4\n");
}
v = args(16);
if (v.columns() == 4)
{
for (i=0;i<v.columns();i++)
{
if ((v.row_vector_value()(i)<0.0) || (v.row_vector_value()(i)>2.0)) {
error(FCNNAME);
error("resampling_factor %d must be 0, 1 or 2 (got %f).",i,v.row_vector_value()(i));
return true;
}
}
}
else {
error(FCNNAME);
error("number of columns for resampling_factor must be 4\n");
}
if ( !args(0).is_real_scalar() )
{
error(FCNNAME);
......@@ -284,6 +301,7 @@ DEFUN_DLD (oarf_config_exmimo, args, nargout,"configure the openair interface -
RowVector rffe_rxg_final = args(13).row_vector_value();
RowVector rffe_band = args(14).row_vector_value();
RowVector autocal = args(15).row_vector_value();
RowVector resampling_factor = args(16).row_vector_value();
int rffe_band_int;
exmimo_config_t *p_exmimo_config;
......@@ -301,6 +319,8 @@ DEFUN_DLD (oarf_config_exmimo, args, nargout,"configure the openair interface -
error("Error mapping bigshm");
if (ret == -3)
error("Error mapping RX or TX buffer");
if (ret == -5)
error("Error Firmware/Software do not match");
return octave_value(ret);
}
......@@ -332,7 +352,7 @@ DEFUN_DLD (oarf_config_exmimo, args, nargout,"configure the openair interface -
p_exmimo_config->framing.eNB_flag = eNB_flag;
p_exmimo_config->framing.tdd_config = tdd_config;
p_exmimo_config->framing.multicard_syncmode = multicard_syncmode;
p_exmimo_config->framing.resampling_factor = 2;
// p_exmimo_config->framing.resampling_factor = 2;
for (ant=0; ant<4; ant++)
{
......@@ -351,7 +371,7 @@ DEFUN_DLD (oarf_config_exmimo, args, nargout,"configure the openair interface -
p_exmimo_config->rf.rffe_gain_txhigh[ant] = 31;
p_exmimo_config->rf.rffe_gain_rxfinal[ant] = rffe_rxg_final(ant);
p_exmimo_config->rf.rffe_gain_rxlow[ant] = rffe_rxg_low(ant);
p_exmimo_config->framing.resampling_factor[ant] = resampling_factor(ant);
rffe_band_int = (int) rffe_band(ant);
switch (rffe_band_int) {
case 0:
......
......@@ -85,6 +85,7 @@ DEFUN_DLD (oarf_get_frame, args, nargout,"Get frame")
int i,aa;
short *rx_sig[MAX_CARDS * MAX_ANTENNAS];
int ret;
int frame_length_samples=0;
ret = openair0_open();
if ( ret != 0 )
......@@ -130,8 +131,19 @@ DEFUN_DLD (oarf_get_frame, args, nargout,"Get frame")
}
printf("\n");
}
ComplexMatrix dx (FRAME_LENGTH_COMPLEX_SAMPLES, numant);
if (openair0_exmimo_pci[0].exmimo_config_ptr->framing.resampling_factor[0] == 2)
frame_length_samples = FRAME_LENGTH_COMPLEX_SAMPLES;
else if (openair0_exmimo_pci[0].exmimo_config_ptr->framing.resampling_factor[0] == 1)
frame_length_samples = FRAME_LENGTH_COMPLEX_SAMPLES*2;
else if (openair0_exmimo_pci[0].exmimo_config_ptr->framing.resampling_factor[0] == 0)
frame_length_samples = FRAME_LENGTH_COMPLEX_SAMPLES*4;
else
frame_length_samples = FRAME_LENGTH_COMPLEX_SAMPLES;
printf("Info : Only resampling_factor of channel 0 is taken into account for copying received frame for all the other chains\n");
ComplexMatrix dx (frame_length_samples, numant);
/*
// set the tx buffer to 0x00010001 to put switch in rx mode
......@@ -152,13 +164,13 @@ DEFUN_DLD (oarf_get_frame, args, nargout,"Get frame")
//printf("adc_head[%i] = %p ", i, rx_sig[i]);
}
printf("\n");
printf("frame length samples : %d\n",frame_length_samples);
// msg("Getting buffer...\n");
if ( no_getframe_ioctl == 0)
openair0_get_frame(card);
for (i=0; i<FRAME_LENGTH_COMPLEX_SAMPLES; i++)
for (i=0; i<frame_length_samples; i++)
for (aa=0; aa<numant; aa++)
dx(i, aa) = Complex( rx_sig[aa][i*2], rx_sig[aa][i*2+1] );
......
......@@ -61,6 +61,7 @@ DEFUN_DLD (oarf_send_frame, args, nargout,"Send frame")
octave_value returnvalue;
int i, ret;
unsigned int length,aa,nbits, numcols;
unsigned int resampling_factor[4];
int dummy=0;
ret = openair0_open();
......@@ -85,12 +86,24 @@ DEFUN_DLD (oarf_send_frame, args, nargout,"Send frame")
printf("colums = %d, rows = %d\n\n\n", numcols, args(1).rows());
if ( numcols<1 || (numcols > openair0_num_antennas[card]) || (args(1).rows()!=76800))
if ( numcols<1 || (numcols > openair0_num_antennas[card]))
{
error(FCNNAME);
error("input array must be of size (%d, 1..%d).", 76800, openair0_num_antennas[card]);
error("input array must be of column size 1..%d.", openair0_num_antennas[card]);
return octave_value_list();
}
for (i=0;i<4;i++)
resampling_factor[i] = (openair0_exmimo_pci[card].exmimo_config_ptr)->framing.resampling_factor[i];
for (i=0;i<numcols;i++){
if (args(1).rows()<(76800*(1 << (2-resampling_factor[i]))))
{
error(FCNNAME);
error("input array column number %d must be of size %d.",i,(76800*(1 << (2-resampling_factor[i]))));
return octave_value_list();
}
}
if ((openair0_exmimo_pci[card].exmimo_config_ptr->framing.tdd_config & TXRXSWITCH_MASK) != TXRXSWITCH_TESTTX)
printf("Warning: tdd_config is not set to TXRXSWITCH_TESTTX! You better know what you are doing! :)\n");
......@@ -102,7 +115,7 @@ DEFUN_DLD (oarf_send_frame, args, nargout,"Send frame")
{
if (nbits==16)
{
for (i=0;i<76800;i++)
for (i=0;i<(76800*(1 << (2-resampling_factor[aa])));i++)
{
if (i<64)
printf("%d: %d,%d\n",i,(short)real(dx(i,aa)),(short)imag(dx(i,aa)));
......@@ -112,7 +125,7 @@ DEFUN_DLD (oarf_send_frame, args, nargout,"Send frame")
}
else if (nbits==8)
{
for (i=0;i<76800;i++)
for (i=0;i<(76800*(1 << (2-resampling_factor[aa])));i++)
{
if (i<64)
printf("%d: %d,%d\n",i,char(real(dx(i,aa))),char(imag(dx(i,aa))));
......
// Riadh Ghaddab - created 2013-10-24
// see http://www.gnu.org/software/octave/doc/interpreter/Dynamically-Linked-Functions.html#Dynamically-Linked-Functions
// and http://wiki.octave.org/wiki.pl?CodaTutorial
// and http://octave.sourceforge.net/coda/c58.html
// compilation: see Makefile
#include <octave/oct.h>
extern "C" {
#include "openair0_lib.h"
}
#define FCNNAME "oarf_stop_without_reset"
#define TRACE 1
static bool any_bad_argument(const octave_value_list &args)
{
octave_value v;
if (args.length()!=1)
{
error(FCNNAME);
error("syntax: oarf_stop(card)");
return true;
}
v=args(0);
if ((!v.is_real_scalar()) || (v.scalar_value() < -1) || (floor(v.scalar_value()) != v.scalar_value()) || (v.scalar_value() >= MAX_CARDS))
{
error(FCNNAME);
error("card must be 0..number of cards-1.\nUse card = -1 to stop all cards.\n");
return true;
}
return false;
}
DEFUN_DLD (oarf_stop, args, nargout,"Stop RT acquisition and write registers.")
{
int a,b;
if (any_bad_argument(args))
return octave_value_list();
int card = args(0).int_value();
int ret;
octave_value returnvalue;
ret = openair0_open();
if ( ret != 0 )
{
error(FCNNAME);
if (ret == -1)
error("Error opening /dev/openair0");
if (ret == -2)
error("Error mapping bigshm");
if (ret == -3)
error("Error mapping RX or TX buffer");
return octave_value(ret);
}
if (card <-1 || card >= openair0_num_detected_cards)
error("Invalid card number (num detected cards: %d, card: %d)!", openair0_num_detected_cards, card);
if (card == -1) {
for (card = 0; card < openair0_num_detected_cards; card++)
returnvalue = openair0_stop( card );
} else
returnvalue = openair0_stop_without_reset( card );
openair0_close( );
return octave_value(returnvalue);
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment