Removed high-level modules and scripts

This commit is contained in:
ismagom 2015-11-13 12:42:43 +01:00
parent 3f357ad6f2
commit 68c4f3a6e1
50 changed files with 2 additions and 7386 deletions

View File

@ -3,32 +3,6 @@ Paul Sutton <paul@softwareradiosystems.com>. All rights reserved.
The following copyright notices are for libraries used within srsLTE:
-----------------------------------------------------------
CLibrary.py
-----------------------------------------------------------
Copyright (c) 2003-2011 Paul T. McGuire
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-----------------------------------------------------------
FEC Library - Version 3.0.1 - August 7th, 2007
-----------------------------------------------------------

View File

@ -1,60 +0,0 @@
#
# Copyright 2012-2013 The libLTE Developers. See the
# COPYRIGHT file at the top-level directory of this distribution.
#
# This file is part of the libLTE library.
#
# libLTE is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
#
# libLTE 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 Lesser General Public License for more details.
#
# A copy of the GNU Lesser General Public License can be found in
# the LICENSE file in the top-level directory of this distribution
# and at http://www.gnu.org/licenses/.
#
#!/usr/bin/env python
from module import Module
from xml2aloe import MakeModule
import sys, os, getopt
argv = sys.argv
input_file = None
output_dir = None
try:
opts, args = getopt.getopt(argv,"hi:o:",["input_file=","output_dir="])
except getopt.GetoptError:
print argv[0] + ' -i <input_file> -o <output_dir>'
sys.exit(2)
for opt, arg in opts:
if opt == '-h':
print argv[0] + ' -i <input_file> -o <output_dir>'
sys.exit()
elif opt in ("-i", "--input_file"):
input_file = arg
elif opt in ("-o", "--output_dir"):
output_dir = arg
if input_file == None or output_dir == None:
print argv[0] + ' -i <input_file> -o <output_dir>'
sys.exit(2)
filename=os.path.basename(input_file).split('.')[0]
print filename + '\n'
print input_file + '\n'
print output_dir + '\n'
#m = Module("binsource")
#m.readHeader(input_file)
#MakeModule(m,output_dir)
#print m.toString()

View File

@ -1,31 +0,0 @@
#
# Copyright 2012-2013 The libLTE Developers. See the
# COPYRIGHT file at the top-level directory of this distribution.
#
# This file is part of the libLTE library.
#
# libLTE is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
#
# libLTE 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 Lesser General Public License for more details.
#
# A copy of the GNU Lesser General Public License can be found in
# the LICENSE file in the top-level directory of this distribution
# and at http://www.gnu.org/licenses/.
#
#!/usr/bin/env python
from module import Module
from xml2aloe import MakeModule
m = Module("binsource")
m.readHeader('/home/ismael/work/osld-lib/scripts/binsource.h')
MakeModule(m)
print m.toString()

View File

@ -1,311 +0,0 @@
#
# Copyright 2012-2013 The libLTE Developers. See the
# COPYRIGHT file at the top-level directory of this distribution.
#
# This file is part of the libLTE library.
#
# libLTE is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
#
# libLTE 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 Lesser General Public License for more details.
#
# A copy of the GNU Lesser General Public License can be found in
# the LICENSE file in the top-level directory of this distribution
# and at http://www.gnu.org/licenses/.
#
from xml.dom.minidom import Document,parseString
from pyclibrary import CParser
class Module:
# name
nof_inputs=0
nof_outputs=0
init_params = []
input_params = []
output_params = []
def __init__(self,name):
self.name=name
self.init_func=name+'_initialize'
self.work_func=name+'_work'
self.handler=name+'_hl'
self.handler_instance=name
self.init_pm_struct=name+'_init'
self.input_pm_struct=name+'_ctrl_in'
self.output_pm_struct=name+'_ctrl_out'
self.directory_name = 'lib_' + name
def set_input(self,nof_inputs, input_type, input_size):
self.nof_inputs = nof_inputs
self.input_type = input_type
self.input_size = input_size
def set_output(self,nof_outputs, output_type, output_size):
self.nof_outputs = nof_outputs
self.output_type = output_type
self.output_size = output_size
def add_init_param(self,name,type,default):
p={'name':name,'variable':self.name+'.init.'+name,'type':type,'default':default}
self.init_params.append(p)
def add_input_param(self,name,type,default):
p={'name':name,'variable':self.name+'.ctrl_in.'+name,'type':type,'default':default}
self.input_params.append(p)
def add_output_param(self,name,type,default):
p={'name':name,'variable':self.name+'.ctrl_in.'+name,'type':type,'default':default}
self.output_params.append(p)
def toString(self):
s = 'name: ' + self.name + '\n'
s = s + 'handler: ' + self.handler + '\n'
if self.nof_inputs > 0:
s = s + str(self.nof_inputs) + ' ' + self.input_type + ' inputs of size ' + str(self.output.size) + '\n'
else:
s = s + 'no inputs\n'
if self.nof_outputs > 0:
s = s + str(self.nof_outputs) + ' ' + self.output_type + ' outputs of size ' + str(self.output_size) + '\n'
else:
s = s + 'no outputs\n'
if self.init_params:
s = s + 'Initialization parameters:\n'
for p in self.init_params:
s = s + ' - ' + p['type'] + ' ' + p['name'] + ' = ' + p['default'] + '\n'
if self.input_params:
s = s + 'Input parameters:\n'
for p in self.input_params:
s = s + ' - ' + p['type'] + ' ' + p['name']
if p['default'] == None:
s = s + ' (Mandatory)\n'
else:
s = s + ' = ' + p['default'] + '\n'
if self.output_params:
s = s + 'Output parameters:\n'
for p in self.output_params:
s = s + ' - ' + p['type'] + ' ' + p['name'] + '\n'
return s
def toXML(self):
root = Document()
module = root.createElement('module')
root.appendChild(module)
module.setAttribute("name",self.name)
module.setAttribute("handler",self.handler)
module.setAttribute("handler_instance",self.handler_instance)
# Functions
functions = root.createElement("functions")
module.appendChild(functions)
functions.setAttribute("initialize",self.init_func)
functions.setAttribute("work",self.work_func)
# Interfaces
inputs = root.createElement("inputs")
module.appendChild(inputs)
inputs.setAttribute("num",str(self.nof_inputs))
inputs.setAttribute("type",self.input_type)
inputs.setAttribute("size",self.input_size)
outputs = root.createElement("outputs")
module.appendChild(outputs)
outputs.setAttribute("num",str(self.nof_outputs))
outputs.setAttribute("type",self.output_type)
outputs.setAttribute("size",self.output_size)
# Init Parameters
pinit = root.createElement("init_parameters")
module.appendChild(pinit)
for p in self.init_params:
pi = root.createElement("param")
pinit.appendChild(pi)
pi.setAttribute("name",p['name'])
pi.setAttribute("var",p['variable'])
pi.setAttribute("type",p['type'])
pi.setAttribute("default",p['default'])
pinput = root.createElement("input_parameters")
module.appendChild(pinput)
for p in self.input_params:
pi = root.createElement("param")
pinput.appendChild(pi)
pi.setAttribute("name",p['name'])
pi.setAttribute("var",p['variable'])
pi.setAttribute("type",p['type'])
pi.setAttribute("default",p['default'])
poutput = root.createElement("output_parameters")
module.appendChild(poutput)
for p in self.input_params:
pi = root.createElement("param")
pinput.appendChild(pi)
pi.setAttribute("name",p['name'])
pi.setAttribute("var",p['variable'])
pi.setAttribute("type",p['type'])
return root.toprettyxml()
def readXML(self, string):
root = parseString(string)
module = root.getElementsByTagName("module").item(0)
self.name = module.getAttribute("name")
self.handler = module.getAttribute("handler")
self.handler_instance = module.getAttribute("handler_instance")
functions = root.getElementsByTagName("functions").item(0)
self.init_func = functions.getAttribute("initialize")
self.work_func = functions.getAttribute("work")
# Interfaces
inputs = root.getElementsByTagName("inputs").item(0)
self.nof_inputs = int(inputs.getAttribute("num"))
self.input_type = inputs.getAttribute("type")
self.input_size = inputs.getAttribute("size")
outputs = root.getElementsByTagName("outputs").item(0)
self.nof_outputs = int(outputs.getAttribute("num"))
self.output_type = outputs.getAttribute("type")
self.output_size = outputs.getAttribute("size")
pinit = root.getElementsByTagName("init_parameters").item(0)
for p in pinit.getElementsByTagName("params"):
self.init_params.appendChild({'name':p.getAttribute("name"),\
'variable':p.getAttribute("variable"), \
'type':p.getAttribute("type"),\
'default':p.getAttribute("default")})
pinput = root.getElementsByTagName("input_parameters").item(0)
for p in pinput.getElementsByTagName("params"):
self.input_params.appendChild({'name':p.getAttribute("name"),\
'variable':p.getAttribute("variable"),\
'type':p.getAttribute("type"),\
'default':p.getAttribute("default")})
poutput = root.getElementsByTagName("output_parameters").item(0)
for p in poutput.getElementsByTagName("params"):
self.output_params.appendChild({'name':p.getAttribute("name"),\
'variable':p.getAttribute("variable"),\
'type':p.getAttribute("type")})
def findMember(self,members, name):
for m in members:
if m[0] == name:
return m
return None
def findDefault(self, lines, variable):
for line in lines:
if variable in line:
if 'default' in line.lower():
return str(int(line.split('=')[1].split('*/')[0]))
else:
return None
def findSize(self, lines, variable):
for line in lines:
if variable in line:
if 'size' in line.lower():
return line.split('=')[1].split('*/')[0]
else:
return None
def findLinesStruct(self, lines, struct_name):
slines = []
state = "nf"
for line in lines:
if state == 'nf':
if 'struct ' + struct_name in line:
state = "f1"
elif state == 'f1':
if '}' in line:
state = 'f2'
return slines
else:
slines.append(line)
def findLinesHandler(self,file_name):
with open(file_name,'r') as f:
slines = []
state = "nf"
for line in reversed(f.readlines()):
if state == 'nf':
if self.handler in line and '}' in line:
state = "f1"
elif state == 'f1':
if 'typedef' in line and 'struct' in line:
state = 'f2'
return reversed(slines)
else:
slines.append(line)
def readHeader(self, file_name):
p = CParser([file_name])
h = p.defs['structs'][p.defs['types'][p.defs['types'][self.handler][0]][1]]['members']
input = self.findMember(h,'input')
if input == None:
self.nof_inputs = 0
self.input_type = None
self.input_size = 0
else:
self.nof_inputs = input[1][2][0]
self.input_type = input[1][0]
size = self.findSize(self.findLinesHandler(file_name), 'input')
if size == None:
size = '2048*20'
self.input_size = size
output = self.findMember(h,'output')
if output == None:
self.nof_outputs = 0
self.output_type = None
self.output_size = 0
else:
self.nof_outputs = output[1][2][0]
self.output_type = output[1][0]
size = self.findSize(self.findLinesHandler(file_name), 'output')
if size == None:
size = '2048*20'
self.output_size = size
initpm = p.defs['structs'].get(self.init_pm_struct)
if (initpm != None):
for m in initpm['members']:
default = self.findDefault(self.findLinesStruct(\
self.findLinesHandler(file_name),\
self.init_pm_struct), m[0])
if default == None:
default = '0'
self.init_params.append({'name':m[0],'variable':self.name+'.init.'+m[0],\
'type':m[1][0],'default':default})
inputpm = p.defs['structs'].get(self.input_pm_struct)
if (inputpm != None):
for m in inputpm['members']:
default = self.findDefault(self.findLinesStruct(\
self.findLinesHandler(file_name),\
self.input_pm_struct), m[0])
self.input_params.append({'name':m[0],'variable':self.name+'.ctrl_in.'+m[0],\
'type':m[1][0],'default':default})
outputpm = p.defs['structs'].get(self.output_pm_struct)
if (outputpm != None):
for m in outputpm['members']:
self.output_params.append({'name':m[0],'variable':self.name+'.ctrl_out.'+m[0],\
'type':m[1][0]})

