fake_trx: share and use common GSM constants
Previously there were multiple definitions of some common GSM constants in different modules. Let's share them. Change-Id: Id6cdfbc6e8688755a0df7e44daa512c9afa7dad2
This commit is contained in:
parent
ab7eb390cb
commit
5da2ac7197
|
@ -29,6 +29,7 @@ import sys
|
|||
|
||||
from rand_burst_gen import RandBurstGen
|
||||
from data_if import DATAInterface
|
||||
from gsm_shared import *
|
||||
|
||||
COPYRIGHT = \
|
||||
"Copyright (C) 2017 by Vadim Yanitskiy <axilirator@gmail.com>\n" \
|
||||
|
@ -73,7 +74,7 @@ class Application:
|
|||
|
||||
# Generate a random frame number or use provided one
|
||||
if self.fn is None:
|
||||
fn = random.randint(0, DATAInterface.GSM_HYPERFRAME)
|
||||
fn = random.randint(0, GSM_HYPERFRAME)
|
||||
else:
|
||||
fn = self.fn
|
||||
|
||||
|
@ -106,7 +107,7 @@ class Application:
|
|||
self.tn, fn, self.pwr)
|
||||
|
||||
# Increase frame number (for count > 1)
|
||||
fn = (fn + 1) % DATAInterface.GSM_HYPERFRAME
|
||||
fn = (fn + 1) % GSM_HYPERFRAME
|
||||
|
||||
self.shutdown()
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ import getopt
|
|||
import sys
|
||||
|
||||
from data_if import DATAInterface
|
||||
from gsm_shared import *
|
||||
|
||||
COPYRIGHT = \
|
||||
"Copyright (C) 2017 by Vadim Yanitskiy <axilirator@gmail.com>\n" \
|
||||
|
@ -75,7 +76,7 @@ class Application:
|
|||
|
||||
# Generate a random frame number or use provided one
|
||||
if self.fn is None:
|
||||
fn = random.randint(0, DATAInterface.GSM_HYPERFRAME)
|
||||
fn = random.randint(0, GSM_HYPERFRAME)
|
||||
else:
|
||||
fn = self.fn
|
||||
|
||||
|
@ -109,7 +110,7 @@ class Application:
|
|||
self.tn, fn, self.pwr)
|
||||
|
||||
# Increase frame number (for count > 1)
|
||||
fn = (fn + 1) % DATAInterface.GSM_HYPERFRAME
|
||||
fn = (fn + 1) % GSM_HYPERFRAME
|
||||
|
||||
# Finish
|
||||
self.shutdown()
|
||||
|
|
|
@ -28,6 +28,7 @@ import sys
|
|||
|
||||
from threading import Timer
|
||||
from udp_link import UDPLink
|
||||
from gsm_shared import *
|
||||
|
||||
COPYRIGHT = \
|
||||
"Copyright (C) 2017 by Vadim Yanitskiy <axilirator@gmail.com>\n" \
|
||||
|
@ -39,7 +40,6 @@ COPYRIGHT = \
|
|||
class CLCKGen:
|
||||
# GSM TDMA definitions
|
||||
SEC_DELAY_US = 1000 * 1000
|
||||
GSM_SUPERFRAME = 2715648
|
||||
GSM_FRAME_US = 4615.0
|
||||
|
||||
# Average loop back delay
|
||||
|
@ -74,8 +74,8 @@ class CLCKGen:
|
|||
|
||||
def send_clck_ind(self):
|
||||
# Keep clock cycle
|
||||
if self.clck_src % self.GSM_SUPERFRAME >= 0:
|
||||
self.clck_src %= self.GSM_SUPERFRAME
|
||||
if self.clck_src % GSM_HYPERFRAME >= 0:
|
||||
self.clck_src %= GSM_HYPERFRAME
|
||||
|
||||
# We don't need to send so often
|
||||
if self.clck_src % self.ind_period == 0:
|
||||
|
|
|
@ -25,10 +25,9 @@
|
|||
import random
|
||||
|
||||
from udp_link import UDPLink
|
||||
from gsm_shared import *
|
||||
|
||||
class DATAInterface(UDPLink):
|
||||
# GSM PHY definitions
|
||||
GSM_HYPERFRAME = 2048 * 26 * 51
|
||||
|
||||
def send_l1_msg(self, burst,
|
||||
tn = None, fn = None, rssi = None):
|
||||
|
@ -38,7 +37,7 @@ class DATAInterface(UDPLink):
|
|||
|
||||
# Generate random frame number if not preset
|
||||
if fn is None:
|
||||
fn = random.randint(0, self.GSM_HYPERFRAME)
|
||||
fn = random.randint(0, GSM_HYPERFRAME)
|
||||
|
||||
# Generate random RSSI if not preset
|
||||
if rssi is None:
|
||||
|
@ -79,7 +78,7 @@ class DATAInterface(UDPLink):
|
|||
|
||||
# Generate random frame number if not preset
|
||||
if fn is None:
|
||||
fn = random.randint(0, self.GSM_HYPERFRAME)
|
||||
fn = random.randint(0, GSM_HYPERFRAME)
|
||||
|
||||
# Generate random power level if not preset
|
||||
if pwr is None:
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
#!/usr/bin/env python2
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Virtual Um-interface (fake transceiver)
|
||||
# Common GSM constants
|
||||
#
|
||||
# (C) 2018 by Vadim Yanitskiy <axilirator@gmail.com>
|
||||
#
|
||||
# All Rights Reserved
|
||||
#
|
||||
# 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 program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along
|
||||
# with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
# TDMA definitions
|
||||
GSM_SUPERFRAME = 26 * 51
|
||||
GSM_HYPERFRAME = 2048 * GSM_SUPERFRAME
|
||||
|
||||
# Burst length
|
||||
GSM_BURST_LEN = 148
|
||||
EDGE_BURST_LEN = GSM_BURST_LEN * 3
|
|
@ -24,9 +24,9 @@
|
|||
|
||||
import random
|
||||
|
||||
from gsm_shared import *
|
||||
|
||||
class RandBurstGen:
|
||||
# GSM L1 definitions
|
||||
GSM_BURST_LEN = 148
|
||||
|
||||
# GSM 05.02 Chapter 5.2.3 Normal Burst
|
||||
nb_tsc_list = [
|
||||
|
@ -125,7 +125,7 @@ class RandBurstGen:
|
|||
|
||||
# Generate a frequency correction burst
|
||||
def gen_fb(self):
|
||||
return [0] * self.GSM_BURST_LEN
|
||||
return [0] * GSM_BURST_LEN
|
||||
|
||||
# Generate a synchronization burst
|
||||
def gen_sb(self):
|
||||
|
|
Loading…
Reference in New Issue