⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 connection_local.c

📁 This a framework to test new ideas in transmission technology. Actual development is a LDPC-coder in
💻 C
字号:
/***************************************************************************          connection_local.c  -  Helps connection.c                            -------------------    begin                :  2002    authors              :  Linus Gasser    emails               :  linus.gasser@epfl.ch ***************************************************************************//***************************************************************************                                 Changes                                 ------- date - name - description 2002-12-19 - ineiti - init  **************************************************************************//*************************************************************************** *                                                                         * *   This program 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 2 of the License, or     * *   (at your option) any later version.                                   * *                                                                         * ***************************************************************************//** * This got split for aesthetical purposes from connection.c */#define DBG_LVL 0#include "system.h"#include "debugging.h"#include "memory.h"#include "sdb.h"#include "subsystem.h"#include "connection_local.h"// The array for all connectionsconnection_t *conn_table;// The next ID to giveint conn_next_id;/** * Lots of initialisation for the connection-add part. All this has been * put here so as to make swr_connection_add() a bit more nice. */int conn_get_ids( connection_t *tmp,                  swr_sdb_id sender, swr_sdb_id receiver,                  int output, int input ) {  swr_spc_id_t ssend, srcv;  swr_signal_type_t csend, crcv;  int i;  tmp->sender = sender;  tmp->receiver = receiver;  // Check for next free ID  for ( i=0; i < MAX_CONNECTIONS; i++ ) {    if ( ENTRY( i + conn_next_id ).ID == -1 )      break;  }  if ( i < MAX_CONNECTIONS ) {    conn_next_id += i;    tmp->ID = conn_next_id;  } else {    PR_DBG( 0, "ERROR: all ids full" );    return -1;  }  // Get the SPMs  ssend = swr_sdb_spm( sender );  srcv = swr_sdb_spm( receiver );  if ( ( ssend | srcv ) < 0 ) {    PR_DBG( 0, "ERROR: No corresponding SPM found\n" );    return -1;  }  // The SDB-structures  tmp->sdb_send = swr_sdb_get_struct( sender );  tmp->sdb_rcv = swr_sdb_get_struct( receiver );  // Get the types of connections  csend = tmp->sdb_send->cdb_desc->outputs.ports[ output ].signal_type;  crcv = tmp->sdb_rcv->cdb_desc->inputs.ports[ input ].signal_type;  if ( ( csend | crcv ) < 0 ) {    PR_DBG( 0, "ERROR: Input or Output is wrong\n" );    return -1;  }  if ( csend != crcv ) {    PR_DBG( 0, "ERROR: Input and Output don't match\n" );    return -1;  }  // If we connect to a module that is ready for sending, we have to  // delete this data...  tmp->sdb_send->port_out[ output ].flags &= ~SWR_PORT_DATA;  // Write some more stuff in tmp  // connection request  tmp->rsend.port_out = output;  tmp->rsend.port_in = input;  tmp->rsend.dir = OUTPUT;  tmp->rsend.sdb_id = tmp->receiver;  tmp->rsend.prop = NULL;  tmp->rsend.other_flags = tmp->sdb_rcv->port_in[ input ].flags;  tmp->rrcv.port_out = output;  tmp->rrcv.port_in = input;  tmp->rrcv.dir = INPUT;  tmp->rrcv.sdb_id = tmp->sender;  tmp->rrcv.prop = NULL;  tmp->rrcv.other_flags = tmp->sdb_send->port_out[ output ].flags;  PR_DBG( 3, "SDB-ids: From %i to %i\n", tmp->sender, tmp->receiver );  return 0;}/** * Sends the actual connect-msgs to the subsytem and waits for the * reply.. */int conn_send( connection_t *tmp ) {  int err = -1, i, part = 0;  char sndr_str[SWR_CDB_MAX_NAME_LENGTH], rcvr_str[SWR_CDB_MAX_NAME_LENGTH];  swr_propagation_t *res_send = NULL, *res_rcv = NULL;  // If any of the modules have a SWR_PORT_OWN_MALLOC, it has to be called  // first...  if ( tmp->rsend.other_flags & SWR_PORT_OWN_MALLOC ) {    part = 1;  }  for ( i=0; i<2; i++ ) {    switch( part ) {    case 0:      // Connect the sender      if ( swr_sdb_send_msg( tmp->sender, SUBS_MSG_CONNECT, &tmp->rsend, -1 ) < 0 ) {        PR_DBG( 0, "ERROR: couldn't send request to emitter\n" );        goto conn_send_err_1;      }      break;    case 1:      // Connect the receiver      if ( swr_sdb_send_msg( tmp->receiver, SUBS_MSG_CONNECT, &tmp->rrcv, -1 ) < 0 ) {        PR_DBG( 0, "ERROR: couldn't send request to receiver\n" );        goto conn_send_err_2;      }      break;    }    part ^= 1;  }  if ( tmp->rsend.prop ) {    PR_DBG( 4, "RESIZE from sender\n" );    res_send = tmp->rsend.prop;  } else {    PR_DBG( 4, "OK from sender\n" );  }  if ( tmp->rrcv.prop ) {    PR_DBG( 4, "RESIZE from receiver\n" );    res_rcv = tmp->rrcv.prop;    if ( res_send ) {      if ( res_send->size != res_rcv->size ) {        swr_cdb_get_name( tmp->sdb_send->cdb_desc->id, sndr_str );        swr_cdb_get_name( tmp->sdb_rcv->cdb_desc->id, rcvr_str );        PR_DBG( 0, "Resizing sender(%s) and receiver(%s) with different sizes(%i/%i)!\n",                sndr_str, rcvr_str, res_send->size, res_rcv->size );      }      res_rcv = NULL;    }  } else {    PR_DBG( 4, "OK from receiver\n" );  }  if ( res_rcv ) {    swr_sdb_send_msg( res_rcv->dest_sdb, SUBS_MSG_RESIZE, res_rcv, tmp->receiver );  }  if ( res_send ) {    swr_sdb_send_msg( res_send->dest_sdb, SUBS_MSG_RESIZE, res_send, tmp->sender );  }  return 0;conn_send_err_2:  err--;conn_send_err_1:  return err;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -