Unverified Commit a90a7274 authored by Andrea Orlati's avatar Andrea Orlati Committed by GitHub
Browse files

fix issue #820: handled the error risen when trying to connect to the… (#821)



* fix issue #820: handled the error risen when trying to connect to the LNA board and commented out all the code trying to get data from the board. Now the
LNA bias parameters are zeros. Also get rid of the old K band derotator.

* SRT5GHzReceiver with CLOW LO

* SRT5GHz test configuration patched

* fix issue #820: handled (got rid) of an error coused by the lan control board replacement that could affect the setup process of the receiver

* Update .gitignore

.vscode extension

* Fix #820, upd. ReceiversLibrary and K band component

---------

Co-authored-by: default avatarAndrea Orlati <a.orati@ira.inaf.it>
Co-authored-by: default avatarGiuseppe Carboni <giuseppecarboni89@live.com>
Co-authored-by: default avatarSergio Poppi <s.poppi@gmail.com>

I will merge this now, if anything wrong may arise in the future, we will fix it
parent f6070e0e
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -50,3 +50,4 @@ SRT/Clients/SRTActiveSurfaceGUIClient/include/SRTActiveSurfaceGUI.h
SRT/Clients/SRTActiveSurfaceGUIClient/src/moc_SRTActiveSurfaceCore.cpp
SRT/Clients/SRTActiveSurfaceGUIClient/src/moc_SRTActiveSurfaceGUIui.cpp
SRT/Interfaces/SRTActiveSurfaceInterface/idl/SRTActiveSurfaceBoss.idl
.vscode/settings.json
+1 −0
Original line number Diff line number Diff line
@@ -124,6 +124,7 @@ private:
    const DWORD m_timeout;
    const BYTE m_master_address;
    const BYTE m_slave_address;
    bool m_connected;
    IRA::CSocket *m_socket;
    unsigned long long m_id;
    BYTE m_command_type;
+6 −6
Original line number Diff line number Diff line
@@ -667,8 +667,8 @@ public:
            const BYTE port_type=MCB_PORT_TYPE_DIO,
            const BYTE port_number_sd=MCB_PORT_NUMBER_13,
            const BYTE port_number_vlbi=MCB_PORT_NUMBER_14,
            const BYTE value_sd=0x00,
            const BYTE value_vlbi=0x01
            const BYTE value_sd=0x01,
            const BYTE value_vlbi=0x00
    );


@@ -682,7 +682,7 @@ public:
    bool isSingleDishModeOn(
            const BYTE data_type=MCB_CMD_DATA_TYPE_B01,
            const BYTE port_type=MCB_PORT_TYPE_DIO, 
            const BYTE port_number=MCB_PORT_NUMBER_29
            const BYTE port_number=MCB_PORT_NUMBER_13
    );


@@ -704,8 +704,8 @@ public:
            const BYTE port_type=MCB_PORT_TYPE_DIO,
            const BYTE port_number_vlbi=MCB_PORT_NUMBER_14,
            const BYTE port_number_sd=MCB_PORT_NUMBER_13,
            const BYTE value_vlbi=0x00,
            const BYTE value_sd=0x01
            const BYTE value_vlbi=0x01,
            const BYTE value_sd=0x00
    );


@@ -719,7 +719,7 @@ public:
    bool isVLBIModeOn(
            const BYTE data_type=MCB_CMD_DATA_TYPE_B01,
            const BYTE port_type=MCB_PORT_TYPE_DIO,
            const BYTE port_number=MCB_PORT_NUMBER_30
            const BYTE port_number=MCB_PORT_NUMBER_14
    );

    
+5 −1
Original line number Diff line number Diff line
@@ -53,7 +53,7 @@ PY_SCRIPTS =

EXECUTABLES     = 
EXECUTABLES_L   = Test1 Test2 TestDBTable TestTypes TestMicroControllerBoard TestReceiverControl TestLogDike TestTimeTaggedCircularArray  \
				  TestFlux TestTimer TestRounding
				  TestFlux TestTimer TestRounding TestCommandRXBoard

#
# <brief description of xxxxx program>
@@ -75,6 +75,10 @@ TestMicroControllerBoard_LIBS = IRALibrary
TestReceiverControl_OBJECTS   = TestReceiverControl
TestReceiverControl_LIBS      = IRALibrary

TestCommandRXBoard_OBJECTS   = TestCommandRXBoard
TestCommandRXBoard_LIBS      = IRALibrary


TestLogDike_OBJECTS = TestDike
TestLogDike_LIBS      = IRALibrary ClientErrors

