Should I use Python for these programs?

C

CC

Hi:

I have considerable C and assembly language experience. However, these
are mostly on embedded microcontrollers since I moved away from PC
programming all the way back in 1988 :-O

I wish to accomplish a few PC programming tasks, and am considering to
learn Python:

1. Develop a simple GUI program to run on Linux and Windows which can
send parameters and small blocks of data to an embedded microcontroller
device via RS-232 or USB. Also display simple data (probably single
numbers) sent from the device.

Note, if it is USB, then the client will be implemented by me using FTDI
chips that appear to the PC as a serial port.

2. Develop a simple vector drawing program that will allow one to
freehand draw a sketch composed of a few lines, or perhaps render text
in a vector form. Then sample the lines with a certain (user
configurable) spacing, and use the mouse to move the sample points along
the lines to tweak the sample locations if desired. Then output a file
of X,Y coordinates for the samples.

What is this crazy thing for? It's to develop simple lasershow vector
frames. I am also designing a DSP-based lasershow output device, so the
same capabilities of delivering a data payload over serial/USB to a
target device will be needed here as well.

I would prefer to be able to write a program that is cross-platform
between Linux and Windows. I realize this might be especially
problematic with the serial comms.

I am also confused by the plethora of Python GUI extensions, though
Tkinter seems like a likely candidate. I am uncertain if I will have
difficulty learning how to use this if I don't know Tcl/Tk.

Do you think Python is the right language for these projects?

Any input will be appreciated.
 
G

Grant Edwards

I wish to accomplish a few PC programming tasks, and am
considering to learn Python:

1. Develop a simple GUI program to run on Linux and Windows
which can send parameters and small blocks of data to an
embedded microcontroller device via RS-232 or USB. Also
display simple data (probably single numbers) sent from the
device.

Note, if it is USB, then the client will be implemented by
me using FTDI chips that appear to the PC as a serial port.

I do a lot of that sort of thing using Python. I'd probably
recommend using pyserial and wxWidgets. Both are
cross-platform.

http://pyserial.sourceforge.net/
http://www.wxpython.org/

In any case, both "normal" PC serial ports and USB-serial ports
looks the same to a Linux app. Windows support for stuff like
that wasn't so good last time I tried, but it's supposed to work.
2. Develop a simple vector drawing program that will allow one
to freehand draw a sketch composed of a few lines, or
perhaps render text in a vector form. Then sample the
lines with a certain (user configurable) spacing, and use
the mouse to move the sample points along the lines to
tweak the sample locations if desired. Then output a file
of X,Y coordinates for the samples.

What is this crazy thing for? It's to develop simple
lasershow vector frames. I am also designing a DSP-based
lasershow output device, so the same capabilities of
delivering a data payload over serial/USB to a target
device will be needed here as well.

Most of the graphics I do with Python is with Gnuplot (not
really appropriate for what you want to do.
wxWidgets/Floatcanvas might be worth looking into.
I would prefer to be able to write a program that is cross-platform
between Linux and Windows. I realize this might be especially
problematic with the serial comms.

Not at all. Cross-platform serial stuff is easy.
I am also confused by the plethora of Python GUI extensions,
though Tkinter seems like a likely candidate. I am uncertain
if I will have difficulty learning how to use this if I don't
know Tcl/Tk.


Tk's canvas widget is pretty powerful, and you don't need to
know Tcl -- it's all hidden behind a veneer of Python.
Do you think Python is the right language for these projects?

It's what I use for stuff like that.
 
M

Michele Simionato

2. Develop a simple vector drawing program that will allow one to
freehand draw a sketch composed of a few lines, or perhaps render text
in a vector form. Then sample the lines with a certain (user
configurable) spacing, and use the mouse to move the sample points along
the lines to tweak the sample locations if desired. Then output a file
of X,Y coordinates for the samples.

You may look at dia for that.

Michele Simionato
 
H

Hendrik van Rooyen

CC said:
I have considerable C and assembly language experience. However, these
are mostly on embedded microcontrollers since I moved away from PC
programming all the way back in 1988 :-O

Your experience parallels mine, except that mine has a surfeit of assembler...
I wish to accomplish a few PC programming tasks, and am considering to
learn Python:

go for it - you will be delighted with the simplicity of the complex stuff,
and irritated at the hoops that you have to jump through to do low level stuff,
but the trade off is worth the pain.
1. Develop a simple GUI program to run on Linux and Windows which can
send parameters and small blocks of data to an embedded microcontroller
device via RS-232 or USB. Also display simple data (probably single
numbers) sent from the device.

If you spend a bit of money on a Lantronix Xport, you can use ethernet,
and then the linux/windows problems goes away - as sockets seem to
"just work"
Note, if it is USB, then the client will be implemented by me using FTDI
chips that appear to the PC as a serial port.

2. Develop a simple vector drawing program that will allow one to
freehand draw a sketch composed of a few lines, or perhaps render text
in a vector form. Then sample the lines with a certain (user
configurable) spacing, and use the mouse to move the sample points along
the lines to tweak the sample locations if desired. Then output a file
of X,Y coordinates for the samples.

What is this crazy thing for? It's to develop simple lasershow vector
frames. I am also designing a DSP-based lasershow output device, so the
same capabilities of delivering a data payload over serial/USB to a
target device will be needed here as well.

I would prefer to be able to write a program that is cross-platform
between Linux and Windows. I realize this might be especially
problematic with the serial comms.

true - its not quite the same.
I am also confused by the plethora of Python GUI extensions, though
Tkinter seems like a likely candidate. I am uncertain if I will have
difficulty learning how to use this if I don't know Tcl/Tk.

No - there are excellent examples and docs available on the web.
Unless you are doing something very fancy, you dont "need" to know Tcl.

The development cycle is fast, and if you get stuck you can get help
here - this is a super group of people (said he modestly... :- ) )
Do you think Python is the right language for these projects?