Binary file not shown.

View File

@ -1,319 +0,0 @@
#
# Copyright 2012-2013 The libLTE Developers. See the
# COPYRIGHT file at the top-level directory of this distribution.
#
# This file is part of the libLTE library.
#
# libLTE is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
#
# libLTE 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 Lesser General Public License for more details.
#
# A copy of the GNU Lesser General Public License can be found in
# the LICENSE file in the top-level directory of this distribution
# and at http://www.gnu.org/licenses/.
#
from xml.dom.minidom import Document,parseString
from pyclibrary import CParser
class Module:
# name
nof_inputs=0
nof_outputs=0
init_params = []
input_params = []
output_params = []
def __init__(self,name):
self.name=name
self.init_func=name+'_initialize'
self.work_func=name+'_work'
self.handler=name+'_hl'
self.handler_instance=name
self.init_pm_struct=name+'_init'
self.input_pm_struct=name+'_ctrl_in'
self.output_pm_struct=name+'_ctrl_out'
self.directory_name = 'lib_' + name
self.library_name = 'osld'
def set_input(self,nof_inputs, input_type, input_size):
self.nof_inputs = nof_inputs
self.input_type = input_type
self.input_size = input_size
def set_output(self,nof_outputs, output_type, output_size):
self.nof_outputs = nof_outputs
self.output_type = output_type
self.output_size = output_size
def add_init_param(self,name,type,default):
p={'name':name,'variable':self.name+'.init.'+name,'type':type,'default':default}
self.init_params.append(p)
def add_input_param(self,name,type,default):
p={'name':name,'variable':self.name+'.ctrl_in.'+name,'type':type,'default':default}
self.input_params.append(p)
def add_output_param(self,name,type,default):
p={'name':name,'variable':self.name+'.ctrl_in.'+name,'type':type,'default':default}
self.output_params.append(p)
def toString(self):
s = 'name: ' + self.name + '\n'
s = s + 'handler: ' + self.handler + '\n'
s = s + 'directory: ' + self.directory_name + '\n'
s = s + 'library name: ' + self.library_name + '\n'
if self.nof_inputs > 0:
s = s + str(self.nof_inputs) + ' ' + self.input_type + ' inputs of size ' + str(self.output.size) + '\n'
else:
s = s + 'no inputs\n'
if self.nof_outputs > 0:
s = s + str(self.nof_outputs) + ' ' + self.output_type + ' outputs of size ' + str(self.output_size) + '\n'
else:
s = s + 'no outputs\n'
if self.init_params:
s = s + 'Initialization parameters:\n'
for p in self.init_params:
s = s + ' - ' + p['type'] + ' ' + p['name'] + ' = ' + p['default'] + '\n'
if self.input_params:
s = s + 'Input parameters:\n'
for p in self.input_params:
s = s + ' - ' + p['type'] + ' ' + p['name']
if p['default'] == None:
s = s + ' (Mandatory)\n'
else:
s = s + ' = ' + p['default'] + '\n'
if self.output_params:
s = s + 'Output parameters:\n'
for p in self.output_params:
s = s + ' - ' + p['type'] + ' ' + p['name'] + '\n'
return s
def toXML(self):
root = Document()
module = root.createElement('module')
root.appendChild(module)
module.setAttribute("name",self.name)
module.setAttribute("handler",self.handler)
module.setAttribute("handler_instance",self.handler_instance)
module.setAttribute("library",self.library_name)
module.setAttribute("directory_name",self.directory_name)
# Functions
functions = root.createElement("functions")
module.appendChild(functions)
functions.setAttribute("initialize",self.init_func)
functions.setAttribute("work",self.work_func)
# Interfaces
inputs = root.createElement("inputs")
module.appendChild(inputs)
inputs.setAttribute("num",str(self.nof_inputs))
inputs.setAttribute("type",self.input_type)
inputs.setAttribute("size",self.input_size)
outputs = root.createElement("outputs")
module.appendChild(outputs)
outputs.setAttribute("num",str(self.nof_outputs))
outputs.setAttribute("type",self.output_type)
outputs.setAttribute("size",self.output_size)
# Init Parameters
pinit = root.createElement("init_parameters")
module.appendChild(pinit)
for p in self.init_params:
pi = root.createElement("param")
pinit.appendChild(pi)
pi.setAttribute("name",p['name'])
pi.setAttribute("var",p['variable'])
pi.setAttribute("type",p['type'])
pi.setAttribute("default",p['default'])
pinput = root.createElement("input_parameters")
module.appendChild(pinput)
for p in self.input_params:
pi = root.createElement("param")
pinput.appendChild(pi)
pi.setAttribute("name",p['name'])
pi.setAttribute("var",p['variable'])
pi.setAttribute("type",p['type'])
pi.setAttribute("default",p['default'])
poutput = root.createElement("output_parameters")
module.appendChild(poutput)
for p in self.input_params:
pi = root.createElement("param")
pinput.appendChild(pi)
pi.setAttribute("name",p['name'])
pi.setAttribute("var",p['variable'])
pi.setAttribute("type",p['type'])
return root.toprettyxml()
def readXML(self, string):
root = parseString(string)
module = root.getElementsByTagName("module").item(0)
self.name = module.getAttribute("name")
self.handler = module.getAttribute("handler")
self.handler_instance = module.getAttribute("handler_instance")
self.directory_name = module.getAttribute("directory_name")
self.library_name = module.getAttribute("library")
functions = root.getElementsByTagName("functions").item(0)
self.init_func = functions.getAttribute("initialize")
self.work_func = functions.getAttribute("work")
# Interfaces
inputs = root.getElementsByTagName("inputs").item(0)
self.nof_inputs = int(inputs.getAttribute("num"))
self.input_type = inputs.getAttribute("type")
self.input_size = inputs.getAttribute("size")
outputs = root.getElementsByTagName("outputs").item(0)
self.nof_outputs = int(outputs.getAttribute("num"))
self.output_type = outputs.getAttribute("type")
self.output_size = outputs.getAttribute("size")
pinit = root.getElementsByTagName("init_parameters").item(0)
for p in pinit.getElementsByTagName("params"):
self.init_params.appendChild({'name':p.getAttribute("name"),\
'variable':p.getAttribute("variable"), \
'type':p.getAttribute("type"),\
'default':p.getAttribute("default")})
pinput = root.getElementsByTagName("input_parameters").item(0)
for p in pinput.getElementsByTagName("params"):
self.input_params.appendChild({'name':p.getAttribute("name"),\
'variable':p.getAttribute("variable"),\
'type':p.getAttribute("type"),\
'default':p.getAttribute("default")})
poutput = root.getElementsByTagName("output_parameters").item(0)
for p in poutput.getElementsByTagName("params"):
self.output_params.appendChild({'name':p.getAttribute("name"),\
'variable':p.getAttribute("variable"),\
'type':p.getAttribute("type")})
def findMember(self,members, name):
for m in members:
if m[0] == name:
return m
return None
def findDefault(self, lines, variable):
for line in lines:
if variable in line:
if 'default' in line.lower():
return str(int(line.split('=')[1].split('*/')[0]))
else:
return None
def findSize(self, lines, variable):
for line in lines:
if variable in line:
if 'size' in line.lower():
return line.split('=')[1].split('*/')[0]
else:
return None
def findLinesStruct(self, lines, struct_name):
slines = []
state = "nf"
for line in lines:
if state == 'nf':
if 'struct ' + struct_name in line:
state = "f1"
elif state == 'f1':
if '}' in line:
state = 'f2'
return slines
else:
slines.append(line)
def findLinesHandler(self,file_name):
with open(file_name,'r') as f:
slines = []
state = "nf"
for line in reversed(f.readlines()):
if state == 'nf':
if self.handler in line and '}' in line:
state = "f1"
elif state == 'f1':
if 'typedef' in line and 'struct' in line:
state = 'f2'
return reversed(slines)
else:
slines.append(line)
def readHeader(self, file_name):
p = CParser([file_name])
h = p.defs['structs'][p.defs['types'][p.defs['types'][self.handler][0]][1]]['members']
input = self.findMember(h,'input')
if input == None:
self.nof_inputs = 0
self.input_type = None
self.input_size = 0
else:
self.nof_inputs = input[1][2][0]
self.input_type = input[1][0]
size = self.findSize(self.findLinesHandler(file_name), 'input')
if size == None:
size = '2048*20'
self.input_size = size
output = self.findMember(h,'output')
if output == None:
self.nof_outputs = 0
self.output_type = None
self.output_size = 0
else:
self.nof_outputs = output[1][2][0]
self.output_type = output[1][0]
size = self.findSize(self.findLinesHandler(file_name), 'output')
if size == None:
size = '2048*20'
self.output_size = size
initpm = p.defs['structs'].get(self.init_pm_struct)
if (initpm != None):
for m in initpm['members']:
default = self.findDefault(self.findLinesStruct(\
self.findLinesHandler(file_name),\
self.init_pm_struct), m[0])
if default == None:
default = '0'
self.init_params.append({'name':m[0],'variable':self.name+'.init.'+m[0],\
'type':m[1][0],'default':default})
inputpm = p.defs['structs'].get(self.input_pm_struct)
if (inputpm != None):
for m in inputpm['members']:
default = self.findDefault(self.findLinesStruct(\
self.findLinesHandler(file_name),\
self.input_pm_struct), m[0])
self.input_params.append({'name':m[0],'variable':self.name+'.ctrl_in.'+m[0],\
'type':m[1][0],'default':default})
outputpm = p.defs['structs'].get(self.output_pm_struct)
if (outputpm != None):
for m in outputpm['members']:
self.output_params.append({'name':m[0],'variable':self.name+'.ctrl_out.'+m[0],\
'type':m[1][0]})

