Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: lcm-python/module.c
- ===================================================================
- --- lcm-python/module.c (revision 638)
- +++ lcm-python/module.c (working copy)
- @@ -1,4 +1,5 @@
- #include <Python.h>
- +#include "pylcm_subscription.h"
- //#define dbg(...) fprintf (stderr, __VA_ARGS__)
- #define dbg(...)
- Index: lcm-python/pyeventlog.c
- ===================================================================
- --- lcm-python/pyeventlog.c (revision 638)
- +++ lcm-python/pyeventlog.c (working copy)
- @@ -1,6 +1,9 @@
- #include <Python.h>
- #include <lcm/eventlog.h>
- +#ifdef WIN32
- +#include <WinPorting.h>
- +#endif
- typedef struct {
- PyObject_HEAD
- @@ -13,7 +16,8 @@
- "Event Log parser\n\
- ");
- -PyTypeObject pylcmeventlog_type;
- +//gives redefinition error in MSVC
- +//PyTypeObject pylcmeventlog_type;
- static PyObject *
- pylog_close (PyLogObject *self)
- @@ -134,14 +138,14 @@
- return NULL;
- }
- - lcm_eventlog_event_t le = {
- - .eventnum = 0,
- - .timestamp = utime,
- - .channellen = channellen,
- - .datalen = datalen,
- - .channel = channel,
- - .data = data
- - };
- + lcm_eventlog_event_t le; //msvc needs init of all fields seperately
- + le.eventnum = 0;
- + le.timestamp = utime;
- + le.channellen = channellen;
- + le.datalen = datalen;
- + le.channel = channel;
- + le.data = data;
- +
- if (0 != lcm_eventlog_write_event (self->eventlog, &le)) {
- PyErr_SetFromErrno (PyExc_IOError);
- @@ -194,14 +198,15 @@
- static PyObject *
- pylog_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
- {
- - PyObject *new;
- + //msvc does not allow usage of new as variable name
- + PyObject *newobj;
- - new = type->tp_alloc(type, 0);
- - if (new != NULL) {
- - ((PyLogObject *)new)->eventlog = NULL;
- - ((PyLogObject *)new)->mode = 0;
- + newobj = type->tp_alloc(type, 0);
- + if (newobj != NULL) {
- + ((PyLogObject *)newobj)->eventlog = NULL;
- + ((PyLogObject *)newobj)->mode = 0;
- }
- - return new;
- + return newobj;
- }
- static void
- Index: lcm-python/pylcm.c
- ===================================================================
- --- lcm-python/pylcm.c (revision 638)
- +++ lcm-python/pylcm.c (working copy)
- @@ -1,3 +1,4 @@
- +#ifndef WIN32
- #include <sys/socket.h>
- #include <sys/select.h>
- #include <netinet/in.h>
- @@ -2,2 +3,5 @@
- #include <arpa/inet.h>
- +#else
- +#include <winsock2.h>
- +#endif
- @@ -54,7 +58,8 @@
- @undocumented: __new__, __getattribute__\n\
- ");
- -PyTypeObject pylcm_type;
- +//gives redefinition error in MSVC
- +//PyTypeObject pylcm_type;
- // all LCM messages subscribed to by all LCM objects pass through this
- // handler first.
- @@ -64,9 +69,10 @@
- {
- // if an exception has occurred, then abort.
- if (PyErr_Occurred ()) return;
- +
- + //MSVC requires explicit cast
- + PyLCMSubscriptionObject *subs_obj = (PyLCMSubscriptionObject*) userdata;
- - PyLCMSubscriptionObject *subs_obj = userdata;
- -
- PyObject *arglist = Py_BuildValue ("ss#", channel,
- rbuf->data, rbuf->data_size);
- Index: lcm-python/setup.py
- ===================================================================
- --- lcm-python/setup.py (revision 638)
- +++ lcm-python/setup.py (working copy)
- @@ -1,30 +1,68 @@
- import commands
- from distutils.core import setup, Extension
- +from distutils import msvccompiler
- +import os
- +if os.name == 'nt':
- + #check for GLIB_PATH environment var, exit with error if not found
- + glibPath = os.getenv('GLIB_PATH')
- + if not glibPath:
- + sys.exit('GLIB_PATH environment variable not set.')
- +
- + includeDirs = []
- + lcmBase = '..'
- + includeDirs.append(os.path.join(lcmBase, 'WinSpecific\include'))
- + includeDirs.append(os.path.join(lcmBase, 'WinSpecific'))
- +
- + libraryDirs = ['..\WinSpecific\Release', os.path.join(glibPath, 'lib')]
- +
- + #define additional macro WIN32, used to discriminate win specific code
- + defineMacros = [('WIN32', 1)]
- +
- + winlibs = ['Ws2_32', 'glib-2.0', 'gthread-2.0', 'lcm']
- + # compiler arguments
- + # /TP enforces compilation of code as c++
- + extraCompileArgs = ['/TP']
- -pkgconfig_cflags = commands.getoutput ("pkg-config --cflags lcm glib-2.0 gthread-2.0")
- -pkgconfig_include_flags = commands.getoutput ("pkg-config --cflags-only-I lcm")
- -pkgconfig_include_dirs = [ t[2:] for t in pkgconfig_include_flags.split() ]
- + # we need to patch the msvccompiler.MSVCCompiler class to compile
- + # .c C files as C++ code (/TP switch for MSVC)
- + # the default behaviour generates the command line switch /Tc for
- + # every .c source file
- + msvccompiler.MSVCCompiler._c_extensions = []
- + msvccompiler.MSVCCompiler._cpp_extensions.append('.c')
- +
- + pylcm_extension = Extension("lcm._lcm", ["module.c", "pyeventlog.c", "pylcm.c",
- + "pylcm_subscription.c"],
- + include_dirs=includeDirs,
- + define_macros=defineMacros,
- + library_dirs=libraryDirs,
- + libraries=winlibs,
- + extra_compile_args=extraCompileArgs
- + )
- +else:
- + pkgconfig_cflags = commands.getoutput ("pkg-config --cflags lcm glib-2.0 gthread-2.0")
- + pkgconfig_include_flags = commands.getoutput ("pkg-config --cflags-only-I lcm")
- + pkgconfig_include_dirs = [ t[2:] for t in pkgconfig_include_flags.split() ]
- -pkgconfig_lflags = commands.getoutput ( \
- - "pkg-config --libs-only-l lcm glib-2.0 gthread-2.0")
- -pkgconfig_libs = [ t[2:] for t in pkgconfig_lflags.split() ]
- + pkgconfig_lflags = commands.getoutput ( \
- + "pkg-config --libs-only-l lcm glib-2.0 gthread-2.0")
- + pkgconfig_libs = [ t[2:] for t in pkgconfig_lflags.split() ]
- -pkgconfig_biglflags = commands.getoutput ( \
- - "pkg-config --libs-only-L lcm glib-2.0 gthread-2.0")
- -pkgconfig_ldirs = [ t[2:] for t in pkgconfig_biglflags.split() ]
- + pkgconfig_biglflags = commands.getoutput ( \
- + "pkg-config --libs-only-L lcm glib-2.0 gthread-2.0")
- + pkgconfig_ldirs = [ t[2:] for t in pkgconfig_biglflags.split() ]
- -pylcm_extension = Extension("lcm._lcm",
- - sources=["module.c", "pyeventlog.c", "pylcm.c",
- - "pylcm_subscription.c"],
- - library_dirs=pkgconfig_ldirs,
- - include_dirs=pkgconfig_include_dirs,
- - libraries=pkgconfig_libs,
- - extra_compile_args=['-Wno-strict-prototypes',
- - pkgconfig_cflags,
- - "-D_FILE_OFFSET_BITS=64",
- - "-D_LARGEFILE_SOURCE",
- - "-std=gnu99" ])
- + pylcm_extension = Extension("lcm._lcm",
- + sources=["module.c", "pyeventlog.c", "pylcm.c",
- + "pylcm_subscription.c"],
- + library_dirs=pkgconfig_ldirs,
- + include_dirs=pkgconfig_include_dirs,
- + libraries=pkgconfig_libs,
- + extra_compile_args=['-Wno-strict-prototypes',
- + pkgconfig_cflags,
- + "-D_FILE_OFFSET_BITS=64",
- + "-D_LARGEFILE_SOURCE",
- + "-std=gnu99" ])
- setup(name="lcm", version="0.8.0",
- ext_modules=[pylcm_extension],
- Index: WinSpecific/include/lcm/lcm.h
- ===================================================================
- --- WinSpecific/include/lcm/lcm.h (revision 638)
- +++ WinSpecific/include/lcm/lcm.h (working copy)
- @@ -213,6 +213,28 @@
- LCM_API_FUNCTION
- int lcm_handle (lcm_t *lcm);
- +/**
- + * @brief Adjusts the maximum number of received messages that can be queued up
- + * for a subscription.
- + *
- + * In general, you probably don't want to use this function. Instead, use the
- + * message-specific set_queue_capacity function generated by @c lcm-gen. Use
- + * this function only when you want to work with untyped subscriptions. TODO
- + * link to example or more details.
- + *
- + * Setting this to a low number may reduce overall latency at the expense of
- + * dropping more messages. Conversely, setting this to a high number may drop
- + * fewer messages at the expense of increased latency. A value of 0 indicates
- + * no limit, and should be used carefully.
- + *
- + * @param handler the subscription object
- + * @param num_messages the maximum queue size, in messages. The default is 30.
- + *
- + */
- +LCM_API_FUNCTION
- +int lcm_subscription_set_queue_capacity(lcm_subscription_t* handler, int num_messages);
- +
- +
- #ifdef __cplusplus
- }
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement