Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #58796 > unrolled thread

Talking to a 'C' program

Started byJohn Pote <johnhpote@o2.co.uk>
First post2013-11-08 14:23 +0000
Last post2013-11-08 16:08 +0000
Articles 3 — 2 participants

Back to article view | Back to comp.lang.python


Contents

  Talking to a 'C' program John Pote <johnhpote@o2.co.uk> - 2013-11-08 14:23 +0000
    Re: Talking to a 'C' program Grant Edwards <invalid@invalid.invalid> - 2013-11-08 15:00 +0000
      Re: Talking to a 'C' program John Pote <johnhpote@o2.co.uk> - 2013-11-08 16:08 +0000

#58796 — Talking to a 'C' program

FromJohn Pote <johnhpote@o2.co.uk>
Date2013-11-08 14:23 +0000
SubjectTalking to a 'C' program
Message-ID<mailman.2220.1383920660.18130.python-list@python.org>
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.

Also as I don't have any microsoft offerings of a C compiler any suggestions as to a suitable C compiler for a PC appreciated as well. llvm? mingw? gcc?

Thanks a lot everyone,
John

[toc] | [next] | [standalone]


#58801

FromGrant Edwards <invalid@invalid.invalid>
Date2013-11-08 15:00 +0000
Message-ID<l5iuaf$1ig$1@reader1.panix.com>
In reply to#58796
On 2013-11-08, John Pote <johnhpote@o2.co.uk> 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.

Sockets are nice and simple.  Depending on what you're doing,
stdin/stdout may be even simpler.

For the RS232 part of the problem, don't forget about pyserial:

  http://pyserial.sourceforge.net/pyserial.html

> Any ideas on how to do this would be gratefully appreciated.
>
> Also as I don't have any microsoft offerings of a C compiler any
> suggestions as to a suitable C compiler for a PC appreciated as well.
> llvm? mingw? gcc?

I've occasionaly used mingw (which _is_ gcc), and it worked well.
Cygwin (also gcc) works well, but it's a bit more involved.

I do all my embedded development on a Linux host.  I find Linux to be
far more suitable for the task -- the entire Unix system basically
evolved as a software development platform.  I've yet to figure out
what MS-Windows is suited for other than lining Bill Gates' pockets.

Before Linux, I used Solaris/SunOS, and before that I used Unix V7.
Everytime I've been involved in a Microsoft-hosted embedded
development project, I just end up walking a way afterwards shaking my
head in puzzlement.

-- 
Grant Edwards               grant.b.edwards        Yow! I'm having a
                                  at               tax-deductible experience!
                              gmail.com            I need an energy crunch!!

[toc] | [prev] | [next] | [standalone]


#58810

FromJohn Pote <johnhpote@o2.co.uk>
Date2013-11-08 16:08 +0000
Message-ID<mailman.2226.1383927011.18130.python-list@python.org>
In reply to#58801

[Multipart message — attachments visible in raw view] — view raw

Thanks everyone for the advice, some good ideas to keep me busy. Will try and look at over weekend/next week as tied up the rest of today.

I've used pyserial several times  - many thanks to Chris Liechti for that module

Hmmmmm must be loosing it, forgot about stdin/out!

I've also used CUnit before and it's nice an easy and small. Problem is I've only 500 bytes code space left on the micro-controller so by the time CUnit gone in with the various tests I'm gonna run of room. I have to keep the RS232 driver in as well as it's the only way to talk to the controller.

Python + pyserial enables me to run the tests with the C compiled and run on the PC as well as compiled to run on the micro-controller. Python is a great environment for doing this sort of thing and, as has been mentioned, a GUI can be added easily (time permitting).

Thanks again all,
John
 
On 8 Nov 2013, at 15:00, Grant Edwards <invalid@invalid.invalid> wrote:

> On 2013-11-08, John Pote <johnhpote@o2.co.uk> 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.
> 
> Sockets are nice and simple.  Depending on what you're doing,
> stdin/stdout may be even simpler.
> 
> For the RS232 part of the problem, don't forget about pyserial:
> 
>  http://pyserial.sourceforge.net/pyserial.html
> 
>> Any ideas on how to do this would be gratefully appreciated.
>> 
>> Also as I don't have any microsoft offerings of a C compiler any
>> suggestions as to a suitable C compiler for a PC appreciated as well.
>> llvm? mingw? gcc?
> 
> I've occasionaly used mingw (which _is_ gcc), and it worked well.
> Cygwin (also gcc) works well, but it's a bit more involved.
> 
> I do all my embedded development on a Linux host.  I find Linux to be
> far more suitable for the task -- the entire Unix system basically
> evolved as a software development platform.  I've yet to figure out
> what MS-Windows is suited for other than lining Bill Gates' pockets.
> 
> Before Linux, I used Solaris/SunOS, and before that I used Unix V7.
> Everytime I've been involved in a Microsoft-hosted embedded
> development project, I just end up walking a way afterwards shaking my
> head in puzzlement.
> 
> -- 
> Grant Edwards               grant.b.edwards        Yow! I'm having a
>                                  at               tax-deductible experience!
>                              gmail.com            I need an energy crunch!!
> -- 
> https://mail.python.org/mailman/listinfo/python-list

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web