Binary file not shown.

View File

@ -1,501 +0,0 @@
# -*- coding: utf-8 -*-
"""
CLibrary.py - Provides CLibrary class
Copyright 2010 Luke Campagnola
Distributed under MIT/X11 license. See license.txt for more infomation.
Proxy to both CHeader and ctypes, allowing automatic type conversion and
function calling based on C header definitions.
"""
from ctypes import *
import sys
class CLibrary:
"""The CLibrary class is intended to automate much of the work in using ctypes by integrating
header file definitions from CParser. Ths class serves as a proxy to a ctypes, adding
a few features:
- allows easy access to values defined via CParser
- automatic type conversions for function calls using CParser function signatures
- creates ctype classes based on type definitions from CParser
Initialize using a ctypes shared object and a CParser:
headers = CParser.winDefs()
lib = CLibrary(windll.User32, headers)
There are 3 ways to access library elements:
lib(type, name) - type can be one of 'values', 'functions', 'types', 'structs', 'unions', or 'enums'.
Returns an object matching name. For values, the value from the headers is
returned. For functions, a callable object is returned that handles automatic
type conversion for arguments and return values. for structs, types, and enums,
a ctypes class is returned matching the type specified.
lib.name - searches in order through values, functions, types, structs, unions, and enums from
header definitions and returns an object for the first match found. The object
returned is the same as returned by lib(type, name). This is the preferred way to access
elements from CLibrary, but may not work in some situations (for example, if
a struct and variable share the same name).
lib[type] - Accesses the header definitions directly, returns definition dictionaries
based on the type requested. This is equivalent to headers.defs[type].
"""
Null = object()
cTypes = {
'char': c_char,
'wchar': c_wchar,
'unsigned char': c_ubyte,
'short': c_short,
'short int': c_short,
'unsigned short': c_ushort,
'unsigned short int': c_ushort,
'int': c_int,
'unsigned': c_uint,
'unsigned int': c_uint,
'long': c_long,
'long int': c_long,
'unsigned long': c_ulong,
'unsigned long int': c_ulong,
'__int64': c_longlong,
'long long': c_longlong,
'long long int': c_longlong,
'unsigned __int64': c_ulonglong,
'unsigned long long': c_ulonglong,
'unsigned long long int': c_ulonglong,
'float': c_float,
'double': c_double,
'long double': c_longdouble
}
cPtrTypes = {
'char': c_char_p,
'wchar': c_wchar_p,
'void': c_void_p
}
def __init__(self, lib, headers, prefix=None):
## name everything using underscores to avoid name collisions with library
self._lib_ = lib
self._headers_ = headers
self._defs_ = headers.defs
if prefix is None:
self._prefix_ = []
elif type(prefix) is list:
self._prefix_ = prefix
else:
self._prefix_ = [prefix]
self._objs_ = {}
for k in ['values', 'functions', 'types', 'structs', 'unions', 'enums']:
self._objs_[k] = {}
self._allObjs_ = {}
self._structs_ = {}
self._unions_ = {}
def __call__(self, typ, name):
if typ not in self._objs_:
typs = self._objs_.keys()
raise Exception("Type must be one of %s" % str(typs))
if name not in self._objs_[typ]:
self._objs_[typ][name] = self._mkObj_(typ, name)
return self._objs_[typ][name]
def _allNames_(self, name):
return [name] + [p + name for p in self._prefix_]
def _mkObj_(self, typ, name):
names = self._allNames_(name)
for n in names:
if n in self._objs_:
return self._objs_[n]
for n in names: ## try with and without prefix
if n not in self._defs_[typ] and not (typ in ['structs', 'unions', 'enums'] and n in self._defs_['types']):
continue
if typ == 'values':
return self._defs_[typ][n]
elif typ == 'functions':
return self._getFunction(n)
elif typ == 'types':
obj = self._defs_[typ][n]
return self._ctype(obj)
elif typ == 'structs':
return self._cstruct('structs', n)
elif typ == 'unions':
return self._cstruct('unions', n)
elif typ == 'enums':
## Allow automatic resolving of typedefs that alias enums
if n not in self._defs_['enums']:
if n not in self._defs_['types']:
raise Exception('No enums named "%s"' % n)
typ = self._headers_.evalType([n])[0]
if typ[:5] != 'enum ':
raise Exception('No enums named "%s"' % n)
n = self._defs_['types'][typ][1] ## look up internal name of enum
obj = self._defs_['enums'][n]
return obj
else:
raise Exception("Unknown type %s" % typ)
raise NameError(name)
def __getattr__(self, name):
"""Used to retrieve any type of definition from the headers. Searches for the name in this order:
values, functions, types, structs, unions, enums."""
if name not in self._allObjs_:
names = self._allNames_(name)
for k in ['values', 'functions', 'types', 'structs', 'unions', 'enums', None]:
if k is None:
raise NameError(name)
obj = None
for n in names:
if n in self._defs_[k]:
obj = self(k, n)
break
if obj is not None:
break
self._allObjs_[name] = obj
return self._allObjs_[name]
def __getitem__(self, name):
"""Used to retrieve a specific dictionary from the headers."""
return self._defs_[name]
def __repr__(self):
return "<CLibrary instance: %s>" % str(self._lib_)
def _getFunction(self, funcName):
try:
func = getattr(self._lib_, funcName)
except:
raise Exception("Function name '%s' appears in headers but not in library!" % func)
#print "create function %s," % (funcName), self._defs_['functions'][funcName]
return CFunction(self, func, self._defs_['functions'][funcName], funcName)
def _ctype(self, typ, pointers=True):
"""return a ctype object representing the named type.
If pointers is True, the class returned includes all pointer/array specs provided.
Otherwise, the class returned is just the base type with no pointers."""
try:
typ = self._headers_.evalType(typ)
mods = typ[1:][:]
## Create the initial type
## Some types like ['char', '*'] have a specific ctype (c_char_p)
## (but only do this if pointers == True)
if pointers and len(typ) > 1 and typ[1] == '*' and typ[0] in CLibrary.cPtrTypes:
cls = CLibrary.cPtrTypes[typ[0]]
mods = typ[2:]
## If the base type is in the list of existing ctypes:
elif typ[0] in CLibrary.cTypes:
cls = CLibrary.cTypes[typ[0]]
## structs, unions, enums:
elif typ[0][:7] == 'struct ':
cls = self._cstruct('structs', self._defs_['types'][typ[0]][1])
elif typ[0][:6] == 'union ':
cls = self._cstruct('unions', self._defs_['types'][typ[0]][1])
elif typ[0][:5] == 'enum ':
cls = c_int
## void
elif typ[0] == 'void':
cls = None
else:
#print typ
raise Exception("Can't find base type for %s" % str(typ))
if not pointers:
return cls
## apply pointers and arrays
while len(mods) > 0:
m = mods.pop(0)
if isinstance(m, basestring): ## pointer or reference
if m[0] == '*' or m[0] == '&':
for i in m:
cls = POINTER(cls)
elif type(m) is list: ## array
for i in m:
if i == -1: ## -1 indicates an 'incomplete type' like "int variable[]"
cls = POINTER(cls) ## which we should interpret like "int *variable"
else:
cls = cls * i
elif type(m) is tuple: ## Probably a function pointer
## Find pointer and calling convention
isPtr = False
conv = '__cdecl'
if len(mods) == 0:
raise Exception("Function signature with no pointer:", m, mods)
for i in [0,1]:
if len(mods) < 1:
break
if mods[0] == '*':
mods.pop(0)
isPtr = True
elif mods[0] in ['__stdcall', '__cdecl']:
conv = mods.pop(0)
else:
break
if not isPtr:
raise Exception("Not sure how to handle type (function without single pointer): %s" % str(typ))
if conv == '__stdcall':
mkfn = WINFUNCTYPE
else:
mkfn = CFUNCTYPE
#print "Create function pointer (%s)" % conv
args = [self._ctype(arg[1]) for arg in m]
cls = mkfn(cls, *args)
else:
raise Exception("Not sure what to do with this type modifier: '%s'" % str(p))
return cls
except:
print "Error while processing type", typ
raise
def _cstruct(self, strType, strName):
if strName not in self._structs_:
## Resolve struct name--typedef aliases allowed.
if strName not in self._defs_[strType]:
if strName not in self._defs_['types']:
raise Exception('No struct/union named "%s"' % strName)
typ = self._headers_.evalType([strName])[0]
if typ[:7] != 'struct ' and typ[:6] != 'union ':
raise Exception('No struct/union named "%s"' % strName)
strName = self._defs_['types'][typ][1]
## Pull struct definition
defn = self._defs_[strType][strName]
## create ctypes class
defs = defn['members'][:]
if strType == 'structs':
class s(Structure):
def __repr__(self):
return "<ctypes struct '%s'>" % strName
elif strType == 'unions':
class s(Union):
def __repr__(self):
return "<ctypes union '%s'>" % strName
## must register struct here to allow recursive definitions.
self._structs_[strName] = s
if defn['pack'] is not None:
s._pack_ = defn['pack']
## assign names to anonymous members
members = []
anon = []
for i in range(len(defs)):
if defs[i][0] is None:
c = 0
while True:
name = 'anon_member%d' % c
if name not in members:
defs[i][0] = name
anon.append(name)
break
members.append(defs[i][0])
s._anonymous_ = anon
s._fields_ = [(m[0], self._ctype(m[1])) for m in defs]
s._defaults_ = [m[2] for m in defs]
return self._structs_[strName]
class CFunction:
def __init__(self, lib, func, sig, name):
self.lib = lib
self.func = func
#print sig
self.sig = list(sig) # looks like [return_type, [(argName, type, default), (argName, type, default), ...]]
self.sig[1] = [s for s in sig[1] if s[1] != ['void']] ## remove void args from list
for conv in ['__stdcall', '__cdecl']:
if conv in self.sig[0]:
self.sig[0].remove(conv)
self.name = name
self.restype = lib._ctype(self.sig[0])
#func.restype = self.restype
self.argTypes = [lib._ctype(s[1]) for s in self.sig[1]]
func.argtypes = self.argTypes
self.reqArgs = [x[0] for x in self.sig[1] if x[2] is None]
self.argInds = dict([(self.sig[1][i][0], i) for i in range(len(self.sig[1]))]) ## mapping from argument names to indices
#print "created func", self, sig, self.argTypes
def argCType(self, arg):
"""Return the ctype required for the specified argument.
arg can be either an integer or the name of the argument.
"""
if isinstance(arg, basestring):
arg = self.argInds[arg]
return self.lib._ctype(self.sig[1][arg][1])
def __call__(self, *args, **kwargs):
"""Invoke the SO or dll function referenced, converting all arguments to the correct type.
Keyword arguments are allowed as long as the header specifies the argument names.
Arguments which are passed byref may be omitted entirely, and will be automaticaly generated.
To pass a NULL pointer, give None as the argument.
Returns the return value of the function call as well as all of the arguments (so that objects passed by reference can be retrieved)"""
#print "CALL: %s(%s)" % (self.name, ", ".join(map(str, args) + ["%s=%s" % (k, str(kwargs[k])) for k in kwargs]))
#print " sig:", self.sig
argList = [None] * max(len(self.reqArgs), len(args)) ## We'll need at least this many arguments.
## First fill in args
for i in range(len(args)):
#argList[i] = self.argTypes[i](args[i])
if args[i] is None:
argList[i] = self.lib.Null
else:
argList[i] = args[i]
## Next fill in kwargs
for k in kwargs:
#print " kw:", k
if k not in self.argInds:
print "Function signature:", self.prettySignature()
raise Exception("Function signature has no argument named '%s'" % k)
ind = self.argInds[k]
if ind >= len(argList): ## stretch argument list if needed
argList += [None] * (ind - len(argList) + 1)
#argList[ind] = self.coerce(kwargs[k], self.argTypes[ind])
if kwargs[k] is None:
argList[ind] = self.lib.Null
else:
argList[ind] = kwargs[k]
guessedArgs = []
## Finally, fill in remaining arguments if they are pointers to int/float/void*/struct values
## (we assume these are to be modified by the function and their initial value is not important)
for i in range(len(argList)):
if argList[i] is None or argList[i] is self.lib.Null:
try:
sig = self.sig[1][i][1]
argType = self.lib._headers_.evalType(sig)
if argList[i] is self.lib.Null: ## request to build a null pointer
if len(argType) < 2:
raise Exception("Can not create NULL for non-pointer argument type: %s" % str(argType))
argList[i] = self.lib._ctype(sig)()
#elif argType == ['char', '*']: ## pass null pointer if none was specified. This is a little dangerous, but some functions will expect it.
#argList[i] = c_char_p() ## On second thought: let's just require the user to explicitly ask for a NULL pointer.
else:
if argType == ['void', '**'] or argType == ['void', '*', '*']:
cls = c_void_p
else:
assert len(argType) == 2 and argType[1] == '*' ## Must be 2-part type, second part must be '*'
cls = self.lib._ctype(sig, pointers=False)
argList[i] = pointer(cls(0))
guessedArgs.append(i)
except:
if sys.exc_info()[0] is not AssertionError:
raise
#sys.excepthook(*sys.exc_info())
print "Function signature:", self.prettySignature()
raise Exception("Function call '%s' missing required argument %d '%s'. (See above for signature)" % (self.name, i, self.sig[1][i][0]))
#print " args:", argList
try:
res = self.func(*argList)
except:
print "Function call failed. Signature is:", self.prettySignature()
print "Arguments:", argList
print "Argtypes:", self.func.argtypes
raise
#print " result:", res
cr = CallResult(res, argList, self.sig, guessed=guessedArgs)
return cr
def prettySignature(self):
return "%s %s(%s)" % (''.join(self.sig[0]), self.name, ', '.join(["%s %s" % ("".join(map(str, s[1])), s[0]) for s in self.sig[1]]))
class CallResult:
"""Class for bundling results from C function calls. Allows access to the function
return value as well as all of the arguments, since the function call will often return
extra values via these arguments.
- Original ctype objects can be accessed via result.rval or result.args
- Python values carried by these objects can be accessed using ()
To access values:
- The return value: ()
- The nth argument passed: [n]
- The argument by name: ['name']
- All values that were auto-generated: .auto()
The class can also be used as an iterator, so that tuple unpacking is possible:
ret, arg1, arg2 = lib.runSomeFunction(...)
"""
def __init__(self, rval, args, sig, guessed):
self.rval = rval ## return value of function call
self.args = args ## list of arguments to function call
self.sig = sig ## function signature
self.guessed = guessed ## list of arguments that were generated automatically (usually byrefs)
def __call__(self):
#print "Clibrary:", type(self.rval), self.mkVal(self.rval)
if self.sig[0] == ['void']:
return None
return self.mkVal(self.rval)
def __getitem__(self, n):
if type(n) is int:
return self.mkVal(self.args[n])
elif type(n) is str:
ind = self.findArg(n)
return self.mkVal(self.args[ind])
else:
raise Exception("Index must be int or str.")
def __setitem__(self, n, val):
if type(n) is int:
self.args[n] = val
elif type(n) is str:
ind = self.findArg(n)
self.args[ind] = val
else:
raise Exception("Index must be int or str.")
def mkVal(self, obj):
while not hasattr(obj, 'value'):
if not hasattr(obj, 'contents'):
return obj
try:
obj = obj.contents
except ValueError:
return None
return obj.value
def findArg(self, arg):
for i in range(len(self.sig[1])):
if self.sig[1][i][0] == arg:
return i
raise Exception("Can't find argument '%s' in function signature. Arguments are: %s" % (arg, str([a[0] for a in self.sig[1]])))
def __iter__(self):
yield self()
for i in range(len(self.args)):
yield(self[i])
def auto(self):
return [self[n] for n in self.guessed]

