Pau Espin Pedrol | 1f46d24 | 2020-10-05 12:40:24 +0200 | [diff] [blame] | 1 | # osmo_gsm_tester: class defining a RF emulation object implemented using SRS ENB stdin interface |
| 2 | # |
| 3 | # Copyright (C) 2020 by sysmocom - s.f.m.c. GmbH |
| 4 | # |
| 5 | # Author: Pau Espin Pedrol <pespin@sysmocom.de> |
| 6 | # |
| 7 | # This program is free software: you can redistribute it and/or modify |
| 8 | # it under the terms of the GNU General Public License as |
| 9 | # published by the Free Software Foundation, either version 3 of the |
| 10 | # License, or (at your option) any later version. |
| 11 | # |
| 12 | # This program is distributed in the hope that it will be useful, |
| 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | # GNU General Public License for more details. |
| 16 | # |
| 17 | # You should have received a copy of the GNU General Public License |
| 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 19 | |
| 20 | import json |
| 21 | |
| 22 | from ..core import log |
| 23 | from .rfemu import RFemulation |
| 24 | |
| 25 | class RFemulationSrsStdin(RFemulation): |
| 26 | ############## |
| 27 | # PROTECTED |
| 28 | ############## |
| 29 | def __init__(self, conf): |
| 30 | super().__init__(conf, 'srsenb_stdin') |
| 31 | self.cell_id = int(conf.get('cell_id')) |
| 32 | if self.cell_id is None: |
| 33 | raise log.Error('No "cell_id" attribute provided in rfemu conf!') |
| 34 | self.enb = conf.get('enb') |
| 35 | if self.enb is None: |
| 36 | raise log.Error('No "srsenb" attribute provided in rfemu conf!') |
| 37 | |
| 38 | def __del__(self): |
| 39 | self.enb = None |
| 40 | |
| 41 | ############################# |
| 42 | # PUBLIC (test API included) |
| 43 | ############################# |
| 44 | def set_attenuation(self, db): |
Andre Puschmann | e3f40f9 | 2020-10-13 18:05:28 +0200 | [diff] [blame] | 45 | msg_str = 'cell_gain %d %f' % (self.cell_id, -db) |
Pau Espin Pedrol | 1f46d24 | 2020-10-05 12:40:24 +0200 | [diff] [blame] | 46 | self.dbg('sending stdin msg: "%s"' % msg_str) |
| 47 | self.enb.process.stdin_write(msg_str + '\n') |
| 48 | |
| 49 | def get_max_attenuation(self): |
| 50 | return 200 # maximum cell_gain value in srs. Is this correct value? |
| 51 | |
| 52 | # vim: expandtab tabstop=4 shiftwidth=4 |