Real Time Embedded Systems Monitor in Python?

F

frikk

Hey Everyone!
I've got a question regarding the capabilities of python in a real
time environment. I'll start by saying I'm a little bit flaky when it
comes to terminology, so please correct me or ask where it seems I'm
not beings specific or using the wrong wording.

I am looking into a project for the company I work for. Essentially
it involves setting up a real time monitor / signal injector in
between a CPU board and a system controller. The system controller
sends signals (message packets) to the CPU board. We would like to
create an environment where we can modify signals, inject new
messages, drop signals, etc. This would simulate communication
failures and message dropouts to see how the CPU board responds. The
application monitor would use a COM port to send and receive
messages. The most important part about this monitor is that
absolutely no messages get delayed or dropped due to inturrupts or lag
on the PC that the monitor is running on. What would be the expected
sampling time range that I could expect to handle?

I have seen similar applications written for other projects that we
have which were done in Visual Basic. I assume that if VB is up to the
task, Python should be as well. What kind of libraries am I looking
at? I will probably use wxWindows, but what about for the serial ports
and packet timing?

Like I said - I'm not sure what kind of "real time" this is - all I
know is that I need messages to not get dropped when they're received.

Thanks!
Blaine Booher
 
D

Dennis Lee Bieber

I am looking into a project for the company I work for. Essentially
it involves setting up a real time monitor / signal injector in
between a CPU board and a system controller. The system controller
sends signals (message packets) to the CPU board. We would like to
create an environment where we can modify signals, inject new
messages, drop signals, etc. This would simulate communication
failures and message dropouts to see how the CPU board responds. The
application monitor would use a COM port to send and receive
messages. The most important part about this monitor is that
absolutely no messages get delayed or dropped due to inturrupts or lag
on the PC that the monitor is running on. What would be the expected
sampling time range that I could expect to handle?
Insufficient information: processor speed, OS, UART capabilities,
dedicated or general usage (ie, are you running a spreadsheet in
parallel?); protocol specs... (if the messages are in an byte-HDLC
format, the timing may be slightly tighter).
I have seen similar applications written for other projects that we
have which were done in Visual Basic. I assume that if VB is up to the
task, Python should be as well. What kind of libraries am I looking
at? I will probably use wxWindows, but what about for the serial ports
and packet timing?
Visual C++ isn't up to the job of tight realtime! Mainly because
Windows isn't up to realtime specs. I had an application that had to
precisely time output on a parallel port (using an external clock signal
coming in on the port)... Even with the program running in "realtime"
priority class on W98 (don't ask*), the timing became glitched every 200
or so "ticks".

One thing -- you probably do not want the serial port handler to be
in the same thread as the GUI. As for module: pyserial is about all that
I know of (unless you intend to go down to the level of win32 I/O
calls). Inbound timing you have no control over -- the hardware will
interrupt as the UART fills, and the OS I/O subsystem will pass data to
any pending read operation (which will probably work better if you have
a recognized "end-of-packet" -- like a newline -- that the subsystem can
use to send complete packets to the application; otherwise you run the
overhead of reading one byte at a time and parsing). Outbound? Well,
once you pass a complete packet to the I/O subsystem (via a write
operation), the OS will be sending bytes to the UART whenever it signals
the buffer is near empty...

Like I said - I'm not sure what kind of "real time" this is - all I
know is that I need messages to not get dropped when they're received.
If you are using serial ports, you're probably already using
interrupt driven behavior. Are the systems using RTS/CTS (hardware
handshake)? Any modern machine has a UART with 16-byte buffering.
Question now is: what baud-rate? Your requirements will be quite loose
at <19200 (some machines can keep up 19200 WITHOUT handshaking, just
using the start/stop bits of each byte). At 115Kbps, you'd better be
using hardware handshaking (maybe with the UART set to interrupt at
8-bytes, giving you an 8-byte margin to respond and read).

Serial ports are commonly asynchronous -- other than the bit-rate
per byte, the data transfer is not hard realtime. The UART doesn't care
if byte-2 comes immediately after byte-1, or next month <G>





* Okay, I'll inflict the pain on you anyways: government furnished
laptop; used six of the 8 data pins on the port to emulate 3 balanced
serial output signal -- as a pseudo ground station command formatter. At
the time, GPS PPS keys couldn't pass through the full ground station
without turning the station fully classified/crypto; the laptop could be
kept secure and plugged in for key uploads. Keys could not be stored on
disk, had to be taken directly from DTD to output port after packing
into upload commands; then memory wiped.
--
Wulfraed Dennis Lee Bieber KD6MOG
(e-mail address removed) (e-mail address removed)
HTTP://wlfraed.home.netcom.com/
(Bestiaria Support Staff: (e-mail address removed))
HTTP://www.bestiaria.com/
 
H

Hendrik van Rooyen

frikk said:
I am looking into a project for the company I work for. Essentially
it involves setting up a real time monitor / signal injector in
between a CPU board and a system controller. The system controller
sends signals (message packets) to the CPU board. We would like to
create an environment where we can modify signals, inject new
messages, drop signals, etc. This would simulate communication
failures and message dropouts to see how the CPU board responds. The
application monitor would use a COM port to send and receive
messages. The most important part about this monitor is that
absolutely no messages get delayed or dropped due to inturrupts or lag
on the PC that the monitor is running on. What would be the expected
sampling time range that I could expect to handle?

What speed is the serial port running at? I have run a port at 115200 Baud
(albeit not carrying back to back packets), on a pentium II running Linux.

If you are not trying to do something insane like a Fast Fourier Transform in
real time, then Python should do the job for you - I would suggest you just
try it, starting with the smallest subset of commands - should take no longer
than about a week to get a prototype running.

When you say "in between" do you mean in one port and out of another?
So that you have to handle an upstream and downstream serial port?

The sampling time range will be directly (more or less, given some spillage
for turn around times) related to the baud rate, unless its a sort of sliding
window full duplex protocol. (I assume there is some sort of error
detection and recovery scheme - these normally waste about 10% of the
available bandwidth)
I have seen similar applications written for other projects that we
have which were done in Visual Basic. I assume that if VB is up to the
task, Python should be as well. What kind of libraries am I looking
at? I will probably use wxWindows, but what about for the serial ports
and packet timing?

Start off with a basic character interface, and use the serial module,
solving the protocol hassles first.
You can add the pretty pictures afterwards.

hth - Hendrik
 

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

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top