File diff suppressed because it is too large Load Diff

View File

@ -1,8 +0,0 @@
pyclibrary
==========
C parser and ctypes automation for Python.
Fork of <https://launchpad.net/pyclibrary>. (`bzr branch lp:pyclibrary pyclibrary-bzr && mkdir pyclibrary && cd pyclibrary && bar fast-export --plain ../pyclibrary-bzr | git fast-import`)
Pyclibrary includes 1) a pure-python C parser and 2) a ctypes automation library that uses C header file definitions to simplify the use of ctypes. The C parser currently processes all macros, typedefs, structs, unions, enums, function prototypes, and global variable declarations, and can evaluate typedefs down to their fundamental C types + pointers/arrays/function signatures. Pyclibrary can automatically build ctypes structs/unions and perform type conversions when calling functions via cdll/windll.

View File

@ -1,3 +0,0 @@
# -*- coding: utf-8 -*-
from CParser import *
from CLibrary import *

View File

@ -1,7 +0,0 @@
Copyright (c) 2010 Luke Campagnola ('luke.campagnola@%s.com' % 'gmail')
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

File diff suppressed because it is too large Load Diff

View File

@ -1,117 +0,0 @@
#
# Copyright 2012-2013 The libLTE Developers. See the
# COPYRIGHT file at the top-level directory of this distribution.
#
# This file is part of the libLTE library.
#
# libLTE is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
#
# libLTE 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 Lesser General Public License for more details.
#
# A copy of the GNU Lesser General Public License can be found in
# the LICENSE file in the top-level directory of this distribution
# and at http://www.gnu.org/licenses/.
#
import shutil
import os
def MakeModule(m):
dir = os.path.dirname(__file__)
tdir = os.path.join(dir, 'template')
ddir = tdir + m.directory_name
print 'Creating new directory ' + ddir
shutil.copytree(tdir,ddir)
WriteAloeC(m,tdir + '/src/template.c',\
ddir + '/src/' + m.name + '.c')
WriteAloeH(m,tdir + '/src/template.h',\
ddir + '/src/' + m.name + '.h')
def WriteInitParamsGet(m, f):
for p in m.init_params:
f.write('\tif (param_get_' + p['type'] + '_name("' + p['name'] + '", &' + p['variable']+ ')) {\n'
'\t\t' + p['variable'] + ' = ' + str(p['default']) + ';\n'\
'\t}\n')
def WriteInputParamsHandlers(m, f):
for p in m.input_params:
f.write('pmid_t ' + p['name'] + '_id;\n')
def WriteInputParamsId(m, f):
for p in m.input_params:
f.write('\t' + p['name'] + '_id = param_id("' + p['name'] + '");\n')
def WriteInputParamsGet(m, f):
for p in m.input_params:
f.write('\tif (param_get_' + p['type'] + '(' + p['name'] + '_id, &' + p['variable'] + ') != 1) {\n')
if p['default'] == None:
f.write('\t\t' + r'moderror("Error getting parameter ' + p['name'] + '\\n");' + '\n')
f.write('\t\treturn -1;\n\t}\n')
else:
f.write('\t\t' + r'modinfo("Parameter ' + p['name'] + ' not found. Setting to default (' + p['default'] + ')\\n");' + '\n')
f.write('\t\t' + p['variable'] + ' = ' + p['default'] + ';\n\t}\n')
def WriteAloeC(m, input, output):
with open(input,'r') as f:
newlines = []
for line in f.readlines():
newlines.append(line.replace('-name-', m.name))
with open(output, 'w') as f:
for line in newlines:
if '--input_parameters_handlers--' in line:
WriteInputParamsHandlers(m, f)
elif '--input_parameters_getid--' in line:
WriteInputParamsId(m, f)
elif '--init_parameters--' in line:
WriteInitParamsGet(m, f)
elif '--input_parameters--' in line:
WriteInputParamsGet(m, f)
else:
f.write(line)
def WriteAloeH(m, input, output):
with open(input,'r') as f:
newlines = []
for line in f.readlines():
if '-typeinput-' in line:
if m.nof_inputs > 0:
newlines.append(line.replace('-typeinput-', m.input_type))
elif '-numinputs-' in line:
newlines.append(line.replace('-numinputs-', str(m.nof_inputs)))
elif '-sizeinput-' in line:
if m.nof_inputs > 0:
newlines.append(line.replace('-sizeinput-', m.input_size))
else:
newlines.append(line.replace('-sizeinput-', '0'))
elif '-typeoutput-' in line:
if m.nof_outputs > 0:
newlines.append(line.replace('-typeoutput-', m.output_type))
elif '-numoutputs-' in line:
newlines.append(line.replace('-numoutputs-', str(m.nof_outputs)))
elif '-sizeoutput-' in line:
if m.nof_outputs > 0:
newlines.append(line.replace('-sizeoutput-', m.output_size))
else:
newlines.append(line.replace('-sizeoutput-', '0'))
else:
newlines.append(line)
with open(output, 'w') as f:
for line in newlines:
f.write(line)

Binary file not shown.

View File

@ -1,94 +0,0 @@
# This configuration is for the aloe++ skeleton
# set-up the program libraries here
set(LIBRARIES m rt)
# set-up program includes here
include_directories(/usr/local/include/)
############## DO NOT NEED TO MODIFY BEYOND HERE
get_filename_component(module ${CMAKE_CURRENT_SOURCE_DIR} NAME)
if( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR )
cmake_minimum_required (VERSION 2.6)
project (${module})
# The version number.
set (OECORE_VERSION_MAJOR 1)
set (OECORE_VERSION_MINOR 0)
set(MODULE_REPOS_NAME "default")
else()
include_directories(${OESR_INCLUDE})
endif()
file(GLOB_RECURSE SOURCES "src/*.c")
file(GLOB_RECURSE TEST_SOURCES "test/*.c")
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src)
# aloe module
add_library(${module}-aloe SHARED ${SOURCES})
set_target_properties(${module}-aloe PROPERTIES OUTPUT_NAME ${module})
set_target_properties(${module}-aloe PROPERTIES COMPILE_FLAGS "-D_COMPILE_ALOE")
target_link_libraries(${module}-aloe oesrapi skeleton ${LIBRARIES})
install(TARGETS ${module}-aloe DESTINATION lib/${MODULE_REPOS_NAME}/)
if (NOT ${TEST_SOURCES} STREQUAL "")
# standalone program for testing
add_executable(${module}-bin ${SOURCES} ${TEST_SOURCES})
set_target_properties(${module}-bin PROPERTIES OUTPUT_NAME ${module})
set_target_properties(${module}-bin PROPERTIES COMPILE_FLAGS "-D_COMPILE_STANDALONE")
target_link_libraries(${module}-bin standalone ${LIBRARIES})
install(TARGETS ${module}-bin DESTINATION bin)
endif()
# octave mex file
set(install_mex "")
if(NOT $ENV{OCTAVE_INCLUDE} STREQUAL "")
if(NOT $ENV{OCTAVE_LIBS} STREQUAL "")
add_library(${module}-oct SHARED ${SOURCES})
set_target_properties(${module}-oct PROPERTIES OUTPUT_NAME ${module})
set_target_properties(${module}-oct PROPERTIES PREFIX "am_")
set_target_properties(${module}-oct PROPERTIES SUFFIX .mex)
set_target_properties(${module}-oct PROPERTIES COMPILE_FLAGS "-I$ENV{OCTAVE_INCLUDE} -D_COMPILE_MEX -Wl,-Bsymbolic -L$ENV{OCTAVE_LIBS} -loctinterp -loctave -lcruft -Wl,-Bsymbolic-functions -Wl,-z,relro")
target_link_libraries(${module}-oct aloe_octave ${LIBRARIES})
install(TARGETS ${module}-oct DESTINATION mex)
endif()
endif()
#matlab mex
if(NOT $ENV{MATLAB_ROOT} STREQUAL "")
add_library(${module}-mat SHARED ${SOURCES})
set_target_properties(${module}-mat PROPERTIES OUTPUT_NAME ${module})
set_target_properties(${module}-mat PROPERTIES PREFIX "am_")
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set_target_properties(${module}-mat PROPERTIES SUFFIX .mexa64)
set_target_properties(${module}-mat PROPERTIES COMPILE_FLAGS "-I$ENV{MATLAB_ROOT} -O -pthread -shared -Wl,--version-script,$ENV{MATLAB_ROOT}/extern/lib/glnxa64/mexFunction.map -Wl,--no-undefined -Wl,-rpath-link,$ENV{MATLAB_ROOT}/bin/glnxa64 -L$ENV{MATLAB_ROOT}/bin/glnxa64 -lmx -lmex -lmat -lm -lstdc++")
else()
set_target_properties(${module}-mat PROPERTIES SUFFIX .mexglx)
set_target_properties(${module}-mat PROPERTIES COMPILE_FLAGS "-I$ENV{MATLAB_ROOT} -O -pthread -shared -m32 -Wl,--version-script,$ENV{MATLAB_ROOT}/extern/lib/glnx86/mexFunction.map -Wl,--no-undefined -Wl,-rpath-link,$ENV{MATLAB_ROOT}/bin/glnx86 -L$ENV{MATLAB_ROOT}/bin/glnx86 -lmx -lmex -lmat -lm -lstdc++")
endif()
target_link_libraries(${module}-mat aloe_matlab ${LIBRARIES})
install(TARGETS ${module}-mat DESTINATION mex)
endif()

View File

@ -1,100 +0,0 @@
/**
*
* \section COPYRIGHT
*
* Copyright 2013-2015 The srsLTE Developers. See the
* COPYRIGHT file at the top-level directory of this distribution.
*
* \section LICENSE
*
* This file is part of the srsLTE library.
*
* srsLTE is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* srsLTE 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 Affero General Public License for more details.
*
* A copy of the GNU Affero General Public License can be found in
* the LICENSE file in the top-level directory of this distribution
* and at http://www.gnu.org/licenses/.
*
*/
/*
* This file has been automatically generated from -name-
*/
#include <stdio.h>
#include <oesr.h>
#include <params.h>
#include <skeleton.h>
#include "-name-.h"
-name-_hl -name-;
--input_parameters_handlers--
int out_len[NOF_OUTPUT_ITF];
int initialize() {
/* Initialization Parameters */
--init_parameters--
/* Input Control Parameters */
--input_parameters_getid--
/* Initialization function */
return -name-_initialize(&-name-);
}
int work(void **inp, void **out) {
int i,n;
#if NOF_INPUTS>1
for (i=0;i<NOF_INPUT_ITF;i++) {
-name-.input[i] = inp[i];
-name-.in_len[i] = get_input_samples(i)
}
#elif NOF_INPUTS == 1
-name-.input = inp[0];
-name-.in_len = get_input_samples(0);
#endif
#if NOF_OUTPUTS>1
for (i=0;i<NOF_OUTPUT_ITF;i++) {
-name-.output[i] = out[i];
-name-.out_len = &out_len[i];
}
#elif NOF_OUTPUTS == 1
-name-output = out[0];
-name-.out_len = &out_len[0];
#endif
/* Get input parameters */
--input_parameters--
/* call work */
n = -name-_work(&-name-);
/* Set output nof_samples */
for (i=0;i<NOF_OUTPUT_ITF;i++) {
set_output_samples(i,out_len[i]);
-name-.out_len = &out_len[i];
}
/* Set output parameters */
return n;
}
int stop() {
-name-_destroy(&-name-);
return 0;
}

View File

@ -1,59 +0,0 @@
/**
*
* \section COPYRIGHT
*
* Copyright 2013-2015 The srsLTE Developers. See the
* COPYRIGHT file at the top-level directory of this distribution.
*
* \section LICENSE
*
* This file is part of the srsLTE library.
*
* srsLTE is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* srsLTE 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 Affero General Public License for more details.
*
* A copy of the GNU Affero General Public License can be found in
* the LICENSE file in the top-level directory of this distribution
* and at http://www.gnu.org/licenses/.
*
*/
#ifndef DEFINE_H
#define DEFINE_H
#include <stdint.h>
typedef -typeinput- input_t;
typedef -typeoutput- output_t;
#define INPUT_MAX_SAMPLES -sizeinput-
#define OUTPUT_MAX_SAMPLES -sizeoutput-
#define NOF_INPUT_ITF -numinputs-
#define NOF_OUTPUT_ITF -numoutputs-
#endif
/**@} */
#ifndef INCLUDE_DEFS_ONLY
/* Input and output buffer sizes (in number of samples) */
const int input_max_samples = INPUT_MAX_SAMPLES;
const int output_max_samples = OUTPUT_MAX_SAMPLES;
/* leave these two lines unmodified */
const int input_sample_sz = sizeof(input_t);
int output_sample_sz = sizeof(output_t);
/* Number of I/O interfaces. All have the same maximum size */
const int nof_input_itf = NOF_INPUT_ITF;
const int nof_output_itf = NOF_OUTPUT_ITF;
#endif

View File

@ -1,83 +0,0 @@
/**
*
* \section COPYRIGHT
*
* Copyright 2013-2015 The srsLTE Developers. See the
* COPYRIGHT file at the top-level directory of this distribution.
*
* \section LICENSE
*
* This file is part of the srsLTE library.
*
* srsLTE is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* srsLTE 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 Affero General Public License for more details.
*
* A copy of the GNU Affero General Public License can be found in
* the LICENSE file in the top-level directory of this distribution
* and at http://www.gnu.org/licenses/.
*
*/
/* Functions that generate the test data fed into the DSP modules being developed */
#include <complex.h>
#include <stdio.h>
#include <stdlib.h>
#include <skeleton.h>
#include <params.h>
#define INCLUDE_DEFS_ONLY
#include "template.h"
int offset=0;
/**
* Generates input signal. VERY IMPORTANT to fill length vector with the number of
* samples that have been generated.
* @param inp Input interface buffers. Data from other interfaces is stacked in the buffer.
* Use in(ptr,idx) to access the address.
*
* @param lengths Save on n-th position the number of samples generated for the n-th interface
*/
int generate_input_signal(void *in, int *lengths)
{
int i;
input_t *input = in;
int block_length;
pmid_t blen_id;
blen_id = param_id("block_length");
if (!blen_id) {
moderror("Parameter block_length not found\n");
return -1;
}
if (!param_get_int(blen_id,&block_length)) {
moderror("Getting integer parameter block_length\n");
return -1;
}
modinfo_msg("Parameter block_length is %d\n",block_length);
/** HERE INDICATE THE LENGTH OF THE SIGNAL */
lengths[0] = block_length;
for (i=0;i<block_length;i++) {
#ifdef GENESRSLTE_TCOD_RATE_COMPLEX
__real__ input[i] = (float) ((i+offset)%(block_length));
__imag__ input[i] = (float) ((block_length-i-1+offset)%(block_length));
#else
input[i] = (i+offset)%(block_length);
#endif
}
offset++;
return 0;
}

View File

