Commit f755974c authored by Thanassis Tsiodras's avatar Thanassis Tsiodras

Merge remote-tracking branch 'origin/crazyflie'

parents 39d011ab 7fee05cb
......@@ -100,11 +100,17 @@ class ASynchronousToolGlueGenerator:
ID = re.sub(r'[^A-Za-z0-9_]', '_', ID).upper()
self.C_HeaderFile.write("#ifndef __%s_H__\n" % ID)
self.C_HeaderFile.write("#define __%s_H__\n\n" % ID)
self.C_HeaderFile.write("#ifdef __unix__\n")
self.C_HeaderFile.write("#include <stdlib.h> /* for size_t */\n")
self.C_HeaderFile.write("#else\n")
self.C_HeaderFile.write("typedef unsigned size_t;\n")
self.C_HeaderFile.write("#endif\n\n")
self.C_HeaderFile.write("\n")
self.C_SourceFile.write("#ifdef __unix__\n")
self.C_SourceFile.write("#include <stdio.h>\n")
self.C_SourceFile.write("#include <assert.h>\n")
self.C_SourceFile.write("#endif\n\n")
self.C_SourceFile.write("#include <string.h>\n\n")
self.C_SourceFile.write("#include <assert.h>\n\n")
self.C_SourceFile.write("#include \"%s\"\n\n" % outputCheaderFilename)
self.HeadersOnStartup(asnFile, outputDir, maybeFVname)
......
......@@ -306,8 +306,10 @@ class C_GlueGenerator(ASynchronousToolGlueGenerator):
self.C_SourceFile.write(" if (ossEncode(g_world, OSS_%s_PDU, &var_%s, &strm) != 0) {\n" %
(self.CleanNameAsToolWants(nodeTypename),
self.CleanNameAsToolWants(nodeTypename)))
self.C_SourceFile.write("#ifdef __unix__\n")
self.C_SourceFile.write(
'\tfprintf(stderr, "Could not encode %s (at %%s, %%d), errorMessage was %%s\\n", __FILE__, __LINE__, ossGetErrMsg(g_world));\n' % nodeTypename)
self.C_SourceFile.write("#endif\n")
self.C_SourceFile.write(" return -1;\n")
self.C_SourceFile.write(" } else {\n")
self.C_SourceFile.write(" assert(strm.length <= iMaxBufferSize);\n")
......@@ -321,8 +323,10 @@ class C_GlueGenerator(ASynchronousToolGlueGenerator):
self.C_SourceFile.write(" if (asn1Scc%s_%sEncode(pSrc, &strm, &errorCode, TRUE) == FALSE) {\n" %
(self.CleanNameAsToolWants(nodeTypename),
("ACN_" if encoding.lower() == "acn" else "")))
self.C_SourceFile.write("#ifdef __unix__\n")
self.C_SourceFile.write(
'\tfprintf(stderr, "Could not encode %s (at %%s, %%d), errorCode was %%d\\n", __FILE__, __LINE__, errorCode);\n' % nodeTypename)
self.C_SourceFile.write("#endif\n")
self.C_SourceFile.write(" return -1;\n")
self.C_SourceFile.write(" } else {\n")
self.C_SourceFile.write(" return BitStream_GetLength(&strm);\n")
......@@ -399,8 +403,10 @@ class C_GlueGenerator(ASynchronousToolGlueGenerator):
self.CleanNameAsToolWants(nodeTypename))
self.C_SourceFile.write(" return 0;\n")
self.C_SourceFile.write(" } else {\n")
self.C_SourceFile.write("#ifdef __unix__\n")
self.C_SourceFile.write(
'\tfprintf(stderr, "Could not decode %s (at %%s, %%d), error message was %%s\\n", __FILE__, __LINE__, ossGetErrMsg(g_world));\n' % nodeTypename)
self.C_SourceFile.write("#endif\n")
self.C_SourceFile.write(" return -1;\n")
self.C_SourceFile.write(" }\n")
self.C_SourceFile.write("}\n")
......@@ -408,8 +414,10 @@ class C_GlueGenerator(ASynchronousToolGlueGenerator):
elif encoding.lower() in ["uper", "acn"]:
self.C_SourceFile.write(" return 0;\n")
self.C_SourceFile.write(" } else {\n")
self.C_SourceFile.write("#ifdef __unix__\n")
self.C_SourceFile.write(
'\tfprintf(stderr, "Could not decode %s (at %%s, %%d), error code was %%d\\n", __FILE__, __LINE__, errorCode);\n' % nodeTypename)
self.C_SourceFile.write("#endif\n")
self.C_SourceFile.write(" return -1;\n")
self.C_SourceFile.write(" }\n")
self.C_SourceFile.write("}\n")
......
......@@ -172,9 +172,11 @@ class SynchronousToolGlueGeneratorGeneric(Generic[TSource, TDestin]):
self.C_HeaderFile.write("#include <stdlib.h> /* for size_t */\n")
self.C_HeaderFile.write("\n")
self.C_SourceFile.write("#ifdef __unix__\n")
self.C_SourceFile.write("#include <stdio.h>\n")
self.C_SourceFile.write("#include <string.h>\n\n")
self.C_SourceFile.write("#include <assert.h>\n\n")
self.C_SourceFile.write("#endif\n")
self.C_SourceFile.write("#include \"%s\"\n" % outputCheaderFilename)
......@@ -294,8 +296,10 @@ class SynchronousToolGlueGeneratorGeneric(Generic[TSource, TDestin]):
self.C_SourceFile.write(
" if (ossEncode(g_world, OSS_%s_PDU, &var_%s, &strm) != 0) {\n" %
(self.CleanNameAsToolWants(nodeTypename), self.CleanNameAsToolWants(nodeTypename)))
self.C_SourceFile.write("#ifdef __unix__\n")
self.C_SourceFile.write(
' fprintf(stderr, "Could not encode %s (at %%s, %%d), errorMessage was %%s\\n", __FILE__, __LINE__, ossGetErrMsg(g_world));\n' % nodeTypename)
self.C_SourceFile.write("#endif\n")
self.C_SourceFile.write(" return -1;\n")
self.C_SourceFile.write(" } else {\n")
self.C_SourceFile.write(" assert(strm.length <= iMaxBufferSize);\n")
......@@ -310,8 +314,10 @@ class SynchronousToolGlueGeneratorGeneric(Generic[TSource, TDestin]):
(self.CleanNameAsToolWants(nodeTypename),
"ACN_" if encoding.lower() == "acn" else "",
self.CleanNameAsToolWants(nodeTypename)))
self.C_SourceFile.write("#ifdef __unix__\n")
self.C_SourceFile.write(
' fprintf(stderr, "Could not encode %s (at %%s, %%d), errorCode was %%d\\n", __FILE__, __LINE__, errorCode);\n' % nodeTypename)
self.C_SourceFile.write("#endif\n")
self.C_SourceFile.write(" return -1;\n")
self.C_SourceFile.write(" } else {\n")
self.C_SourceFile.write(" return BitStream_GetLength(&strm);\n")
......@@ -438,16 +444,20 @@ class SynchronousToolGlueGeneratorGeneric(Generic[TSource, TDestin]):
self.C_SourceFile.write(" ossFreeBuf(g_world, pVar_%s);\n" % self.CleanNameAsToolWants(nodeTypename))
self.C_SourceFile.write(" return 0;\n")
self.C_SourceFile.write(" } else {\n")
self.C_SourceFile.write("#ifdef __unix__\n")
self.C_SourceFile.write(
' fprintf(stderr, "Could not decode %s (at %%s, %%d), error message was %%s\\n", __FILE__, __LINE__, ossGetErrMsg(g_world));\n' % nodeTypename)
self.C_SourceFile.write("#endif\n")
self.C_SourceFile.write(" return -1;\n")
self.C_SourceFile.write(" }\n")
self.C_SourceFile.write("}\n\n")
elif encoding.lower() in ["uper", "acn"]:
self.C_SourceFile.write(" return 0;\n")
self.C_SourceFile.write(" } else {\n")
self.C_SourceFile.write("#ifdef __unix__\n")
self.C_SourceFile.write(
' fprintf(stderr, "Could not decode %s (at %%s, %%d), error code was %%d\\n", __FILE__, __LINE__, errorCode);\n' % nodeTypename)
self.C_SourceFile.write("#endif\n")
self.C_SourceFile.write(" return -1;\n")
self.C_SourceFile.write(" }\n")
self.C_SourceFile.write("}\n\n")
......
......@@ -157,6 +157,7 @@ def calculateForNativeAndASN1SCC(absASN1SCCpath, autosrc, names, inputFiles):
os.chdir(autosrc)
path_to_compiler = spawn.find_executable(cc.decode('utf-8'))
if path_to_compiler is None:
os.chdir(pwd)
continue
for cfile in os.listdir("."):
if cfile.endswith(".c"):
......
......@@ -19,7 +19,7 @@ import pkg_resources # pragma: no cover
try:
__version__ = pkg_resources.require("dmt")[0].version # pragma: no cover
except:
__version__ = "2.1.2"
__version__ = "2.1.3"
def print_version() -> None:
......
......@@ -207,7 +207,9 @@ def main():
C_HeaderFile.write('#endif\n\n')
C_SourceFile = open(configMT.outputDir + os.sep + "PrintTypes.c", "w")
C_SourceFile.write('#include <stdio.h>\n\n')
C_SourceFile.write('#ifdef __unix__\n')
C_SourceFile.write('#include <stdio.h>\n')
C_SourceFile.write('#endif\n')
C_SourceFile.write('#include "PrintTypes.h"\n\n')
C_SourceFile.write('#ifdef __linux__\n')
C_SourceFile.write('#include <pthread.h>\n\n')
......@@ -243,6 +245,7 @@ def main():
C_SourceFile.write('#ifdef __linux__\n')
C_SourceFile.write(' pthread_mutex_lock(&g_printing_mutex);\n')
C_SourceFile.write('#endif\n')
C_SourceFile.write('#ifdef __unix__\n')
lines = [" " + x
for x in printer.Map(
'(*pData)',
......@@ -251,7 +254,8 @@ def main():
leafTypeDict,
asnParser.g_names)]
C_SourceFile.write("\n".join(lines))
C_SourceFile.write('\n#ifdef __linux__\n')
C_SourceFile.write('\n#endif\n')
C_SourceFile.write('#ifdef __linux__\n')
C_SourceFile.write(' pthread_mutex_unlock(&g_printing_mutex);\n')
C_SourceFile.write('#endif\n')
C_SourceFile.write('}\n\n')
......
......@@ -226,7 +226,9 @@ def main():
C_HeaderFile.write('#endif\n\n')
C_SourceFile = open(configMT.outputDir + os.sep + "PrintTypesAsASN1.c", "w")
C_SourceFile.write('#include <stdio.h>\n\n')
C_SourceFile.write('#ifdef __unix__\n')
C_SourceFile.write('#include <stdio.h>\n')
C_SourceFile.write('#endif\n\n')
C_SourceFile.write('#include "PrintTypesAsASN1.h"\n\n')
C_SourceFile.write('#ifdef __linux__\n')
C_SourceFile.write('#include <pthread.h>\n\n')
......@@ -262,12 +264,14 @@ def main():
C_SourceFile.write('#ifdef __linux__\n')
C_SourceFile.write(' pthread_mutex_lock(&g_printing_mutex);\n')
C_SourceFile.write('#endif\n')
C_SourceFile.write('#ifdef __unix__\n')
C_SourceFile.write(' //printf("%%s %s ::= ", paramName);\n' % nodeTypename)
C_SourceFile.write(' printf("%s ", paramName);\n')
# C_SourceFile.write('\n'.join(printer.Map('(*pData)', '', node, leafTypeDict, asnParser.g_names)))
lines = [" " + x for x in printer.Map('(*pData)', '', node, leafTypeDict, asnParser.g_names)]
C_SourceFile.write("\n".join(lines))
C_SourceFile.write('\n#ifdef __linux__\n')
C_SourceFile.write('\n#endif\n')
C_SourceFile.write('#ifdef __linux__\n')
C_SourceFile.write(' pthread_mutex_unlock(&g_printing_mutex);\n')
C_SourceFile.write('#endif\n')
C_SourceFile.write('}\n\n')
......
......@@ -11,7 +11,7 @@ from setuptools import setup, find_packages
setup(
name='dmt',
version="2.1.16",
version="2.1.17",
packages=find_packages(),
author='Thanassis Tsiodras',
author_email='Thanassis.Tsiodras@esa.int',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment