Com port interrupts again

engsol engsolnorm at peak.org
Sat Jan 15 22:59:38 CET 2005


On Fri, 14 Jan 2005 23:25:21 -0500, Peter Hansen <peter at engcorp.com> wrote:

>engsol wrote:
>> I didn't fully think through my application before posting my
>> question. Async com port routines to handle com port interrups
>> only work well if one has access to the low level operating
>> system. In that case the receive buffer interrupt would cause
>> a jump to an interrupt service routine.. I don't believe that
>> Python provides that capabilty directly. The solution then would
>> be to write a C extention?
>
>Maybe, but I doubt that you can or would really want to do this
>with modern operating systems anyway.  With DOS, and similar
>primitive things, glomming onto an interrupt or hooking yourself
>into the interrupt table was pretty easy.  I don't think either
>Windows or Linux is structured such that you just "write a
>C extension" to intercept interrupts.  Instead, you must write
>relatively complicated drivers which have to be loaded at
>system startup (more or less) and be tied into the kernel at
>a relatively low level.  Think "rocket science", at least in
>comparison to writing a simple C extension. :-)
>
>> The suggestions offered by respondents to my original post
>> were almost all of a "Use threads, and poll as needed" flavor.
>> You're right...I need to learn threads as applied to com ports.
>
>At least on Windows, I'm fairly sure you can configure the
>read timeouts so that you get behaviour on reads that for
>all intents and purposes is about as good as an interrupt,
>without the difficulties inherent in that approach, but
>provided you are willing to dedicate a thread to the task.
>
>On Linux, it's possible the read timeouts capabilities are
>a little less flexible (but I've only just barely glanced
>at this area), but as I recall you were on Windows anyway.
>
>BTW, another post pointed you to USPP.  As far as I know,
>it hasn't been updated recently and, while I can't say how
>it compares to PySerial, I believe it's fair to say at
>this point in time that PySerial is the _de facto_ standard
>way to do serial port stuff in Python.  If it doesn't do
>what you need, it's probably a good idea to at least point
>that out in its mailing list so that it can be improved.
>
>-Peter

Peter, thanks for the input...good advice. I took a look at USPP,
and as you observed, it seems to be a bit dated.

Actually, I've violated one of my basic rules: do it the simple way
first, then determine what needs to be expanded, improved, speeded up,
etc.
Norm B




More information about the Python-list mailing list