@ -54,21 +54,5 @@ SRSLTE_API void srslte_ch_awgn_f(const float* x,
SRSLTE_API float srslte_ch_awgn_get_variance(float ebno_db,
float rate);
/* High-level API */
typedef struct SRSLTE_API{
const cf_t* input;
int in_len;
struct srslte_ch_awgn_ctrl_in {
float variance; // Noise variance
} ctrl_in;
cf_t* output;
int out_len;
}srslte_ch_awgn_hl;
SRSLTE_API int srslte_ch_awgn_initialize(srslte_ch_awgn_hl* hl);
SRSLTE_API int srslte_ch_awgn_work(srslte_ch_awgn_hl* hl);
SRSLTE_API int srslte_ch_awgn_stop(srslte_ch_awgn_hl* hl);
#endif

View File

@ -54,26 +54,4 @@ SRSLTE_API int srslte_convcoder_encode(srslte_convcoder_t *q,
uint32_t frame_length);
/* High-level API */
typedef struct SRSLTE_API {
srslte_convcoder_t obj;
struct srslte_convcoder_ctrl_in {
int rate;
int constraint_length;
int tail_bitting;
int generator_0;
int generator_1;
int generator_2;
int frame_length;
} ctrl_in;
uint8_t *input;
int in_len;
uint8_t *output;
int out_len;
}srslte_convcoder_hl;
SRSLTE_API int srslte_convcoder_initialize(srslte_convcoder_hl* h);
SRSLTE_API int srslte_convcoder_work(srslte_convcoder_hl* hl);
SRSLTE_API int srslte_convcoder_stop(srslte_convcoder_hl* h);
#endif

View File

@ -56,26 +56,4 @@ SRSLTE_API int srslte_rm_conv_rx(float *input,
float *output,
uint32_t out_len);
/* High-level API */
typedef struct
SRSLTE_API {
struct srslte_rm_conv_init {
int direction;
} init;
void *input; // input type may be uint8_t or float depending on hard
int in_len;
struct srslte_rm_conv_ctrl_in {
int E;
int S;
} ctrl_in;
void *output;
int out_len;
} srslte_rm_conv_hl;
SRSLTE_API int srslte_rm_conv_initialize(srslte_rm_conv_hl* h);
SRSLTE_API int srslte_rm_conv_work(srslte_rm_conv_hl* hl);
SRSLTE_API int srslte_rm_conv_stop(srslte_rm_conv_hl* hl);
#endif

View File

@ -84,25 +84,4 @@ SRSLTE_API int srslte_rm_turbo_rx_lut(int16_t *input,
uint32_t rv_idx);
/* High-level API */
typedef struct SRSLTE_API {
struct srslte_rm_turbo_init {
int direction;
} init;
void *input; // input type may be uint8_t or float depending on hard
int in_len;
struct srslte_rm_turbo_ctrl_in {
int E;
int S;
int rv_idx;
} ctrl_in;
void *output;
int out_len;
} srslte_rm_turbo_hl;
SRSLTE_API int srslte_rm_turbo_initialize(srslte_rm_turbo_hl* h);
SRSLTE_API int srslte_rm_turbo_work(srslte_rm_turbo_hl* hl);
SRSLTE_API int srslte_rm_turbo_stop(srslte_rm_turbo_hl* hl);
#endif

View File

@ -83,27 +83,4 @@ SRSLTE_API int srslte_viterbi_decode_uc(srslte_viterbi_t *q,
uint8_t *data,
uint32_t frame_length);
/* High-level API */
typedef struct SRSLTE_API{
srslte_viterbi_t obj;
struct srslte_viterbi_init {
int rate;
int constraint_length;
int tail_bitting;
int generator_0;
int generator_1;
int generator_2;
int frame_length;
} init;
float *input;
int in_len;
uint8_t *output;
int out_len;
}srslte_viterbi_hl;
SRSLTE_API int srslte_viterbi_initialize(srslte_viterbi_hl* h);
SRSLTE_API int srslte_viterbi_work(srslte_viterbi_hl* hl);
SRSLTE_API int srslte_viterbi_stop(srslte_viterbi_hl* h);
#endif

View File

@ -69,22 +69,4 @@ SRSLTE_API int srslte_binsource_generate(srslte_binsource_t* q,
uint8_t *bits,
int nbits);
/* High-level API */
typedef struct SRSLTE_API {
srslte_binsource_t obj;
struct srslte_binsource_init {
int cache_seq_nbits; // If non-zero, generates random bits on init
uint32_t seed; // If non-zero, uses as random seed, otherwise local time is used.
} init;
struct srslte_binsource_ctrl_in {
int nbits; // Number of bits to generate
} ctrl_in;
uint8_t* output;
int out_len;
}srslte_binsource_hl;
SRSLTE_API int srslte_binsource_initialize(srslte_binsource_hl* h);
SRSLTE_API int srslte_binsource_work( srslte_binsource_hl* hl);
SRSLTE_API int srslte_binsource_stop(srslte_binsource_hl* hl);
#endif // BINSOURCE_

View File

@ -60,21 +60,4 @@ SRSLTE_API int srslte_filesink_write(srslte_filesink_t *q,
void *buffer,
int nsamples);
/* High-level API */
typedef struct SRSLTE_API {
srslte_filesink_t obj;
struct srslte_filesink_init {
char *file_name;
int block_length;
int data_type;
} init;
void* input;
int in_len;
}srslte_filesink_hl;
SRSLTE_API int srslte_filesink_initialize(srslte_filesink_hl* h);
SRSLTE_API int srslte_filesink_work( srslte_filesink_hl* hl);
SRSLTE_API int srslte_filesink_stop(srslte_filesink_hl* h);
#endif // FILESINK_

View File

@ -63,24 +63,4 @@ SRSLTE_API int srslte_filesource_read(srslte_filesource_t *q,
void *buffer,
int nsamples);
/* High-level API */
typedef struct SRSLTE_API {
srslte_filesource_t obj;
struct srslte_filesource_init {
char *file_name;
int block_length;
int data_type;
} init;
struct srslte_filesource_ctrl_in {
int nsamples; // Number of samples to read
} ctrl_in;
void* output;
int out_len;
}srslte_filesource_hl;
SRSLTE_API int srslte_filesource_initialize(srslte_filesource_hl* h);
SRSLTE_API int srslte_filesource_work( srslte_filesource_hl* hl);
SRSLTE_API int srslte_filesource_stop(srslte_filesource_hl* h);
#endif // FILESOURCE_

View File

@ -72,22 +72,4 @@ SRSLTE_API int srslte_netsink_write(srslte_netsink_t *q,
SRSLTE_API int srslte_netsink_set_nonblocking(srslte_netsink_t *q);
/* High-level API */
typedef struct SRSLTE_API {
srslte_netsink_t obj;
struct srslte_netsink_init {
char *address;
int port;
int block_length;
int data_type;
} init;
void* input;
int in_len;
}srslte_netsink_hl;
SRSLTE_API int srslte_netsink_initialize(srslte_netsink_hl* h);
SRSLTE_API int srslte_netsink_work( srslte_netsink_hl* hl);
SRSLTE_API int srslte_netsink_stop(srslte_netsink_hl* h);
#endif // UDPSINK_

View File

@ -76,24 +76,4 @@ SRSLTE_API int srslte_netsource_read(srslte_netsource_t *q,
SRSLTE_API int srslte_netsource_set_timeout(srslte_netsource_t *q,
uint32_t microseconds);
/* High-level API */
typedef struct SRSLTE_API {
srslte_netsource_t obj;
struct srslte_netsource_init {
char *address;
int port;
int data_type;
} init;
struct srslte_netsource_ctrl_in {
int nsamples; // Number of samples to read
} ctrl_in;
void* output;
int out_len;
}srslte_netsource_hl;
SRSLTE_API int srslte_netsource_initialize(srslte_netsource_hl* h);
SRSLTE_API int srslte_netsource_work( srslte_netsource_hl* hl);
SRSLTE_API int srslte_netsource_stop(srslte_netsource_hl* h);
#endif // UDPSOURCE_

View File

@ -58,23 +58,4 @@ SRSLTE_API int srslte_demod_hard_demodulate(srslte_demod_hard_t* q,
uint8_t *bits,
uint32_t nsymbols);
/* High-level API */
typedef struct SRSLTE_API {
srslte_demod_hard_t obj;
struct srslte_demod_hard_init {
srslte_mod_t std; // Symbol mapping standard (see modem_table.h)
} init;
cf_t* input;
int in_len;
uint8_t* output;
int out_len;
}srslte_demod_hard_hl;
SRSLTE_API int srslte_demod_hard_initialize(srslte_demod_hard_hl* hl);
SRSLTE_API int srslte_demod_hard_work(srslte_demod_hard_hl* hl);
SRSLTE_API int srslte_demod_hard_stop(srslte_demod_hard_hl* hl);
#endif // DEMOD_HARD_

View File

@ -54,29 +54,4 @@ SRSLTE_API int srslte_demod_soft_demodulate_s(srslte_mod_t modulation,
short* llr,
int nsymbols);
/* High-level API */
typedef struct SRSLTE_API {
srslte_modem_table_t table;
struct srslte_demod_soft_init{
srslte_mod_t std; // symbol mapping standard (see modem_table.h)
} init;
const cf_t* input;
int in_len;
struct srslte_demod_soft_ctrl_in {
float sigma; // Estimated noise variance
}ctrl_in;
float* output;
int out_len;
}srslte_demod_soft_hl;
SRSLTE_API int srslte_demod_soft_initialize(srslte_demod_soft_hl* hl);
SRSLTE_API int srslte_demod_soft_work(srslte_demod_soft_hl* hl);
SRSLTE_API int srslte_demod_soft_stop(srslte_demod_soft_hl* hl);
#endif // DEMOD_SOFT_

View File

@ -53,22 +53,4 @@ SRSLTE_API int srslte_mod_modulate_bytes(srslte_modem_table_t* q,
cf_t* symbols,
uint32_t nbits);
/* High-level API */
typedef struct SRSLTE_API {
srslte_modem_table_t obj;
struct mod_init {
srslte_mod_t std; // symbol mapping standard (see modem_table.h)
} init;
uint8_t* input;
int in_len;
cf_t* output;
int out_len;
}srslte_mod_hl;
SRSLTE_API int mod_initialize(srslte_mod_hl* hl);
SRSLTE_API int mod_work(srslte_mod_hl* hl);
SRSLTE_API int mod_stop(srslte_mod_hl* hl);
#endif // MOD_

View File

@ -135,32 +135,4 @@ SRSLTE_API int srslte_pss_synch_chest(srslte_pss_synch_t *q,
SRSLTE_API float srslte_pss_synch_cfo_compute(srslte_pss_synch_t* q,
cf_t *pss_recv);
/* High-level API */
typedef struct SRSLTE_API {
srslte_pss_synch_t obj;
struct srslte_pss_synch_init {
int frame_size; // if 0, 2048
int unsync_nof_pkts;
int N_id_2;
int do_cfo;
} init;
cf_t *input;
int in_len;
struct srslte_pss_synch_tctrl_in {
int correlation_threshold;
float manual_cfo;
} ctrl_in;
cf_t *output;
int out_len;
}srslte_pss_synch_hl;
#define DEFAULT_FRAME_SIZE 2048
SRSLTE_API int srslte_pss_synch_initialize(srslte_pss_synch_hl* h);
SRSLTE_API int srslte_pss_synch_twork(srslte_pss_synch_hl* hl);
SRSLTE_API int srslte_pss_synch_tstop(srslte_pss_synch_hl* hl);
#endif // PSS_

View File

@ -153,32 +153,5 @@ SRSLTE_API void srslte_sss_synch_set_symbol_sz(srslte_sss_synch_t *q,
SRSLTE_API void srslte_sss_synch_set_subframe_sz(srslte_sss_synch_t *q,
uint32_t subframe_sz);
/* High-level API */
typedef struct SRSLTE_API {
srslte_sss_synch_t obj;
struct srslte_sss_synch_init {
uint32_t N_id_2;
} init;
cf_t *input;
uint32_t in_len;
struct srslte_sss_synch_ctrl_in {
uint32_t symbol_sz;
uint32_t subframe_sz;
uint32_t correlation_threshold;
} ctrl_in;
struct srslte_sss_synch_ctrl_out {
uint32_t subframe_idx;
uint32_t N_id_1;
} ctrl_out;
}srslte_sss_synch_hl;
#define DEFAULT_FRAME_SIZE 2048
SRSLTE_API int srslte_sss_synch_initialize(srslte_sss_synch_hl* h);
SRSLTE_API int srslte_sss_synch_work(srslte_sss_synch_hl* hl);
SRSLTE_API int srslte_sss_synch_stop(srslte_sss_synch_hl* hl);
#endif // SSS_

View File

@ -57,19 +57,3 @@ void srslte_ch_awgn_f(const float* x, float* y, float variance, uint32_t len) {
y[i] = x[i] + variance * rand_gauss();
}
}
/* High-level API */
int srslte_ch_awgn_initialize(srslte_ch_awgn_hl* hl) {
return 0;
}
int srslte_ch_awgn_work(srslte_ch_awgn_hl* hl) {
srslte_ch_awgn_c(hl->input,hl->output,hl->ctrl_in.variance,hl->in_len);
hl->out_len = hl->in_len;
return 0;
}
int srslte_ch_awgn_stop(srslte_ch_awgn_hl* hl) {
return 0;
}

View File

@ -370,7 +370,7 @@ double cuhd_set_tx_gain(void *h, double gain)
{
cuhd_handler *handler = static_cast < cuhd_handler * >(h);
handler->usrp->set_tx_gain(gain);
return handler->usrp->get_tx_gain();
return gain;
}
double cuhd_set_tx_srate(void *h, double freq)

View File

@ -65,24 +65,3 @@ int srslte_convcoder_encode(srslte_convcoder_t *q, uint8_t *input, uint8_t *outp
}
}
int srslte_convcoder_initialize(srslte_convcoder_hl* h) {
return 0;
}
int srslte_convcoder_work(srslte_convcoder_hl* hl) {
hl->obj.K = hl->ctrl_in.constraint_length;
hl->obj.R = hl->ctrl_in.rate;
hl->obj.poly[0] = hl->ctrl_in.generator_0;
hl->obj.poly[1] = hl->ctrl_in.generator_1;
hl->obj.poly[2] = hl->ctrl_in.generator_2;
hl->obj.tail_biting = hl->ctrl_in.tail_bitting?true:false;
hl->out_len = srslte_convcoder_encode(&hl->obj, hl->input, hl->output, hl->in_len);
return 0;
}
int srslte_convcoder_stop(srslte_convcoder_hl* h) {
return 0;
}

View File

@ -153,26 +153,3 @@ int srslte_rm_conv_rx(float *input, uint32_t in_len, float *output, uint32_t out
return 0;
}
/** High-level API */
int srslte_rm_conv_initialize(srslte_rm_conv_hl* h) {
return 0;
}
/** This function can be called in a subframe (1ms) basis */
int srslte_rm_conv_work(srslte_rm_conv_hl* hl) {
if (hl->init.direction) {
srslte_rm_conv_tx(hl->input, hl->in_len, hl->output, hl->ctrl_in.E);
hl->out_len = hl->ctrl_in.E;
} else {
srslte_rm_conv_rx(hl->input, hl->in_len, hl->output, hl->ctrl_in.S);
hl->out_len = hl->ctrl_in.S;
}
return 0;
}
int srslte_rm_conv_stop(srslte_rm_conv_hl* hl) {
return 0;
}

View File

@ -716,20 +716,3 @@ int srslte_rm_turbo_rx(float *w_buff, uint32_t w_buff_len, float *input, uint32_
return 0;
}
/** High-level API */
int srslte_rm_turbo_initialize(srslte_rm_turbo_hl* h) {
return 0;
}
/** This function can be called in a subframe (1ms) basis */
int srslte_rm_turbo_work(srslte_rm_turbo_hl* hl) {
return 0;
}
int srslte_rm_turbo_stop(srslte_rm_turbo_hl* hl) {
return 0;
}

View File

@ -231,52 +231,3 @@ int srslte_viterbi_decode_uc(srslte_viterbi_t *q, uint8_t *symbols, uint8_t *dat
uint32_t frame_length) {
return q->decode(q, symbols, data, frame_length);
}
int srslte_viterbi_initialize(srslte_viterbi_hl* h) {
uint32_t poly[3];
srslte_viterbi_type_t type;
if (h->init.rate == 2) {
if (h->init.constraint_length == 7) {
type = SRSLTE_VITERBI_27;
} else if (h->init.constraint_length == 9) {
type = SRSLTE_VITERBI_29;
} else {
fprintf(stderr, "Unsupported decoder %d/%d\n", h->init.rate,
h->init.constraint_length);
return -1;
}
} else if (h->init.rate == 3) {
if (h->init.constraint_length == 7) {
type = SRSLTE_VITERBI_37;
} else if (h->init.constraint_length == 9) {
type = SRSLTE_VITERBI_39;
} else {
fprintf(stderr, "Unsupported decoder %d/%d\n", h->init.rate,
h->init.constraint_length);
return -1;
}
} else {
fprintf(stderr, "Unsupported decoder %d/%d\n", h->init.rate,
h->init.constraint_length);
return -1;
}
poly[0] = h->init.generator_0;
poly[1] = h->init.generator_1;
poly[2] = h->init.generator_2;
return srslte_viterbi_init(&h->obj, type, poly, (uint32_t) h->init.frame_length,
h->init.tail_bitting ? true : false);
}
int srslte_viterbi_work(srslte_viterbi_hl* hl) {
if (hl->in_len != hl->init.frame_length) {
fprintf(stderr, "Expected input length %d but got %d\n",
hl->init.frame_length, hl->in_len);
return -1;
}
return srslte_viterbi_decode_f(&hl->obj, hl->input, hl->output, hl->init.frame_length);
}
int srslte_viterbi_stop(srslte_viterbi_hl* h) {
srslte_viterbi_free(&h->obj);
return 0;
}

View File

@ -134,47 +134,3 @@ int srslte_binsource_generate(srslte_binsource_t* q, uint8_t *bits, int nbits) {
/* High-Level API */
int srslte_binsource_initialize(srslte_binsource_hl* hl) {
srslte_binsource_init(&hl->obj);
if (hl->init.seed) {
srslte_binsource_seed_set(&hl->obj,hl->init.seed);
} else {
srslte_binsource_seed_time(&hl->obj);
}
if (hl->init.cache_seq_nbits) {
if (srslte_binsource_cache_gen(&hl->obj,hl->init.cache_seq_nbits)) {
return -1;
}
}
return 0;
}
int srslte_binsource_work(srslte_binsource_hl* hl) {
int ret = -1;
if (hl->init.cache_seq_nbits) {
srslte_binsource_cache_cpy(&hl->obj,hl->output,hl->ctrl_in.nbits);
ret = 0;
} else {
ret = srslte_binsource_generate(&hl->obj,hl->output,hl->ctrl_in.nbits);
}
if (!ret) {
hl->out_len = hl->ctrl_in.nbits;
} else {
hl->out_len = 0;
}
return ret;
}
int srslte_binsource_stop(srslte_binsource_hl* hl) {
srslte_binsource_free(&hl->obj);
return 0;
}

View File

@ -100,20 +100,3 @@ int srslte_filesink_write(srslte_filesink_t *q, void *buffer, int nsamples) {
return i;
}
int srslte_filesink_initialize(srslte_filesink_hl* h) {
return srslte_filesink_init(&h->obj, h->init.file_name, h->init.data_type);
}
int srslte_filesink_work(srslte_filesink_hl* h) {
if (srslte_filesink_write(&h->obj, h->input, h->in_len)<0) {
return -1;
}
return 0;
}
int srslte_filesink_stop(srslte_filesink_hl* h) {
srslte_filesink_free(&h->obj);
return 0;
}

View File

@ -117,20 +117,3 @@ int srslte_filesource_read(srslte_filesource_t *q, void *buffer, int nsamples) {
return i;
}
int srslte_filesource_initialize(srslte_filesource_hl* h) {
return srslte_filesource_init(&h->obj, h->init.file_name, h->init.data_type);
}
int srslte_filesource_work(srslte_filesource_hl* h) {
h->out_len = srslte_filesource_read(&h->obj, h->output, h->ctrl_in.nsamples);
if (h->out_len < 0) {
return -1;
}
return 0;
}
int srslte_filesource_stop(srslte_filesource_hl* h) {
srslte_filesource_free(&h->obj);
return 0;
}

View File

@ -105,20 +105,3 @@ int srslte_netsink_write(srslte_netsink_t *q, void *buffer, int nof_bytes) {
return n;
}
int srslte_netsink_initialize(srslte_netsink_hl* h) {
return srslte_netsink_init(&h->obj, h->init.address, h->init.port, SRSLTE_NETSINK_UDP);
}
int srslte_netsink_work(srslte_netsink_hl* h) {
if (srslte_netsink_write(&h->obj, h->input, h->in_len)<0) {
return -1;
}
return 0;
}
int srslte_netsink_stop(srslte_netsink_hl* h) {
srslte_netsink_free(&h->obj);
return 0;
}

View File

@ -124,20 +124,3 @@ int srslte_netsource_set_timeout(srslte_netsource_t *q, uint32_t microseconds) {
}
return 0;
}
int srslte_netsource_initialize(srslte_netsource_hl* h) {
return srslte_netsource_init(&h->obj, h->init.address, h->init.port, SRSLTE_NETSOURCE_UDP);
}
int srslte_netsource_work(srslte_netsource_hl* h) {
h->out_len = srslte_netsource_read(&h->obj, h->output, h->ctrl_in.nsamples);
if (h->out_len < 0) {
return -1;
}
return 0;
}
int srslte_netsource_stop(srslte_netsource_hl* h) {
srslte_netsource_free(&h->obj);
return 0;
}

View File

@ -66,21 +66,3 @@ int srslte_demod_hard_demodulate(srslte_demod_hard_t* q, cf_t* symbols, uint8_t
}
int srslte_demod_hard_initialize(srslte_demod_hard_hl* hl) {
srslte_demod_hard_init(&hl->obj);
srslte_demod_hard_table_set(&hl->obj,hl->init.std);
return 0;
}
int srslte_demod_hard_work(srslte_demod_hard_hl* hl) {
int ret = srslte_demod_hard_demodulate(&hl->obj,hl->input,hl->output,hl->in_len);
hl->out_len = ret;
return 0;
}
int srslte_demod_hard_stop(srslte_demod_hard_hl* hl) {
return 0;
}

View File

@ -282,19 +282,3 @@ int srslte_demod_soft_demodulate_s(srslte_mod_t modulation, const cf_t* symbols,
}
return 0;
}
/* High-Level API */
int srslte_demod_soft_initialize(srslte_demod_soft_hl* hl) {
return 0;
}
int srslte_demod_soft_work(srslte_demod_soft_hl* hl) {
int ret = srslte_demod_soft_demodulate(hl->init.std,hl->input,hl->output,hl->in_len);
hl->out_len = ret;
return 0;
}
int srslte_demod_soft_stop(srslte_demod_soft_hl* hl) {
return 0;
}

View File

@ -152,27 +152,3 @@ int srslte_mod_modulate_bytes(srslte_modem_table_t* q, uint8_t *bits, cf_t* symb
}
return nbits/q->nbits_x_symbol;
}
/* High-Level API */
int mod_initialize(srslte_mod_hl* hl) {
srslte_modem_table_init(&hl->obj);
if (srslte_modem_table_lte(&hl->obj,hl->init.std)) {
return -1;
}
return 0;
}
int mod_work(srslte_mod_hl* hl) {
int ret = srslte_mod_modulate(&hl->obj,hl->input,hl->output,hl->in_len);
hl->out_len = ret;
return 0;
}
int mod_stop(srslte_mod_hl* hl) {
srslte_modem_table_free(&hl->obj);
return 0;
}

View File

@ -151,30 +151,3 @@ int srslte_sss_synch_N_id_1(srslte_sss_synch_t *q, uint32_t m0, uint32_t m1) {
}
return N_id_1;
}
/** High-level API */
int srslte_sss_synch_initialize(srslte_sss_synch_hl* h) {
if (srslte_sss_synch_init(&h->obj, 128)) {
return SRSLTE_ERROR;
}
srslte_sss_synch_set_N_id_2(&h->obj, h->init.N_id_2);
return SRSLTE_SUCCESS;
}
int srslte_sss_synch_work(srslte_sss_synch_hl* hl) {
if (hl->ctrl_in.correlation_threshold) {
srslte_sss_synch_set_threshold(&hl->obj, hl->ctrl_in.correlation_threshold);
}
return SRSLTE_SUCCESS;
}
int srslte_sss_synch_stop(srslte_sss_synch_hl* hl) {
srslte_sss_synch_free(&hl->obj);
return SRSLTE_SUCCESS;
}

View File

@ -418,7 +418,7 @@ int srslte_ue_ul_srs_encode(srslte_ue_ul_t *q, uint32_t tti, cf_t *output_signal
}
if (q->normalize_en) {
float norm_factor = (float) q->cell.nof_prb/20/sqrtf(srslte_refsignal_srs_M_sc(&q->signals)/6);
float norm_factor = (float) q->cell.nof_prb/15/sqrtf(srslte_refsignal_srs_M_sc(&q->signals));
srslte_vec_sc_prod_cfc(output_signal, norm_factor, output_signal, SRSLTE_SF_LEN_PRB(q->cell.nof_prb));
}