+29 −16
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@ MicroControllerBoard::MicroControllerBoard(
        const BYTE master_address, const BYTE slave_address, 
        const DWORD timeout) : 
                m_IP(IP), m_port(port), m_timeout(timeout), m_master_address(master_address), 
                m_slave_address(slave_address),
                m_slave_address(slave_address), m_connected(false),
                m_socket(NULL), m_id(0), m_command_type(0x00)
{
    try {
@@ -17,9 +17,11 @@ MicroControllerBoard::MicroControllerBoard(
    catch (std::bad_alloc& ex) {
        throw MicroControllerBoardEx("Memory allocation error");
    }

    if(m_socket->Create(m_Error, CSocket::STREAM) == CSocket::FAIL)
        throw MicroControllerBoardEx("Error creating socket");
	 if (strcmp(m_IP.c_str(),"")!=0) {
    	if(m_socket->Create(m_Error, CSocket::STREAM) == CSocket::FAIL) throw MicroControllerBoardEx("Error creating socket");
    } else {
    	m_connected=false;
    }
}

MicroControllerBoard::~MicroControllerBoard() {
@@ -31,12 +33,13 @@ MicroControllerBoard::~MicroControllerBoard() {


void MicroControllerBoard::openConnection(void) {

	 if (strcmp(m_IP.c_str(),"")==0) return;
    if (m_socket->Connect(m_Error, m_IP.c_str(), m_port) == CSocket::FAIL) {
        closeConnection();
        throw MicroControllerBoardEx(std::string("Error connecting to ") + m_IP + ":" + any2string(m_port));
    }
    else {
    	  m_connected=true;
        if(m_socket->setSockMode(m_Error, CSocket::BLOCKINGTIMEO, m_timeout) != CSocket::SUCCESS) {
            closeConnection();
            throw MicroControllerBoardEx("Error configuring socket");
@@ -48,8 +51,9 @@ CSocket::SocketStatus MicroControllerBoard::getConnectionStatus(void) { return(m

void MicroControllerBoard::closeConnection(void) { 
    pthread_mutex_lock(&m_socket_mutex); 
    if(m_socket != NULL && m_socket->getStatus()) {
    if(m_socket != NULL && m_socket->getStatus() && m_connected) {
        m_socket->Close(m_Error);
        m_connected=false;

        if(!m_Error.isNoError()) 
            std::cerr << "An error occured closing the socket" << endl;
@@ -60,13 +64,15 @@ void MicroControllerBoard::closeConnection(void) {
}

std::vector<BYTE> MicroControllerBoard::receive(void) { 
    pthread_mutex_lock(&m_socket_mutex); 

    BYTE msg[MCB_BUFF_LIMIT] = {0x00};
    bool is_short_cmd = false, has_data_cmd = false;
    BYTE sh_command = 0x00; // Shifted command (command_type - MCB_CMD_TYPE_EXTENDED)
    std::vector<BYTE> data, clean_data;
    
    std::ostringstream msg_stream;    
    if (!m_connected) throw MicroControllerBoardEx("Board connection disabled");
    pthread_mutex_lock(&m_socket_mutex); 
    // Receive the response one byte at once 
    try {
        for(size_t j = 0; j < MCB_HT_COUNTER; j++) {
@@ -77,8 +83,10 @@ std::vector<BYTE> MicroControllerBoard::receive(void) {
                    continue;
            }
        }
        if(msg[0] != MCB_CMD_STX)
        if(msg[0] != MCB_CMD_STX) {
        	throw MicroControllerBoardEx("No answer header received");
        }
            
        else {
            m_answer.clear();
            m_answer.push_back(msg[0]);
@@ -125,8 +133,9 @@ std::vector<BYTE> MicroControllerBoard::receive(void) {
                    has_data_cmd = false;
            }

            if(msg[MCB_BASE_ANSWER_LENGTH])
            if(msg[MCB_BASE_ANSWER_LENGTH]) {
               throw MicroControllerBoardEx("An error occurs. Error code: " + any2string(int(msg[MCB_BASE_ANSWER_LENGTH])));
            }

            // If the answer should have data and there aren't any errors, then continue the reception
            if(has_data_cmd) {
@@ -138,8 +147,10 @@ std::vector<BYTE> MicroControllerBoard::receive(void) {
                    msg_stream << msg[MCB_BASE_ANSWER_LENGTH];
                    m_answer.push_back(msg[MCB_BASE_ANSWER_LENGTH]);
                }
                else
                else {
                	pthread_mutex_unlock(&m_socket_mutex);
                	throw MicroControllerBoardEx("Error: data length not received.");
                }

                // Get the parameters
                for(int i=MCB_BASE_ANSWER_LENGTH + 1; i < MCB_BASE_ANSWER_LENGTH + 1 + int(msg[MCB_BASE_ANSWER_LENGTH]); i++) {
@@ -173,9 +184,10 @@ std::vector<BYTE> MicroControllerBoard::receive(void) {
                        break;
                } while(counter < MCB_HT_COUNTER);

                if(msg[idx] != MCB_CMD_ETX)
                if(msg[idx] != MCB_CMD_ETX) {
                  throw MicroControllerBoardEx("Answer terminator not found.");
                }
            }
            pthread_mutex_unlock(&m_socket_mutex); 
            
            // Check if master and slave are the same for answer and request
@@ -231,6 +243,7 @@ std::vector<BYTE> MicroControllerBoard::receive(void) {
}

void MicroControllerBoard::send(const BYTE command, std::vector<BYTE> parameters) {
	if (!m_connected) throw MicroControllerBoardEx("Board connection disabled");
    pthread_mutex_lock(&m_socket_mutex); 
    try {
        if(command >= MCB_CMD_TYPE_MIN_EXT && command <= MCB_CMD_TYPE_MAX_ABB) {
Loading