Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!news.linkpendium.com!news.linkpendium.com!panix!not-for-mail From: Grant Edwards Newsgroups: comp.lang.python Subject: Re: Talking to a 'C' program Date: Fri, 8 Nov 2013 15:04:03 +0000 (UTC) Organization: PANIX Public Access Internet and UNIX, NYC Lines: 37 Message-ID: References: <89D0AF8F-FE2A-4051-84E7-7373A7340C35@o2.co.uk> NNTP-Posting-Host: dsl.comtrol.com X-Trace: reader1.panix.com 1383923043 1616 64.122.56.22 (8 Nov 2013 15:04:03 GMT) X-Complaints-To: abuse@panix.com NNTP-Posting-Date: Fri, 8 Nov 2013 15:04:03 +0000 (UTC) User-Agent: slrn/1.0.1 (Linux) Xref: csiph.com comp.lang.python:58802 On 2013-11-08, Oscar Benjamin wrote: > On 8 November 2013 14:23, John Pote wrote: >> Hi all, >> >> I have the task of testing some embedded 'C' code for a small >> micro-controller. Thought it would be a good idea to test it on the >> PC first to make sure the algorithm is correct then perhaps test it >> on the controller via RS232 and an appropriate wrapper round the 'C' >> functions. >> >> On the PC I can use Python's unit test library module and logging to >> create a nice and easy to use environment (I like Python). So my >> question is how to communicate from Python to the C module on the PC. >> What I'd like is simplicity and ease of setting up. All I can think >> of myself is to use sockets. >> >> Any ideas on how to do this would be gratefully appreciated. > > Have a look at Cython: > http://cython.org/ > > This enables you to call C code from Python code within the same > process. You can also use c-types for that http://docs.python.org/2/library/ctypes.html#module-ctypes I've used Python/ctypes to exercise libraries written in C, but I've never done it under Windows. However, others have: http://hakantiftikci.wordpress.com/2009/11/14/generating-dll-using-mingw-and-using-them-in-python-via-ctypes/ -- Grant Edwards grant.b.edwards Yow! Give them RADAR-GUIDED at SKEE-BALL LANES and gmail.com VELVEETA BURRITOS!!