- From: bryan cole <bryan.cole_at_teraview.com>
- Date: Thu, 18 Mar 2004 14:31:49 +0000
Hi Matt, Sorry the python wrappers aren't properly documented: I don't have much time for python developement, unfortunately. Comedilib does now ship with one version of the python wrappers included. You go to the 'comedilib/swig/python' subdirectory and run 'python setup.py install' as root. This should automatically build the python wrappers using SWIG, compile them and then install them in the site-packages directory of your python distribution (you need swig-1.3 or later for this. get it from 'www.swig.org'). *BUT* the current version of comedilib ships with an old version of the comedi.i swig interface file. The wrappers which this file creates have a few fundamental flaws (although I think they build fine). I've attached an updated comedi.i interface file which I use, which has fixed most of these issues (well, it works great for me, anyway). Simply drop it in place of the existing comedi.i file and then rerun swig (execute 'swig -python comedi.i') to recreate new wrappers. You can then rebuild these using 'python setup.py install'. Hopefully, everything will go without a hitch :) verify that the modules works by opening a python shell and importing the module: # python ... etc ... >>> import comedi Or run the attached file 'SimpleDataLogger.py' as a test (assuming you're using a analog-input card of some form). BTW, I'm assuming you've got an otherwise working Comedi installation I.e. you've compiled, installed and tested Comedi and Comedilib (by running one of the comedilib example programs). If not, you'd best concentrate on getting that working before worrying about the python wrappers. The wrappers are a 1:1 mirror of all the Comedilib functions. You can create a comedi data-structure e.g. a 'comedi_cmd' structure using an appropriate swig-generated wrapper class e.g.: myCmd = comedi.comedi_cmd_struct() myCmd.Command.subdev = 0 myCmd.flags = 0 myCmd.start_src = comedi.TRIG_NOW ... etc ... I.e. all structures have '_struct' on the end of the creator function name. Comedilib Functions which return one or more results back by reference simply return a tuple when accessed from python (and leave out the pointer argument to the function). Feel free to email me if you have problems or further questions. HTH Bryan On Wed, 2004-03-17 at 22:02, Matt wrote: > Hi, > > I work for a research group at Georgia Tech. I'm interested in using > comedi with python (specifically usb-dux), but I can't find stuff about > this anywhere. > > I saw you post this to the mailing list: > > As far as Comedi supported cards go, I've always found NI E-series cards > work well. I posted complete python-wrappers to the Comedi list a while > back. These allow you to call Comedi functions directly from Python. > Great for rapid prototyping. On Win32, we have python-wrappers for the > NI-DAQ win32 drivers these NI cards. > > but I can't actually find the wrappers you mention. Also in the > distribution of comedi that I have, I found this in the README in > comedlib/demos/python: > > I wrote the python scripts using Bryan Cole's comedi wrappers. I > followed the instructions provided by him to generate the comedi > python module. > > And yet I can't find instructions anywhere. Any idea why this stuff isn't > included with all the other comedi stuff in one neat bundle? > > I'd appreciate any help you could offer. > > Thanks, > Matt > > Georgia Institute of Technology > Atlanta, GA, US -- Bryan Cole Teraview Ltd., 302-304 Cambridge Science Park, Milton Road, Cambridge CB4 0WG, United Kingdom. tel: +44 (1223) 435380 / 435386 (direct-dial) fax: +44 (1223) 435382
Attachments
- text/plain attachment: comedi.i
- text/x-python attachment: SimpleDataLogger.py
Received on 2004-03-18Z14:31:49