Yes - I am in the process of finishing an Injection Moulding Machine
Controller, with the GUI in tkinter (cos its in the standard library),
with some crude animation of the machine functions - and it all "just works"

In my case, the OS is linux, and the interface is serial - but then I am not
trying for cross platform compatibility. - I have implemented a sliding
window full duplex reliable protocol, so it is possible to use Python to
talk to a serial device. (at 115200, so its not "that" slow)
Any input will be appreciated.

hth - Hendrik
 
B

Bjoern Schliessmann

Grant said:
Most of the graphics I do with Python is with Gnuplot (not
really appropriate for what you want to do.
wxWidgets/Floatcanvas might be worth looking into.

Agreed (I'm quite sure you mean wxPython though). Also, in "wxPython
in Action" (the official book) a simple drawing app is constructed.
It could help to start from there.

Regards,


Björn
 
N

Nick Craig-Wood

CC said:
I have considerable C and assembly language experience. However, these
are mostly on embedded microcontrollers since I moved away from PC
programming all the way back in 1988 :-O

I wish to accomplish a few PC programming tasks, and am considering to
learn Python:

1. Develop a simple GUI program to run on Linux and Windows which can
send parameters and small blocks of data to an embedded microcontroller
device via RS-232 or USB. Also display simple data (probably single
numbers) sent from the device.

Note, if it is USB, then the client will be implemented by me using FTDI
chips that appear to the PC as a serial port.

No problems - pyserial, wxPython work fine cross platform. You can
also use libusb from python from windows and linux also for low level
USB stuff. I've managed to use all those things successfully.
I would prefer to be able to write a program that is cross-platform
between Linux and Windows. I realize this might be especially
problematic with the serial comms.

On the contrary, pyserial does a very good job of abstracting the
serial port away.
I am also confused by the plethora of Python GUI extensions, though
Tkinter seems like a likely candidate. I am uncertain if I will have
difficulty learning how to use this if I don't know Tcl/Tk.

Use wxPython would be my advice. tk is OK, but a bit clunky. it does
have the advantage that it is built into the language though.
Do you think Python is the right language for these projects?

Yes!
 
C

CC

Hendrik said:
If you spend a bit of money on a Lantronix Xport, you can use ethernet,
and then the linux/windows problems goes away - as sockets seem to
"just work"

Yeah, that's neato. Trouble is, I work at a national lab, which is
where some of these apps will be developed. They have a big problem
with ethernet devices. Basically, it's almost impossible to use
ethernet on other than PCs, on the official LAN.

I will have to look into this further though, as higher data rate stuff
is a problem with serial. Although I could do 10Mbps RS-422 I suppose.
>>[edit]
I am also confused by the plethora of Python GUI extensions, though
Tkinter seems like a likely candidate. I am uncertain if I will have
difficulty learning how to use this if I don't know Tcl/Tk.

No - there are excellent examples and docs available on the web.
Unless you are doing something very fancy, you dont "need" to know Tcl.

The development cycle is fast, and if you get stuck you can get help
here - this is a super group of people (said he modestly... :- ) )

Yeah, that's really great. Our in-house programmer uses wxPython, I've
discovered, so that's a strong push in that direction. Though he isn't
totally unfamiliar with TkInter too.
Yes - I am in the process of finishing an Injection Moulding Machine
Controller, with the GUI in tkinter (cos its in the standard library),
with some crude animation of the machine functions - and it all "just works"

Thanks for the input.

I am not seeing anything to indicate that Python isn't the direction in
which I should head.

Good day!
 
C

CC

Bjoern said:
Agreed (I'm quite sure you mean wxPython though). Also, in "wxPython
in Action" (the official book) a simple drawing app is constructed.
It could help to start from there.

Ooh, that's interesting.

The programming contractor at work who does all our DAQ stuff also uses
wxPython so it's looking like I should use that since I can get lots of
help.


Thanks for the book tip.
 
C

CC

Michele said:
You may look at dia for that.

Michele Simionato

Thanks for the input.

Yes, I will have a look. Makes sense to check out if any drawing progs
can do what I want off the shelf.

But it might be fun to write one anyway!
 
H

Hendrik van Rooyen

8< -----------------------------------------------------------
Basically, it's almost impossible to use
ethernet on other than PCs, on the official LAN.

I will have to look into this further though, as higher data rate stuff
is a problem with serial. Although I could do 10Mbps RS-422 I suppose.

This kind of implies USB into the PC - Haven't seen a 16550 driven much
above 1Mb/s

As you have a DSP in the system think about USB (with the chips you mentioned)
into a DSP then the DSP's serial port converted to RS-485 for every signal
(clock, data in and out and sync) and then everything is native DSP on the
remote device.

That gives you multiple channels of better than Audio response, full duplex.

And since your eyes are slower than your ears, that should be good enough...

- Hendrik
 
C

Chris Mellon

Ooh, that's interesting.

The programming contractor at work who does all our DAQ stuff also uses
wxPython so it's looking like I should use that since I can get lots of
help.

Since the book was written, wxPython has grown a vector graphics
system that might be more suitable for your needs. Look at the
wxGraphicsContext class.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,057
Messages
2,570,443
Members
47,113
Latest member
XZJMike318

Latest Threads

Top