Fixed bug that prevented the code to compile in Mac OS. Documentation added

git-svn-id: https://svn.code.sf.net/p/gnss-sdr/code/trunk@189 64b25241-fba3-4117-9849-534c7e92360d
This commit is contained in:
Carles Fernandez 2012-03-24 02:53:00 +00:00
parent 0319b180c6
commit 3533a08330
6 changed files with 91 additions and 80 deletions

View File

@ -1,6 +1,7 @@
/*! /*!
* \file cordic.cc * \file cordic.cc
* \brief Implementation of the CORDIC (COordinate Rotation DIgital Computer) algorithm * \brief Implementation of the CORDIC (COordinate Rotation DIgital Computer) algorithm.
* This implementation is NOT OPTIMIZED, only for demonstration purposes
* \author Carles Fernandez-Prades, 2012. cfernandez(at)cttc.es * \author Carles Fernandez-Prades, 2012. cfernandez(at)cttc.es
* *
* This is a modified implementation of the one found at * This is a modified implementation of the one found at

View File

@ -1,10 +1,8 @@
/*! /*!
* \file cordic.h * \file cordic.h
* \brief Interface of the CORDIC (COordinate Rotation DIgital Computer) algorithm * \brief Interface of the CORDIC (COordinate Rotation DIgital Computer) algorithm.
* \author Carles Fernandez-Prades, 2012. cfernandez(at)cttc.es * \author Carles Fernandez-Prades, 2012. cfernandez(at)cttc.es
* *
* This is a modified implementation of the one found at
* http://www.dspguru.com/dsp/faqs/cordic
* *
* ------------------------------------------------------------------------- * -------------------------------------------------------------------------
* *
@ -42,6 +40,11 @@ typedef struct tagCORDIC_TABLE {
double phase_rads; double phase_rads;
} CORDIC_TABLE; } CORDIC_TABLE;
/*!
* \brief Implementation of the CORDIC (COordinate Rotation DIgital Computer) algorithm.
* This implementation is NOT OPTIMIZED, only for demonstration purposes
*/
class Cordic class Cordic
{ {
public: public:

View File

@ -1,6 +1,6 @@
/*! /*!
* \file tcp_communication.h * \file tcp_communication.cc
* \brief Library with the definition of the TCP communication class * \brief Implementation of the TCP communication class
* \author David Pubill, 2011. dpubill(at)cttc.es * \author David Pubill, 2011. dpubill(at)cttc.es
* *
* *
@ -38,78 +38,86 @@
#define NUM_TX_VARIABLES 7 #define NUM_TX_VARIABLES 7
#define NUM_RX_VARIABLES 3 #define NUM_RX_VARIABLES 3
tcp_communication::tcp_communication() : tcp_socket_(io_service_){
}
tcp_communication::~tcp_communication(){ tcp_communication::tcp_communication() : tcp_socket_(io_service_)
} {}
tcp_communication::~tcp_communication()
{}
int tcp_communication::listen_tcp_connection(size_t d_port_) int tcp_communication::listen_tcp_connection(size_t d_port_)
{ {
try try
{ {
//! Specify IP type and port // Specify IP type and port
boost::asio::ip::tcp::endpoint endpoint(boost::asio::ip::tcp::v4(), d_port_); boost::asio::ip::tcp::endpoint endpoint(boost::asio::ip::tcp::v4(), d_port_);
boost::asio::ip::tcp::acceptor acceptor(io_service_, endpoint); boost::asio::ip::tcp::acceptor acceptor(io_service_, endpoint);
//! Reuse the IP address for each connection // Reuse the IP address for each connection
acceptor.set_option(boost::asio::ip::tcp::acceptor::reuse_address(true)); acceptor.set_option(boost::asio::ip::tcp::acceptor::reuse_address(true));
std::cout << "Server ready on port " << d_port_ << std::endl; std::cout << "Server ready on port " << d_port_ << std::endl;
//! Listen for a connection and accept it // Listen for a connection and accept it
acceptor.listen(12); acceptor.listen(12);
acceptor.accept(tcp_socket_); acceptor.accept(tcp_socket_);
std::cout << "Socket accepted on port " << d_port_ << std::endl; std::cout << "Socket accepted on port " << d_port_ << std::endl;
} }
catch(std::exception& e) catch(std::exception& e)
{ {
std::cerr << "Exception: " << e.what() << std::endl; std::cerr << "Exception: " << e.what() << std::endl;
} }
return false; return false;
} }
void tcp_communication::send_receive_tcp_packet(boost::array<float, NUM_TX_VARIABLES> buf, tcp_packet_data *tcp_data_) void tcp_communication::send_receive_tcp_packet(boost::array<float, NUM_TX_VARIABLES> buf, tcp_packet_data *tcp_data_)
{ {
int controlc = 0; int controlc = 0;
boost::array<float, NUM_RX_VARIABLES> readbuf; boost::array<float, NUM_RX_VARIABLES> readbuf;
float d_control_id_ = buf.data()[6]; float d_control_id_ = buf.data()[6];
try try
{ {
//! Send a TCP packet // Send a TCP packet
tcp_socket_.write_some(boost::asio::buffer(buf)); tcp_socket_.write_some(boost::asio::buffer(buf));
//! Read the received TCP packet // Read the received TCP packet
tcp_socket_.read_some(boost::asio::buffer(readbuf)); tcp_socket_.read_some(boost::asio::buffer(readbuf));
//! Recover the variables received // Recover the variables received
tcp_data_->proc_pack_code_error = readbuf.data()[0]; tcp_data_->proc_pack_code_error = readbuf.data()[0];
tcp_data_->proc_pack_carr_error = readbuf.data()[1]; tcp_data_->proc_pack_carr_error = readbuf.data()[1];
//! Control. The GNSS-SDR program ends if an error in a TCP packet is detected. // Control. The GNSS-SDR program ends if an error in a TCP packet is detected.
if (d_control_id_ != readbuf.data()[2]) if (d_control_id_ != readbuf.data()[2])
{ {
throw "Packet error!"; throw "Packet error!";
} }
} }
catch(std::exception& e) catch(std::exception& e)
{ {
std::cerr << "Exception: " << e.what() << ". Please press Ctrl+C to end the program." << std::endl; std::cerr << "Exception: " << e.what() << ". Please press Ctrl+C to end the program." << std::endl;
std::cin >> controlc; std::cin >> controlc;
} }
return; return;
} }
void tcp_communication::close_tcp_connection(size_t d_port_) void tcp_communication::close_tcp_connection(size_t d_port_)
{ {
//! Close the TCP connection // Close the TCP connection
tcp_socket_.close(); tcp_socket_.close();
std::cout << "Socket closed on port " << d_port_ << std::endl; std::cout << "Socket closed on port " << d_port_ << std::endl;
return;
return;
} }

View File

@ -1,6 +1,6 @@
/*! /*!
* \file tcp_communication.h * \file tcp_communication.h
* \brief Library with the definition of the TCP communication class * \brief Interface of the TCP communication class
* \author David Pubill, 2011. dpubill(at)cttc.es * \author David Pubill, 2011. dpubill(at)cttc.es
* *
* *
@ -29,26 +29,28 @@
* ------------------------------------------------------------------------- * -------------------------------------------------------------------------
*/ */
#ifndef TCP_COMMUNICATION_H_ #ifndef GNSS_SDR_TCP_COMMUNICATION_H_
#define TCP_COMMUNICATION_H_ #define GNSS_SDR_TCP_COMMUNICATION_H_
#include <boost/asio.hpp> #include <boost/asio.hpp>
#include <boost/array.hpp>
#include "tcp_packet_data.h" #include "tcp_packet_data.h"
class tcp_communication class tcp_communication
{ {
public: public:
tcp_communication(); tcp_communication();
~tcp_communication(); ~tcp_communication();
int listen_tcp_connection(size_t d_port_); int listen_tcp_connection(size_t d_port_);
void send_receive_tcp_packet(boost::array<float, 7> buf, tcp_packet_data *tcp_data_); void send_receive_tcp_packet(boost::array<float,7> buf, tcp_packet_data *tcp_data_);
void close_tcp_connection(size_t d_port_); void close_tcp_connection(size_t d_port_);
private: private:
boost::asio::io_service io_service_; boost::asio::io_service io_service_;
boost::asio::ip::tcp::socket tcp_socket_; boost::asio::ip::tcp::socket tcp_socket_;
}; };
#endif #endif

View File

@ -1,6 +1,6 @@
/*! /*!
* \file tcp_packet_data.h * \file tcp_packet_data.h
* \brief Library with the definition of the TCP packet data class * \brief Interface of the TCP packet data class
* \author David Pubill, 2011. dpubill(at)cttc.es * \author David Pubill, 2011. dpubill(at)cttc.es
* *
* *
@ -29,18 +29,16 @@
* ------------------------------------------------------------------------- * -------------------------------------------------------------------------
*/ */
#ifndef TCP_PACKET_DATA_H_ #ifndef GNSS_SDR_TCP_PACKET_DATA_H_
#define TCP_PACKET_DATA_H_ #define GNSS_SDR_TCP_PACKET_DATA_H_
class tcp_packet_data class tcp_packet_data
{ {
public: public:
tcp_packet_data(); tcp_packet_data();
float proc_pack_code_error;
float proc_pack_carr_error;
~tcp_packet_data(); ~tcp_packet_data();
float proc_pack_code_error;
float proc_pack_carr_error;
}; };
#endif #endif

View File

@ -11,7 +11,7 @@
* *
* ------------------------------------------------------------------------- * -------------------------------------------------------------------------
* *
* Copyright (C) 2010-2011 (see AUTHORS file for a list of contributors) * Copyright (C) 2010-2012 (see AUTHORS file for a list of contributors)
* *
* GNSS-SDR is a software defined Global Navigation * GNSS-SDR is a software defined Global Navigation
* Satellite Systems receiver * Satellite Systems receiver
@ -41,7 +41,8 @@
* \brief This class implements a 2nd order DLL filter for code tracking loop. * \brief This class implements a 2nd order DLL filter for code tracking loop.
* *
* The algorithm is described in: * The algorithm is described in:
* K.Borre, D.M.Akos, N.Bertelsen, P.Rinder, and S. H. Jensen, A Software-Defined GPS and Galileo Receiver. A Single-Frequency Approach, * K.Borre, D.M.Akos, N.Bertelsen, P.Rinder, and S. H. Jensen, A Software-Defined GPS
* and Galileo Receiver. A Single-Frequency Approach,
* Birkhauser, 2007, Applied and Numerical Harmonic Analysis. * Birkhauser, 2007, Applied and Numerical Harmonic Analysis.
*/ */
class Tracking_2nd_DLL_filter class Tracking_2nd_DLL_filter
@ -53,18 +54,16 @@ private:
float d_pdi_code; float d_pdi_code;
float d_dllnoisebandwidth; float d_dllnoisebandwidth;
float d_dlldampingratio; float d_dlldampingratio;
float d_old_code_error; float d_old_code_error;
float d_old_code_nco; float d_old_code_nco;
void calculate_lopp_coef(float* tau1,float* tau2, float lbw, float zeta, float k); void calculate_lopp_coef(float* tau1,float* tau2, float lbw, float zeta, float k);
public: public:
void set_DLL_BW(float dll_bw_hz); //! Set DLL loop bandwidth [Hz] void set_DLL_BW(float dll_bw_hz); //! Set DLL filter bandwidth [Hz]
void initialize(float d_acq_code_phase_samples); void initialize(float d_acq_code_phase_samples); //! Start tracking with acquisition information
float get_code_nco(float DLL_discriminator); float get_code_nco(float DLL_discriminator); //! Numerically controlled oscillator
Tracking_2nd_DLL_filter(); Tracking_2nd_DLL_filter();
~Tracking_2nd_DLL_filter(); ~Tracking_2nd_DLL_filter();
}; };
#endif #endif